Pagina 1 di 1

Script rc.openvpn-br

Inviato: gio 3 apr 2008, 21:13
da 414N
Salve a tutti.
Dato che ultimamente sono tornato a "giochicchiare" (stavolta con successo) con openvpn per creare una connessione bridged, ho pensato di rendere disponibile alla comunità lo script che mi sono preparato per lanciare/fermare il demone.
Eccone le caratteristiche:
  • È pensato per avviare / fermare solo una connessione bridged (lato server). Niente connessioni routed (per ora).
  • È necessario configurare alcune variabili alla bisogna nella prima parte del file perchè funzioni.
  • Ho cercato di scrivere tutti i commenti in inglese, in modo da rendere lo script fruibile anche ad eventuali fruitori non italici del forum.
  • Alcune parti sono ridondanti/poco eleganti. Cercherò di aggiustarle prossimamente. Eventuali suggerimenti sono comunque bene accetti . :)
  • Dato che sulla mia configurazione l'avvio/arresto del bridge di rete mi faceva saltare la configurazione di rete, ho inserito un work around (tramite la variabile NEED_RECONF) che ripristina la configurazione di rete (soprattutto il default gateway) alla situazione precedente. È una soluzione che piace poco anche a me... :( Come detto sopra, si accettano consigli.
Versione corrente: 1.02

Bon, penso di aver detto tutto.
Eccovi il listato:

Codice: Seleziona tutto

#!/bin/bash

# Script able to start/stop a configured OpenVPN daemon in bridged mode.
# Brought to you by 414n.
# Version 1.0

# Global vars:

# This is the path to the start/stop bridge scripts that come with OpenVPN.
# The default path is /usr/doc/openvpnx.y/sample-scripts
# You must edit these scripts before launching OpenVPN.
# This variable cannot be left empty.
BRIDGE_SCRIPTS_PATH="/etc/openvpn"

# These are the names of the two scripts to start/stop the bridge.
# You have to edit them accordingly to you settings.
BRIDGE_START_CMD="bridge-start"
BRIDGE_STOP_CMD="bridge-stop"

# This is the OpenVPN executable (complete) path.
# If openvpn is in your path you can leave this field empty.
OPENVPN_PATH=""

# Here you can specify the config file to be used.
# Default is /etc/openvpn/openvpn.conf if unspecified.
OPENVPN_CFG_FILE=/etc/openvpn/openvpn-test1.conf

# These are some other options you may want to pass to the openvpn executable.
# They are not checked.
OPENVPN_OPTS=""

# This tells wether we need to reconfigure the network interface after 
# switching on/off the bridge.
# I think this is only needed when you bridge the network that has internet
# access. It's a pity that the bridge scripts only work with a physical 
# network interface...
# Possible values: TRUE, * (anything else).
NEED_RECONF=TRUE

# This is the gateway ip. If you specify NEED_RECONF=TRUE, the gateway will
# be defaulted to what you type here.
GATEWAY_IP="xx.yy.zz.aa"


# This function performs checks on the information you provided in this script.

initial_checks()
{
# Checking bridge-scripts presence.

	if ! [ -x "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" ]
	then
		echo "Couldn\'t find $BRIDGE_START_CMD in $BRIDGE_SCRIPTS_PATH."
		exit 1
	#else
	#	echo "Bridge scripts found!"
	fi

	# Checking openvpn executable & configuration file existance.

	if [ "$OPENVPN_PATH" -a ! -x "$OPENVPN_PATH" ]
	then
		echo "Couldn\'t find openvpn executable in $OPENVPN_PATH."
		exit 2
	else
		OPENVPN_PATH=`which openvpn`
		if [ ` echo "$OPENVPN_PATH" | grep 'which'` ]
		then
			echo "Couldn\'t find openvpn in you PATH enviroment variable."
			exit 3
		fi
	fi

	if [ "$OPENVPN_CFG_FILE" ]
	then
		if ! [ -e "$OPENVPN_CFG_FILE" ]
		then
			echo "Couldn\'t find openvpn configuration file in $OPENVPN_CFG_FILE".
			exit 3
		fi
	else
		if [ -e "/etc/openvpn/openvpn.conf" ]
		then
			OPENVPN_CFG_FILE="/etc/openvpn/openvpn.conf"
		else
			echo "Couldn\'t find /etc/openvpn/openvpn.conf. Please select a proper configuration file."
			exit 4
		fi
	fi

}

# This function reads information about the actual bridged network interface
# from the bridge-start script, in order to reconfigure it if needed.

getifacedata ()
{
	IFACE=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth=' | cut -d= -f2 | sed -e 's/"//g'`
	IFACE_IP=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth_ip=' | cut -d= -f2 | sed -e 's/"//g'`
	IFACE_NETMASK=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth_netmask=' | cut -d= -f2 | sed -e 's/"//g'`

}

# This function retrieves the openvpn daemon PID

getpid ()
{
	OPENVPN_PID=`ps aux | awk '{ print $2,$11 }' | grep "$OPENVPN_PATH"$ | awk '{ print $1 }'`
}


#This function reconfigures the default gateway only

reconfgateway ()
{
	route add default gw "$GATEWAY_IP"	
}

# This function restores network configuration

reconfnet ()
{
	getifacedata
	ifconfig "$IFACE" "$IFACE_IP" netmask "$IFACE_NETMASK"
}

# This function starts the daemon

start ()
{
	"$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" 1>/dev/null

	if [ $? -ne 0 ]
	then
		echo "Problem starting bridge. Please review bridge settings in "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD". Exiting"
		"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD"
		reconfgateway
		exit 5
	fi

	sleep 1

	if [ "$OPENVPN_OPTS" ]
	then
		"$OPENVPN_PATH" "$OPENVPN_OPTS" "$OPENVPN_CFG_FILE"
	else

		"$OPENVPN_PATH" "$OPENVPN_CFG_FILE"
	fi

	if [ $? -ne 0 ]
	then
		echo "Something screwed up..."
		"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD"
		reconfgateway
		exit 9
	fi

	if [ "$NEED_RECONF" == "TRUE" ]
	then
		reconfgateway
	fi
}

# This function stops the daemon
# Arguments:
# $1 : OpenVPN process PID

stop ()
{
	kill -9 "$1"
	"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD" 1>/dev/null
	if [ $? -ne 0 ]
	then
		echo "Problem stopping bridge. Please review settings in $BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD. Exiting"
		exit 6
	fi

	if [ "$NEED_RECONF" == "TRUE" ]
	then
		reconfnet
		reconfgateway
	fi

}

initial_checks

case "$1" in
start)
	getpid
	if [ "$OPENVPN_PID" ]
	then
		echo "OpenVPN is already running (PID=$OPENVPN_PID)."
		exit 7
	else
		if [ -z "`lsmod | grep tun`" ]
		then
			modprobe tun
		fi
		echo -n "Starting OpenVPN..."
		sleep 1
		start
		echo "Done."
	fi
;;
stop)
	getpid
	if [ "$OPENVPN_PID" ]
	then
		echo -n "Stopping OpenVPN..."
		stop "$OPENVPN_PID"
		if [ `lsmod | grep tun | awk '{ print $3 }'` == "0" ]
		then
			modprobe -r tun
		fi
		modprobe -r bridge
		echo "Done."
	else
		echo "OpenVPN is not running."
		exit 8
	fi
;;
*)
	echo "Usage: `basename $0` start/stop."
	exit 1
;;
esac
Fatene buon uso :thumbright:

PS: se qualcuno conosce un metodo per far "mangiare" al bridge un'interfaccia virtuale mi faccia un fischio please. Ho già provato con gli alias delle interfaccie di rete ma pretende un'interfaccia fisica...

UPDATE v. 1.01: aggiunto un controllo sull'opzione daemon, in modo che openvpn venga eseguito sempre come daemon.

Codice: Seleziona tutto

#!/bin/bash

# Script able to start/stop a configured OpenVPN daemon in bridged mode.
# Brought to you by 414n.
# Version 1.01

# Global vars:

# This is the path to the start/stop bridge scripts that come with OpenVPN.
# The default path is /usr/doc/openvpnx.y/sample-scripts
# You must edit these scripts before launching OpenVPN.
BRIDGE_SCRIPTS_PATH="/etc/openvpn"

# These are the names of the two scripts to start/stop the bridge.
# You have to edit them accordingly to your settings.
BRIDGE_START_CMD="bridge-start"
BRIDGE_STOP_CMD="bridge-stop"

# This is the OpenVPN executable (complete) path.
# If openvpn is in your path you can leave this field empty.
OPENVPN_PATH=""

# Here you can specify the config file to be used.
# Default is /etc/openvpn/openvpn.conf if unspecified.
OPENVPN_CFG_FILE=/etc/openvpn/openvpn-test1.conf

# These are some other options you may want to pass to the openvpn executable.
# They are not checked.
OPENVPN_OPTS=""

# This tells wether we need to reconfigure the network interface after 
# switching on/off the bridge.
# I think this is only needed when you bridge the network that has internet
# access. It's a pity that the bridge scripts only work with a physical 
# network interface...
# Possible values: TRUE, * (anything else).
NEED_RECONF=TRUE

# This is the gateway ip. If you specify NEED_RECONF=TRUE, the gateway will
# be defaulted to what you type here.
GATEWAY_IP="192.168.5.254"


# This function performs checks on the information you provided in this script.

initial_checks()
{
	# Checking bridge-scripts presence.

	if ! [ -x "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" ]
	then
		echo "Couldn\'t find $BRIDGE_START_CMD in $BRIDGE_SCRIPTS_PATH."
		exit 1
	#else
	#	echo "Bridge scripts found!"
	fi

	# Checking openvpn executable & configuration file existance.

	if [ "$OPENVPN_PATH" -a ! -x "$OPENVPN_PATH" ]
	then
		echo "Couldn\'t find openvpn executable in $OPENVPN_PATH."
		exit 2
	else
		OPENVPN_PATH=`which openvpn`
		if [ ` echo "$OPENVPN_PATH" | grep 'which'` ]
		then
			echo "Couldn\'t find openvpn in you PATH enviroment variable."
			exit 3
		fi
	fi

	if [ "$OPENVPN_CFG_FILE" ]
	then
		if ! [ -e "$OPENVPN_CFG_FILE" ]
		then
			echo "Couldn\'t find openvpn configuration file in $OPENVPN_CFG_FILE".
			exit 3
		fi
	else
		if [ -e "/etc/openvpn/openvpn.conf" ]
		then
			OPENVPN_CFG_FILE="/etc/openvpn/openvpn.conf"
		else
			echo "Couldn\'t find /etc/openvpn/openvpn.conf. Please select a proper configuration file."
			exit 4
		fi
	fi

	# Checking if openvpn is already configured to be run as a daemon.
	# This test checks both the config file and the OPENVPN_OPTS variable.

	ISDAEMON=`echo "$OPENVPN_OPTS" | grep '\-\-daemon'`
	ISDAEMON+=`grep ^daemon$ "$OPENVPN_CFG_FILE"`

	if [ -z "$ISDAEMON" ]
	then
		if [ "$OPENVPN_OPTS" ]
		then
			OPENVPN_OPTS+=" --daemon"
		else
			OPENVPN_OPTS='--daemon'
		fi
	fi

}

# This function reads information about the actual bridged network interface
# from the bridge-start script, in order to reconfigure it if needed.

getifacedata ()
{
	IFACE=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth=' | cut -d= -f2 | sed -e 's/"//g'`
	IFACE_IP=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth_ip=' | cut -d= -f2 | sed -e 's/"//g'`
	IFACE_NETMASK=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth_netmask=' | cut -d= -f2 | sed -e 's/"//g'`

}

# This function retrieves the openvpn daemon PID

getpid ()
{
	OPENVPN_PID=`ps aux | awk '{ print $2,$11 }' | grep "$OPENVPN_PATH"$ | awk '{ print $1 }'`
}


#This function reconfigures the default gateway only

reconfgateway ()
{
	route add default gw "$GATEWAY_IP"	
}

# This function restores network configuration

reconfnet ()
{
	getifacedata
	ifconfig "$IFACE" "$IFACE_IP" netmask "$IFACE_NETMASK"
}

# This function starts the daemon

start ()
{
	"$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" 1>/dev/null

	if [ $? -ne 0 ]
	then
		echo "Problem starting bridge. Please review bridge settings in "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD". Exiting"
		"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD"
		reconfnet
		reconfgateway
		exit 5
	fi

	sleep 1

	if [ "$OPENVPN_OPTS" ]
	then
		"$OPENVPN_PATH" $OPENVPN_OPTS --config "$OPENVPN_CFG_FILE"
	else

		"$OPENVPN_PATH" "$OPENVPN_CFG_FILE"
	fi

	if [ $? -ne 0 ]
	then
		echo "Something screwed up..."
		"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD"
		reconfnet
		reconfgateway
		exit 9
	fi

	if [ "$NEED_RECONF" == "TRUE" ]
	then
		reconfgateway
	fi
}

# This function stops the daemon
# Arguments:
# $1 : OpenVPN process PID

stop ()
{
	kill -9 "$1"
	"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD" 1>/dev/null
	if [ $? -ne 0 ]
	then
		echo "Problem stopping bridge. Please review settings in $BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD. Exiting"
		exit 6
	fi

	if [ "$NEED_RECONF" == "TRUE" ]
	then
		reconfnet
		reconfgateway
	fi

}

initial_checks

case "$1" in
start)
	getpid
	if [ "$OPENVPN_PID" ]
	then
		echo "OpenVPN is already running (PID=$OPENVPN_PID)."
		exit 7
	else
		if [ -z "`lsmod | grep tun`" ]
		then
			modprobe tun
		fi
		echo -n "Starting OpenVPN..."
		sleep 1
		start
		echo "Done."
		if ! [ "$ISDAEMON" ]
		then
			echo "Please add the \"daemon\" option to your config file ($OPENVPN_CFG_FILE) or to OPENVPN_OPTS."
		fi
	fi
;;
stop)
	getpid
	if [ "$OPENVPN_PID" ]
	then
		echo -n "Stopping OpenVPN..."
		stop "$OPENVPN_PID"
		if [ `lsmod | grep tun | awk '{ print $3 }'` == "0" ]
		then
			modprobe -r tun
		fi
		modprobe -r bridge
		echo "Done."
	else
		echo "OpenVPN is not running."
		exit 8
	fi
;;
*)
	echo "Usage: `basename $0` start/stop."
	exit 1
;;
esac

Re: Script rc.openvpn-br

Inviato: ven 4 apr 2008, 19:01
da Zeros
Ciao, ho provato lo script e sembra funziona correttamente.
Unica cosa, ho dovuto mettere in background il comando openvpn perchè lo script attendeva la chiusura di quest'ultimo.
Ciao e thanks!

Re: Script rc.openvpn-br

Inviato: ven 4 apr 2008, 20:38
da 414N
Zeros ha scritto:Ciao, ho provato lo script e sembra funziona correttamente.
Unica cosa, ho dovuto mettere in background il comando openvpn perchè lo script attendeva la chiusura di quest'ultimo.
Ciao e thanks!
Rimane in foreground perchè probabilmente nel file di configurazione non hai specificato l'opzione "daemon".
Prova ad aggiungerla e dimmi. :thumbright:

Re: Script rc.openvpn-br

Inviato: sab 5 apr 2008, 0:00
da Zeros
:thumbright: E' andata!
Non sarebbe il caso di fare un controllo se questa voce è presente nel conf?
Perchè nel caso non ci fosse, quando lo script viene richiamato per esempio da rc.M, rimarrebbe in attesa, giusto?

Re: Script rc.openvpn-br

Inviato: sab 5 apr 2008, 9:06
da 414N
Zeros ha scritto::thumbright: E' andata!
Non sarebbe il caso di fare un controllo se questa voce è presente nel conf?
Perchè nel caso non ci fosse, quando lo script viene richiamato per esempio da rc.M, rimarrebbe in attesa, giusto?
Non hai tutti i torti... Vedo cosa posso fare.

Re: Script rc.openvpn-br

Inviato: sab 5 apr 2008, 12:51
da 414N
Ok, piccolo update.
Ora viene effettuato un controllo incrociato riguardo l'opzione "daemon". Se l'opzione non è contenuta nel file di configurazione o nella variabile OPENVPN_OPTS viene accodata a quest'ultima. Una volta avviato openvpn in questo modo verrà stampato un messaggio a video che ricorda all'utente di specificarla nel file di configurazione o nella variabile OPENVPN_OPTS.
Il listato si trova nel primo post di questo thread.

Re: Script rc.openvpn-br

Inviato: dom 6 apr 2008, 10:26
da 414N
Ho aggiunto un altro controllino sulla presenza di un indirizzo del gateway se NEED_RECONF è TRUE.

Codice: Seleziona tutto

#!/bin/bash

# Script able to start/stop a configured OpenVPN daemon in bridged mode.
# Brought to you by 414n.
# Version 1.02

# Global vars:

# This is the path to the start/stop bridge scripts that come with OpenVPN.
# The default path is /usr/doc/openvpnx.y/sample-scripts
# You must edit these scripts before launching OpenVPN.
BRIDGE_SCRIPTS_PATH="/etc/openvpn"

# These are the names of the two scripts to start/stop the bridge.
# You have to edit them accordingly to your settings.
BRIDGE_START_CMD="bridge-start"
BRIDGE_STOP_CMD="bridge-stop"

# This is the OpenVPN executable (complete) path.
# If openvpn is in your path you can leave this field empty.
OPENVPN_PATH=""

# Here you can specify the config file to be used.
# Default is /etc/openvpn/openvpn.conf if unspecified.
OPENVPN_CFG_FILE=/etc/openvpn/openvpn-test1.conf

# These are some other options you may want to pass to the openvpn executable.
# They are not checked.
OPENVPN_OPTS=""

# This tells wether we need to reconfigure the network interface after 
# switching on/off the bridge.
# I think this is only needed when you bridge the network that has internet
# access. It's a pity that the bridge scripts only work with a physical 
# network interface...
# Possible values: TRUE, * (anything else).
NEED_RECONF=TRUE

# This is the gateway ip. If you specify NEED_RECONF=TRUE, the gateway will
# be defaulted to what you type here.
GATEWAY_IP="192.168.5.254"


# This function performs checks on the information you provided in this script.

initial_checks()
{
	# Checking bridge-scripts presence.

	if ! [ -x "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" ]
	then
		echo "Couldn\'t find $BRIDGE_START_CMD in $BRIDGE_SCRIPTS_PATH."
		exit 1
	#else
	#	echo "Bridge scripts found!"
	fi

	# Checking openvpn executable & configuration file existance.

	if [ "$OPENVPN_PATH" -a ! -x "$OPENVPN_PATH" ]
	then
		echo "Couldn\'t find openvpn executable in $OPENVPN_PATH."
		exit 2
	else
		OPENVPN_PATH=`which openvpn`
		if [ ` echo "$OPENVPN_PATH" | grep 'which'` ]
		then
			echo "Couldn\'t find openvpn in you PATH enviroment variable."
			exit 3
		fi
	fi

	if [ "$OPENVPN_CFG_FILE" ]
	then
		if ! [ -e "$OPENVPN_CFG_FILE" ]
		then
			echo "Couldn\'t find openvpn configuration file in $OPENVPN_CFG_FILE".
			exit 3
		fi
	else
		if [ -e "/etc/openvpn/openvpn.conf" ]
		then
			OPENVPN_CFG_FILE="/etc/openvpn/openvpn.conf"
		else
			echo "Couldn\'t find /etc/openvpn/openvpn.conf. Please select a proper configuration file."
			exit 4
		fi
	fi

	# Checking if openvpn is already configured to be run as a daemon.
	# This test checks both the config file and the OPENVPN_OPTS variable.

	ISDAEMON=`echo "$OPENVPN_OPTS" | grep '\-\-daemon'`
	ISDAEMON+=`grep ^daemon$ "$OPENVPN_CFG_FILE"`

	if [ -z "$ISDAEMON" ]
	then
		if [ "$OPENVPN_OPTS" ]
		then
			OPENVPN_OPTS+=" --daemon"
		else
			OPENVPN_OPTS='--daemon'
		fi
	fi

	# Checking if user supplied a gateway IP (if NEED_RECONF=TRUE)

	if [ "$NEED_RECONF" == TRUE -a -z "$GATEWAY_IP" ]
	then
		echo "You didn't supply a gateway ip to be reset. Exiting."
		exit 9
	fi

}

# This function reads information about the actual bridged network interface
# from the bridge-start script, in order to reconfigure it if needed.

getifacedata ()
{
	IFACE=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth=' | cut -d= -f2 | sed -e 's/"//g'`
	IFACE_IP=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth_ip=' | cut -d= -f2 | sed -e 's/"//g'`
	IFACE_NETMASK=`cat "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" | grep 'eth_netmask=' | cut -d= -f2 | sed -e 's/"//g'`

}

# This function retrieves the openvpn daemon PID

getpid ()
{
	OPENVPN_PID=`ps aux | awk '{ print $2,$11 }' | grep "$OPENVPN_PATH"$ | awk '{ print $1 }'`
}


#This function reconfigures the default gateway only

reconfgateway ()
{
	route add default gw "$GATEWAY_IP"	
}

# This function restores network configuration

reconfnet ()
{
	getifacedata
	ifconfig "$IFACE" "$IFACE_IP" netmask "$IFACE_NETMASK"
}

# This function starts the daemon

start ()
{
	"$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD" 1>/dev/null

	if [ $? -ne 0 ]
	then
		echo "Problem starting bridge. Please review bridge settings in "$BRIDGE_SCRIPTS_PATH/$BRIDGE_START_CMD". Exiting"
		"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD"
		reconfnet
		reconfgateway
		exit 5
	fi


	if [ "$OPENVPN_OPTS" ]
	then
		"$OPENVPN_PATH" $OPENVPN_OPTS --config "$OPENVPN_CFG_FILE"
	else

		"$OPENVPN_PATH" "$OPENVPN_CFG_FILE"
	fi

	if [ $? -ne 0 ]
	then
		echo "Something screwed up..."
		"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD"
		reconfnet
		reconfgateway
		exit 9
	fi

	if [ "$NEED_RECONF" == "TRUE" ]
	then
		reconfgateway
	fi
}

# This function stops the daemon
# Arguments:
# $1 : OpenVPN process PID

stop ()
{
	kill -9 "$1"
	"$BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD" 1>/dev/null
	if [ $? -ne 0 ]
	then
		echo "Problem stopping bridge. Please review settings in $BRIDGE_SCRIPTS_PATH/$BRIDGE_STOP_CMD. Exiting"
		exit 6
	fi

	if [ "$NEED_RECONF" == "TRUE" ]
	then
		reconfnet
		reconfgateway
	fi

}

initial_checks

case "$1" in
start)
	getpid
	if [ "$OPENVPN_PID" ]
	then
		echo "OpenVPN is already running (PID=$OPENVPN_PID)."
		exit 7
	else
		if [ -z "`lsmod | grep tun`" ]
		then
			modprobe tun
		fi
		echo -n "Starting OpenVPN..."
		start
		echo "Done."
		if ! [ "$ISDAEMON" ]
		then
			echo "Please add the \"daemon\" option to your config file ($OPENVPN_CFG_FILE) or to OPENVPN_OPTS."
		fi
	fi
;;
stop)
	getpid
	if [ "$OPENVPN_PID" ]
	then
		echo -n "Stopping OpenVPN..."
		stop "$OPENVPN_PID"
		if [ `lsmod | grep tun | awk '{ print $3 }'` == "0" ]
		then
			modprobe -r tun
		fi
		modprobe -r bridge
		echo "Done."
	else
		echo "OpenVPN is not running."
		exit 8
	fi
;;
*)
	echo "Usage: `basename $0` start/stop."
	exit 1
;;
esac

Re: Script rc.openvpn-br

Inviato: dom 6 apr 2008, 10:54
da conraid
Perché non lo metti nel wiki?

Re: Script rc.openvpn-br

Inviato: dom 6 apr 2008, 10:56
da 414N
conraid ha scritto:Perché non lo metti nel wiki?
Non hai tutti i torti...
Devo iscrivermi al gruppo Wiki per farlo, giusto?

Re: Script rc.openvpn-br

Inviato: dom 6 apr 2008, 11:09
da conraid
414N ha scritto:
conraid ha scritto:Perché non lo metti nel wiki?
Non hai tutti i torti...
Devo iscrivermi al gruppo Wiki per farlo, giusto?
Devi chiedere a Loris

Re: Script rc.openvpn-br

Inviato: dom 6 apr 2008, 11:25
da 414N
conraid ha scritto: Devi chiedere a Loris
Ok, chiederò. Grazie!

Re: Script rc.openvpn-br

Inviato: mar 8 apr 2008, 15:51
da 414N
Ok, ho inserito questo script sulla wiki (tra l'altro aggiornandolo).
Grazie del suggerimento, conraid :thumbright: