diff options
author | gabor <gabor@FreeBSD.org> | 2007-02-27 02:57:31 +0800 |
---|---|---|
committer | gabor <gabor@FreeBSD.org> | 2007-02-27 02:57:31 +0800 |
commit | b83b818bd34836417031f549c41f2994be2d547a (patch) | |
tree | b8dcfb9eff920bbaaba0e7ade80556107208a15d /security/vpnc | |
parent | edf45669c5aa45a1569a96ad396d4480665dc3a2 (diff) | |
download | freebsd-ports-gnome-b83b818bd34836417031f549c41f2994be2d547a.tar.gz freebsd-ports-gnome-b83b818bd34836417031f549c41f2994be2d547a.tar.zst freebsd-ports-gnome-b83b818bd34836417031f549c41f2994be2d547a.zip |
- Update rc.d script
- Use USE_RC_SUBR instead of direct patching
- Bump PORTREVISION
PR: ports/107675
Submitted by: Dominic Fandrey <lon_kamikaze@gmx.de> (with fixes from maintainer)
Approved by: Christian Lackas <delta@lackas.net> (maintainer),
erwin (mentor, implicit)
Diffstat (limited to 'security/vpnc')
-rw-r--r-- | security/vpnc/Makefile | 10 | ||||
-rw-r--r-- | security/vpnc/files/vpnc.in | 95 | ||||
-rw-r--r-- | security/vpnc/files/vpnc.sh | 29 |
3 files changed, 99 insertions, 35 deletions
diff --git a/security/vpnc/Makefile b/security/vpnc/Makefile index 5dda87bbd806..ad67b9d7c003 100644 --- a/security/vpnc/Makefile +++ b/security/vpnc/Makefile @@ -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/ @@ -19,11 +19,12 @@ LIB_DEPENDS= gcrypt.13:${PORTSDIR}/security/libgcrypt USE_GMAKE= yes ALL_TARGET= vpnc +USE_RC_SUBR= vpnc + PLIST_FILES= sbin/vpnc \ sbin/vpnc-script \ sbin/vpnc-disconnect \ - etc/vpnc.conf.sample \ - etc/rc.d/vpnc.sh.sample + etc/vpnc.conf.sample PORTDOCS= README ChangeLog TODO MAN8= vpnc.8 @@ -41,9 +42,6 @@ do-install: @${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_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 --git a/security/vpnc/files/vpnc.in b/security/vpnc/files/vpnc.in new file mode 100644 index 000000000000..edc19820a1a4 --- /dev/null +++ b/security/vpnc/files/vpnc.in @@ -0,0 +1,95 @@ +#!/bin/sh +# +# Author: kamikaze +# Contact: LoN_Kamikaze@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" diff --git a/security/vpnc/files/vpnc.sh b/security/vpnc/files/vpnc.sh deleted file mode 100644 index 031d2ed3917d..000000000000 --- a/security/vpnc/files/vpnc.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/sh - -PREFIX=%%PREFIX%% -PIDFILE=/var/run/vpnc.pid - -# change these variables and activate comments -# below to get a full tunnel -VPNGATEWAY=vpn.rwth-aachen.de -ROUTER=192.168.111.2 - -case "$1" in -start) - [ -x ${PREFIX}/sbin/vpnc ] && ${PREFIX}/sbin/vpnc --pid-file ${PIDFILE} && - # route add -host ${VPNGATEWAY} ${ROUTER} - # route delete default && - # route add default -interface tun0 && - echo -n ' vpnc' - ;; -stop) - kill `cat ${PIDFILE}` - # route delete default && - # route add default ${ROUTER} - ;; -*) - echo "Usage: `basename $0` {start|stop}" >&2 - ;; -esac - -exit 0 |