[OpenVPN home] [Date Prev] [Date Index] [Date Next]
[OpenVPN mailing lists] [Thread Prev] [Thread Index] [Thread Next]
Google
 
Web openvpn.net

[Openvpn-users] small patch


  • Subject: [Openvpn-users] small patch
  • From: Farkas Levente <lfarkas@xxxxxxx>
  • Date: Mon, 10 Nov 2003 13:09:58 +0100

hi,
here's a small pacth to the current cvs, I hope these will included before 1.5.
- in the spec file mark config file as config and noreplace, this can avoid if someone change something in a config file, than after an upgrade he loose it (and all of me connections stop:-(). anyway this used to be the normal setup.
- change the init script to search for config files in all subdirectory of /etc/openvpn. to be able to structure your config files (if you have more).


--
  Levente                               "Si vis pacem para bellum!"
--- openvpn/sample-scripts/openvpn.init.lfarkas	2003-11-10 12:25:47.000000000 +0100
+++ openvpn/sample-scripts/openvpn.init	2003-11-10 13:06:12.000000000 +0100
@@ -58,13 +58,13 @@
 #     returning success or failure status to caller (James Yonan).
 
 # Location of openvpn binary
-openvpn="/usr/sbin/openvpn"
+openvpn=/usr/sbin/openvpn
 
 # Lockfile
-lock="/var/lock/subsys/openvpn"
+lock=/var/lock/subsys/openvpn
 
 # PID directory
-piddir="/var/run/openvpn"
+piddir=/var/run/openvpn
 
 # Our working directory
 work=/etc/openvpn
@@ -94,13 +94,19 @@
 
 	#echo 1 > /proc/sys/net/ipv4/ip_forward
 
+	cd $work
 	if [ ! -d  $piddir ]; then
 	    mkdir $piddir
 	fi
+	for d in `find * -type d`; do
+	    if [ ! -d  $piddir/$d ]; then
+	      mkdir $piddir/$d
+	    fi
+	done
 
 	if [ -f $lock ]; then
 	    # we were not shut down correctly
-	    for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do
+	    for pidf in `find $piddir -name "*.pid" 2>/dev/null`; do
 	      if [ -s $pidf ]; then
 		kill `cat $pidf` >/dev/null 2>&1
 	      fi
@@ -110,13 +116,12 @@
 	    sleep 2
 	fi
 
-	rm -f $piddir/*.pid
-	cd $work
+	find $piddir -name "*.pid"|xargs rm -f
 
 	# Start every .conf in $work and run .sh if exists
 	errors=0
 	successes=0
-	for c in `/bin/ls *.conf 2>/dev/null`; do
+	for c in `find * -name "*.conf" 2>/dev/null`; do
 	    bn=${c%%.conf}
 	    if [ -f "$bn.sh" ]; then
 		. $bn.sh
@@ -142,7 +147,7 @@
 	;;
   stop)
 	echo -n $"Shutting down openvpn: "
-	for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do
+	for pidf in `find $piddir -name "*.pid" 2>/dev/null`; do
 	  if [ -s $pidf ]; then
 	    kill `cat $pidf` >/dev/null 2>&1
 	  fi
@@ -158,7 +163,7 @@
 	;;
   reload)
 	if [ -f $lock ]; then
-	    for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do
+	    for pidf in `find $piddir -name "*.pid" 2>/dev/null`; do
 		if [ -s $pidf ]; then
 		    kill -HUP `cat $pidf` >/dev/null 2>&1
 		fi
@@ -170,7 +175,7 @@
 	;;
   reopen)
 	if [ -f $lock ]; then
-	    for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do
+	    for pidf in `find $piddir -name "*.pid" 2>/dev/null`; do
 		if [ -s $pidf ]; then
 		    kill -USR1 `cat $pidf` >/dev/null 2>&1
 		fi
@@ -190,7 +195,7 @@
 	;;
   status)
 	if [ -f $lock ]; then
-	    for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do
+	    for pidf in `find $piddir -name "*.pid" 2>/dev/null`; do
 		if [ -s $pidf ]; then
 		    kill -USR2 `cat $pidf` >/dev/null 2>&1
 		fi
--- openvpn/openvpn.spec.in.lfarkas	2003-11-10 12:43:16.000000000 +0100
+++ openvpn/openvpn.spec.in	2003-11-10 12:57:02.000000000 +0100
@@ -34,9 +34,9 @@
 %__install -c -m 755 %{name}.8 %{buildroot}%{_mandir}/man8
 %__install -c -d -m 755 %{buildroot}%{_sbindir}
 %__install -c -m 755 %{name} %{buildroot}%{_sbindir}
-%__install -c -d -m 755 %{buildroot}/etc/rc.d/init.d
-%__install -c -m 755 sample-scripts/%{name}.init %{buildroot}/etc/rc.d/init.d/%{name}
-%__install -c -d -m 755 %{buildroot}/etc/%{name}
+%__install -c -d -m 755 %{buildroot}%{_sysconfdir}%{_initrddir}
+%__install -c -m 755 sample-scripts/%{name}.init %{buildroot}%{_sysconfdir}%{_initrddir}/%{name}
+%__install -c -d -m 755 %{buildroot}%{_sysconfdir}/%{name}
 
 %__mkdir_p %{buildroot}%{_datadir}/%{name}
 %__cp -pr easy-rsa sample-{config-file,key,script}s %{buildroot}%{_datadir}/%{name}
@@ -67,9 +67,12 @@
 %{_mandir}/man8/%{name}.8*
 %{_sbindir}/%{name}
 %{_datadir}/%{name}
-/etc
+%config(noreplace) %{_sysconfdir}
 
 %changelog
+* Mon Nov 10 2003 Levente Farkas <lfarkas@xxxxxxxxxxx> 1.5_rc1
+- Mark config file as config.
+
 * Sun Feb 23 2003 Matthias Andree <matthias.andree@xxxxxx> 1.3.2.14-1.
 - Have the version number filled in by autoconf.