ports/107675: security/vpnc suggest rc.d script
Christian Lackas
delta at lackas.net
Tue Jan 23 17:40:24 UTC 2007
The following reply was made to PR ports/107675; it has been noted by GNATS.
From: Christian Lackas <delta at lackas.net>
To: bug-followup at FreeBSD.ORG
Cc: "[LoN]Kamikaze" <LoN_Kamikaze at gmx.de>, Edwin Groothuis <edwin at FreeBSD.ORG>
Subject: Re: ports/107675: security/vpnc suggest rc.d script
Date: Tue, 23 Jan 2007 18:36:55 +0100
Hi Everyone,
thanks for the submission, the new start script looks good and works
fine. Please find attached a patch with a PREFIX-aware version of the
script as well as the required changes to the Makefile.
Please remove the old file in files/vpnc.sh.
Best regards,
Christian (Maintainer)
diff -Nur /usr/ports/security/vpnc/Makefile vpnc/Makefile
--- /usr/ports/security/vpnc/Makefile Sat Jul 29 22:41:30 2006
+++ vpnc/Makefile Tue Jan 23 18:34:22 2007
@@ -7,7 +7,7 @@
PORTNAME= vpnc
PORTVERSION= 0.3.3
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= security
MASTER_SITES= http://www.unix-ag.uni-kl.de/~massar/vpnc/
@@ -23,7 +23,7 @@
sbin/vpnc-script \
sbin/vpnc-disconnect \
etc/vpnc.conf.sample \
- etc/rc.d/vpnc.sh.sample
+ etc/rc.d/vpnc
PORTDOCS= README ChangeLog TODO
MAN8= vpnc.8
@@ -41,9 +41,9 @@
@${INSTALL_PROGRAM} -m 751 ${WRKSRC}/vpnc ${PREFIX}/sbin/vpnc
@${INSTALL_SCRIPT} -m 751 ${WRKSRC}/vpnc-script ${PREFIX}/sbin/vpnc-script
@${INSTALL_SCRIPT} -m 751 ${WRKSRC}/vpnc-disconnect ${PREFIX}/sbin/vpnc-disconnect
- @${INSTALL_SCRIPT} ${FILESDIR}/vpnc.sh ${WRKDIR}
- @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' ${WRKDIR}/vpnc.sh
- @${INSTALL_SCRIPT} -m 755 ${WRKDIR}/vpnc.sh ${PREFIX}/etc/rc.d/vpnc.sh.sample
+ @${INSTALL_SCRIPT} ${FILESDIR}/vpnc ${WRKDIR}
+ @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' ${WRKDIR}/vpnc
+ @${INSTALL_SCRIPT} -m 755 ${WRKDIR}/vpnc ${PREFIX}/etc/rc.d/vpnc
@${INSTALL_DATA} -m 600 ${WRKSRC}/vpnc.conf ${PREFIX}/etc/vpnc.conf.sample
.if !defined(NO_INSTALL_MANPAGES)
@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' ${WRKSRC}/vpnc.8
diff -Nur /usr/ports/security/vpnc/files/vpnc vpnc/files/vpnc
--- /usr/ports/security/vpnc/files/vpnc Thu Jan 1 01:00:00 1970
+++ vpnc/files/vpnc Tue Jan 23 18:28:48 2007
@@ -0,0 +1,95 @@
+#!/bin/sh
+#
+# Author: kamikaze
+# Contact: LoN_Kamikaze at gmx.de
+#
+# 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.
+#
+
+# PROVIDE: vpnc
+# REQUIRE: NETWORKING
+# KEYWORD: FreeBSD 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
+
+name="vpnc"
+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.
+ $command $vpnc_flags
+ return $?
+ fi
+}
+
+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
+ /bin/sleep 1
+ # There's no record of connections, asume unmanaged shutdown.
+ $command-disconnect
+ return $?
+ fi
+}
+
+start_cmd=vpnc_start
+stop_cmd=vpnc_stop
+
+load_rc_config $name
+run_rc_command "$1"
--
http://www.lackas.net/ Perl Delphi Linux MP3 Searchengines Domainchecker
http://www.spect-ct.com/
More information about the freebsd-ports-bugs
mailing list