aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgabor <gabor@FreeBSD.org>2007-03-06 03:02:04 +0800
committergabor <gabor@FreeBSD.org>2007-03-06 03:02:04 +0800
commitd41b58971fcefd73511e636c32d594e10fef8742 (patch)
treecda23fe0e0f4da122ce3164298294fb0f2390e7a
parentb1b54f88cd0ccfb970c12de513c9f1adb98784bd (diff)
downloadfreebsd-ports-gnome-d41b58971fcefd73511e636c32d594e10fef8742.tar.gz
freebsd-ports-gnome-d41b58971fcefd73511e636c32d594e10fef8742.tar.zst
freebsd-ports-gnome-d41b58971fcefd73511e636c32d594e10fef8742.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)
-rw-r--r--security/vpnc/Makefile2
-rw-r--r--security/vpnc/files/vpnc.in111
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