Lines 7-30
Link Here
|
7 |
# BEFORE: LOGIN |
7 |
# BEFORE: LOGIN |
8 |
# KEYWORD: shutdown |
8 |
# KEYWORD: shutdown |
9 |
|
9 |
|
|
|
10 |
# strongswan_enable (bool): Set it to "YES" to enable strongswan |
11 |
# Default is "NO" |
12 |
# strongswan_swanctl_loader (bool): Set it to "YES" to use swanctl util and conf |
13 |
# Default is "NO" |
14 |
# |
15 |
|
10 |
. /etc/rc.subr |
16 |
. /etc/rc.subr |
11 |
|
17 |
|
12 |
name=strongswan |
18 |
name=strongswan |
|
|
19 |
desc="Strongswan IPsec startup script" |
13 |
rcvar=strongswan_enable |
20 |
rcvar=strongswan_enable |
14 |
|
21 |
|
15 |
extra_commands="reload statusall" |
|
|
16 |
|
17 |
load_rc_config $name |
22 |
load_rc_config $name |
18 |
|
23 |
|
19 |
command="%%PREFIX%%/sbin/ipsec" |
24 |
: ${strongswan_enable:=NO} |
|
|
25 |
: ${strongswan_swanctl_loader=NO} |
26 |
|
27 |
command=%%PREFIX%%/sbin/ipsec |
28 |
_swanctl_program=%%PREFIX%%/sbin/swanctl |
29 |
_charon_pidfile=/var/run/charon.pid |
30 |
|
31 |
extra_commands="reload statusall" |
20 |
|
32 |
|
21 |
start_precmd="strongswan_precmd" |
33 |
start_precmd=strongswan_start_precmd |
22 |
stop_cmd="strongswan_cmd" |
34 |
start_cmd=strongswan_start |
23 |
status_cmd="strongswan_cmd" |
35 |
stop_cmd=strongswan_cmd |
24 |
reload_cmd="strongswan_cmd" |
36 |
status_cmd=strongswan_status |
25 |
statusall_cmd="strongswan_cmd" |
37 |
reload_cmd=strongswan_reload |
|
|
38 |
statusall_cmd=strongswan_statusall |
26 |
|
39 |
|
27 |
strongswan_precmd() |
40 |
strongswan_start_precmd() |
28 |
{ |
41 |
{ |
29 |
command_args=${rc_arg} |
42 |
command_args=${rc_arg} |
30 |
} |
43 |
} |
Lines 34-37
Link Here
|
34 |
${command} ${rc_arg} |
47 |
${command} ${rc_arg} |
35 |
} |
48 |
} |
36 |
|
49 |
|
|
|
50 |
strongswan_start() |
51 |
{ |
52 |
local _waitcnt=0 |
53 |
local _waitmax=5 |
54 |
|
55 |
strongswan_cmd |
56 |
if checkyesno strongswan_swanctl_loader; then |
57 |
while [ ! -f ${_charon_pidfile} -a \ |
58 |
${_waitcnt} -lt ${_waitmax} ]; do |
59 |
sleep 1 |
60 |
_waitcnt=$((_waitcnt+1)) |
61 |
done |
62 |
${_swanctl_program} --load-all --noprompt |
63 |
fi |
64 |
} |
65 |
|
66 |
strongswan_status() |
67 |
{ |
68 |
if checkyesno strongswan_swanctl_loader; then |
69 |
${_swanctl_program} --stats |
70 |
else |
71 |
strongswan_cmd |
72 |
fi |
73 |
} |
74 |
|
75 |
strongswan_reload() |
76 |
{ |
77 |
if checkyesno strongswan_swanctl_loader; then |
78 |
${_swanctl_program} --reload-settings |
79 |
${_swanctl_program} --load-all --noprompt |
80 |
else |
81 |
strongswan_cmd |
82 |
fi |
83 |
} |
84 |
|
85 |
strongswan_statusall() |
86 |
{ |
87 |
if checkyesno strongswan_swanctl_loader; then |
88 |
${_swanctl_program} --stats |
89 |
${_swanctl_program} --list-conns |
90 |
${_swanctl_program} --list-sas |
91 |
else |
92 |
strongswan_cmd |
93 |
fi |
94 |
} |
95 |
|
37 |
run_rc_command "$1" |
96 |
run_rc_command "$1" |