diff options
author | Gabor Kovesdan <gabor@FreeBSD.org> | 2007-03-05 19:02:04 +0000 |
---|---|---|
committer | Gabor Kovesdan <gabor@FreeBSD.org> | 2007-03-05 19:02:04 +0000 |
commit | e6158dd3983a908563da6d33d89c4f181542f543 (patch) | |
tree | 6cc9fb4210f318197e74e6c1159406af6a635006 /security/vpnc | |
parent | 1f4547516e10ab75421ea312c18202cf546f6852 (diff) | |
download | ports-e6158dd3983a908563da6d33d89c4f181542f543.tar.gz ports-e6158dd3983a908563da6d33d89c4f181542f543.zip |
- Improve the style and behaviour of the rc.d script
- Bump PORTREVISION
Submitted by: dougb
Reviewed by: Dominic Fandrey <lon_kamikaze@gmx.de>
Approved by: Christian Lackas <christian@lackas.net> (maintainer)
Notes
Notes:
svn path=/head/; revision=186598
Diffstat (limited to 'security/vpnc')
-rw-r--r-- | security/vpnc/Makefile | 2 | ||||
-rw-r--r-- | security/vpnc/files/vpnc.in | 111 |
2 files changed, 60 insertions, 53 deletions
diff --git a/security/vpnc/Makefile b/security/vpnc/Makefile index ad67b9d7c003..346d9a4d2cd9 100644 --- a/security/vpnc/Makefile +++ b/security/vpnc/Makefile @@ -7,7 +7,7 @@ PORTNAME= vpnc PORTVERSION= 0.3.3 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= security MASTER_SITES= http://www.unix-ag.uni-kl.de/~massar/vpnc/ diff --git a/security/vpnc/files/vpnc.in b/security/vpnc/files/vpnc.in index edc19820a1a4..283bbacc09c3 100644 --- a/security/vpnc/files/vpnc.in +++ b/security/vpnc/files/vpnc.in @@ -6,18 +6,18 @@ # If vpnc_conf is defined, it will be treated as a list of configuration files # in vpnc_conf_dir. This managed mode is useful where where vpnc tunnels have # to be established through other vpnc tunnels. +# You can pass further command line options to vpnc by specifying +# them in vpnc_flags. # # PROVIDE: vpnc -# REQUIRE: NETWORKING -# KEYWORD: FreeBSD shutdown +# REQUIRE: LOGIN +# KEYWORD: shutdown # Default settings - don't change this. : ${vpnc_enable="NO"} -: ${vpnc_conf=""} : ${vpnc_pid_dir="/var/run"} : ${vpnc_conf_dir="%%PREFIX%%/etc"} -: ${vpnc_flags=""} : ${vpnc_record="$vpnc_pid_dir/vpnc.record"} . /etc/rc.subr @@ -28,64 +28,71 @@ rcvar=`set_rcvar` command="%%PREFIX%%/sbin/$name" vpnc_start() { - if [ "$vpnc_conf" ]; then - # A list of configurations is present. Connect managing - # what is required for a clean shutdown later. - for config in $vpnc_conf; { - # The current configuration file. - current="$vpnc_conf_dir/$config" - # Start vpnc. - $command $current $vpnc_flags - - # Give up on errors. - status=$? - if [ $status -ne 0 ]; then - echo "Running 'vpnc $current $vpnc_flags' failed." - return $status - fi - - # Move files to allow a clean shutdown - # of multiple connections. - /bin/mv "$vpnc_pid_dir/vpnc.pid" "$vpnc_pid_dir/vpnc.$config.pid" - /bin/mv "$vpnc_pid_dir/vpnc.defaultroute" "$vpnc_pid_dir/vpnc.$config.defaultroute" 2> /dev/null - /bin/mv "$vpnc_pid_dir/vpnc.resolv.conf-backup" "$vpnc_pid_dir/vpnc.$config.resolv.conf-backup" 2> /dev/null - echo "$config" >> "$vpnc_record" - - # Wait for the system to catch up. - /bin/sleep 1 - } - else - # No configuration files given, run unmanaged. + if [ -z "$vpnc_conf" ]; then + #No configuration files given, run unmanaged. $command $vpnc_flags return $? fi + + # A list of configurations is present. Connect managing + # what is required for a clean shutdown later. + + for config in $vpnc_conf; do + + # The current configuration file. + current="$vpnc_conf_dir/$config" + + # Start vpnc. + if ! $command $current $vpnc_flags; then + status=$? + echo "Running 'vpnc $current $vpnc_flags' failed." + return $status + fi + + # Move files to allow a clean shutdown + # of multiple connections. + + /bin/mv "$vpnc_pid_dir/vpnc.pid" "$vpnc_pid_dir/vpnc.$config.pid" + /bin/mv "$vpnc_pid_dir/vpnc.defaultroute" "$vpnc_pid_dir/vpnc.$config.defaultroute" 2> /dev/null + /bin/mv "$vpnc_pid_dir/vpnc.resolv.conf-backup" "$vpnc_pid_dir/vpnc.$config.resolv.conf-backup" 2> /dev/null + echo "$config" >> "$vpnc_record" + + # Wait for the system to catch up. + /bin/sleep 1 + done } vpnc_stop() { - if [ -e "$vpnc_record" ]; then - # A record of vpnc connections is present. Attempt a - # managed shutdown. - for config in `/usr/bin/tail -r "$vpnc_record"`; { - # Wait to give the system a chance to catch up with - # recent changes. - /bin/sleep 1 - - # Move the vpnc files back into position. - /bin/mv "$vpnc_pid_dir/vpnc.$config.pid" "$vpnc_pid_dir/vpnc.pid" - /bin/mv "$vpnc_pid_dir/vpnc.$config.defaultroute" "$vpnc_pid_dir/vpnc.defaultroute" 2> /dev/null - /bin/mv "$vpnc_pid_dir/vpnc.$config.resolv.conf-backup" "$vpnc_pid_dir/vpnc.resolv.conf-backup" 2> /dev/null - - # Run the disconnect command. - $command-disconnect - } - # Remove the connection record. - /bin/rm "$vpnc_record" - else + if [ ! -e "$vpnc_record" ]; then /bin/sleep 1 - # There's no record of connections, asume unmanaged shutdown. + # There's no record of connections, assume unmanaged shutdown. $command-disconnect return $? fi + + # A record of vpnc connections is present. Attempt a + # managed shutdown. + + for config in `/usr/bin/tail -r "$vpnc_record"`; do + + # Wait to give the system a chance to catch up with + # recent changes. + + /bin/sleep 1 + + # Move the vpnc files back into position. + + /bin/mv "$vpnc_pid_dir/vpnc.$config.pid" "$vpnc_pid_dir/vpnc.pid" + /bin/mv "$vpnc_pid_dir/vpnc.$config.defaultroute" "$vpnc_pid_dir/vpnc.defaultroute" 2> /dev/null + /bin/mv "$vpnc_pid_dir/vpnc.$config.resolv.conf-backup" "$vpnc_pid_dir/vpnc.resolv.conf-backup" 2> /dev/null + + # Run the disconnect command. + $command-disconnect + done + + # Remove the connection record. + + /bin/rm "$vpnc_record" } start_cmd=vpnc_start |