diff -u openvpn-2.1~rc9/debian/changelog openvpn-2.1~rc9/debian/changelog --- openvpn-2.1~rc9/debian/changelog +++ openvpn-2.1~rc9/debian/changelog @@ -1,3 +1,10 @@ +openvpn (2.1~rc9-3ubuntu2) intrepid; urgency=low + + * Added 'status' action to init script (LP: #251641) + * Added lsb-base>=3.2-14 depend to allow status_of_proc() + + -- Thierry Carrez Fri, 05 Sep 2008 13:41:29 +0200 + openvpn (2.1~rc9-3ubuntu1) intrepid; urgency=low * debian/openvpn.init.d: Add "--script-security 2" by default for backwards compatibility diff -u openvpn-2.1~rc9/debian/control openvpn-2.1~rc9/debian/control --- openvpn-2.1~rc9/debian/control +++ openvpn-2.1~rc9/debian/control @@ -8,7 +8,7 @@ Package: openvpn Architecture: any -Depends: debconf | debconf-2.0, ${shlibs:Depends}, libssl0.9.8 (>= 0.9.8g-9), openssl-blacklist (>= 0.4), openvpn-blacklist +Depends: debconf | debconf-2.0, ${shlibs:Depends}, libssl0.9.8 (>= 0.9.8g-9), openssl-blacklist (>= 0.4), openvpn-blacklist, lsb-base (>= 3.2-14) Recommends: net-tools Suggests: openssl, resolvconf Description: virtual private network daemon diff -u openvpn-2.1~rc9/debian/openvpn.init.d openvpn-2.1~rc9/debian/openvpn.init.d --- openvpn-2.1~rc9/debian/openvpn.init.d +++ openvpn-2.1~rc9/debian/openvpn.init.d @@ -194,8 +194,70 @@ done log_end_msg 0 ;; +status) + GLOBAL_STATUS=0 + if test -z "$2" ; then + # We want status for all defined VPNs. + # Returns success if all autostarted VPNs are defined and running + if test "x$AUTOSTART" = "xnone" ; then + # Consider it a failure if AUTOSTART=none + log_warning_msg "No VPN autostarted" + GLOBAL_STATUS=1 + else + if ! test -z "$AUTOSTART" -o "x$AUTOSTART" = "xall" ; then + # Consider it a failure if one of the autostarted VPN is not defined + for VPN in $AUTOSTART ; do + if ! test -f $CONFIG_DIR/$VPN.conf ; then + log_warning_msg "VPN '$VPN' is in AUTOSTART but is not defined" + GLOBAL_STATUS=1 + fi + done + fi + fi + for CONFIG in `cd $CONFIG_DIR; ls *.conf 2> /dev/null`; do + NAME=${CONFIG%%.conf} + # Is it an autostarted VPN ? + if test -z "$AUTOSTART" -o "x$AUTOSTART" = "xall" ; then + AUTOVPN=1 + else + if test "x$AUTOSTART" = "xnone" ; then + AUTOVPN=0 + else + AUTOVPN=0 + for VPN in $AUTOSTART ; do + if test "x$VPN" = "x$NAME" ; then + AUTOVPN=1 + fi + done + fi + fi + if test "x$AUTOVPN" = "x1" ; then + # If it is autostarted, then it contributes to global status + status_of_proc -p /var/run/openvpn.${NAME}.pid openvpn "VPN '${NAME}'" || GLOBAL_STATUS=1 + else + status_of_proc -p /var/run/openvpn.${NAME}.pid openvpn "VPN '${NAME}' (non autostarted)" + fi + done + else + # We just want status for specified VPNs. + # Returns success if all specified VPNs are defined and running + while shift ; do + [ -z "$1" ] && break + NAME=$1 + if test -e $CONFIG_DIR/$NAME.conf ; then + # Config exists + status_of_proc -p /var/run/openvpn.${NAME}.pid openvpn "VPN '${NAME}'" || GLOBAL_STATUS=1 + else + # Config does not exist + log_warning_msg "VPN '$NAME': missing $CONFIG_DIR/$NAME.conf file !" + GLOBAL_STATUS=1 + fi + done + fi + exit $GLOBAL_STATUS + ;; *) - echo "Usage: $0 {start|stop|reload|restart|force-reload|cond-restart}" >&2 + echo "Usage: $0 {start|stop|reload|restart|force-reload|cond-restart|status}" >&2 exit 1 ;; esac