SOURCES: openvpn.init - verbose status

glen glen at pld-linux.org
Fri Jun 16 08:58:42 CEST 2006


Author: glen                         Date: Fri Jun 16 06:58:42 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- verbose status

---- Files affected:
SOURCES:
   openvpn.init (1.21 -> 1.22) 

---- Diffs:

================================================================
Index: SOURCES/openvpn.init
diff -u SOURCES/openvpn.init:1.21 SOURCES/openvpn.init:1.22
--- SOURCES/openvpn.init:1.21	Tue May 30 13:40:40 2006
+++ SOURCES/openvpn.init	Fri Jun 16 08:58:37 2006
@@ -29,13 +29,20 @@
 
 [ -n "$2" ] && TUNNELS="$2"
 
-# check if all the tunnels are up
+# check if all the tunnel $1 is up
 tunlup() {
+	local tun="$1"
+	local pidfile=/var/run/openvpn/$tun.pid
+	local pid=$(cat $pidfile 2>/dev/null)
+	kill -0 $pid 2>/dev/null
+	return $?
+}
+
+# check if all the tunnels are up
+tunlsup() {
 	ret=0
 	for tun in $TUNNELS; do
-		pidfile=/var/run/openvpn/$tun.pid
-		pid=$(cat $pidfile 2>/dev/null)
-		kill -0 $pid 2>/dev/null && continue
+		tulnup $tun && continue
 		ret=1
 	done
 	return $ret
@@ -51,11 +58,11 @@
 	fi
 
 	# Check if the service is already running?
-	if ! tunlup; then
+	if ! tunslup; then
 		msg_starting "OpenVPN"; started
 		for tun in $TUNNELS; do
 			show "Starting OpenVPN tunnel %s" "$tun"
-			if TUNNELS=$tun tunlup; then
+			if tunlup $tun; then
 				started
 				continue
 			fi
@@ -70,7 +77,7 @@
 	fi
 	;;
   stop)
-	if tunlup; then
+	if tunslup; then
 		# Stop daemons.
 		msg_stopping "OpenVPN"; started
 		for tun in $TUNNELS; do
@@ -86,11 +93,18 @@
 	fi
 	;;
   status)
+	nls "Configured tunnels:"
+   	echo " $TUNNELS"
+	nls "Currently active tunnels:"
+	for tun in $TUNNELS; do
+		tunlup $tun && echo -n " $tun($(cat /var/run/openvpn/$tun.pid))"
+	done
+	echo ""
 	status openvpn
 	exit $?
 	;;
   reload|force-reload)
-	if tunlup; then
+	if tunslup; then
 		msg_reloading "OpenVPN"; started
 		for tun in $TUNNELS; do
 			show "Reloading OpenVPN tunnel %s" "$tun"
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/openvpn.init?r1=1.21&r2=1.22&f=u



More information about the pld-cvs-commit mailing list