diff options
Diffstat (limited to 'net-misc/openvpn/files/openvpn-2.1.init')
-rwxr-xr-x | net-misc/openvpn/files/openvpn-2.1.init | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/net-misc/openvpn/files/openvpn-2.1.init b/net-misc/openvpn/files/openvpn-2.1.init index 060bc4d4a12b..972e80fdd82e 100755 --- a/net-misc/openvpn/files/openvpn-2.1.init +++ b/net-misc/openvpn/files/openvpn-2.1.init @@ -1,10 +1,10 @@ #!/sbin/runscript -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -VPNDIR="${VPNDIR:-/etc/openvpn}" -VPN="${SVCNAME#*.}" -if [[ -n ${VPN} && ${SVCNAME} != "openvpn" ]]; then +VPNDIR=${VPNDIR:-/etc/openvpn} +VPN=${SVCNAME#*.} +if [ -n "${VPN}" ] && [ ${SVCNAME} != "openvpn" ]; then VPNPID="/var/run/openvpn.${VPN}.pid" else VPNPID="/var/run/openvpn.pid" @@ -18,15 +18,15 @@ depend() { checkconfig() { # Linux has good dynamic tun/tap creation - if [[ $(uname) == "Linux" ]] ; then - if [[ ! -e /dev/net/tun ]]; then + if [ $(uname -s) = "Linux" ] ; then + if [ ! -e /dev/net/tun ]; then if ! modprobe tun ; then eerror "TUN/TAP support is not available" \ "in this kernel" return 1 fi fi - if [[ -h /dev/net/tun && -c /dev/misc/net/tun ]]; then + if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then ebegin "Detected broken /dev/net/tun symlink, fixing..." rm -f /dev/net/tun ln -s /dev/misc/net/tun /dev/net/tun @@ -38,18 +38,18 @@ checkconfig() { # Other OS's don't, so we rely on a pre-configured interface # per vpn instance local ifname=$(sed -n -e 's/[[:space:]]*dev[[:space:]][[:space:]]*\([^[:space:]]*\).*/\1/p' "${VPNCONF}") - if [[ -z ${ifname} ]] ; then + if [ -z ${ifname} ] ; then eerror "You need to specify the interface that this openvpn" \ "instance should use" \ "by using the dev option in ${VPNCONF}" return 1 fi - if ! ifconfig "${ifname}" &>/dev/null ; then + if ! ifconfig "${ifname}" >/dev/null ; then # Try and create it - echo > /dev/"${ifname}" &>/dev/null + echo > /dev/"${ifname}" >/dev/null fi - if ! ifconfig "${ifname}" &>/dev/null ; then + if ! ifconfig "${ifname}" >/dev/null ; then eerror "${VPNCONF} requires interface ${ifname}" \ "but that does not exist" return 1 @@ -59,7 +59,7 @@ checkconfig() { start() { # If we are re-called by the openvpn gentoo-up.sh script # then we don't actually want to start openvpn - [[ ${IN_BACKGROUND} == "true" ]] && return 0 + [ "${IN_BACKGROUND}" = "true" ] && return 0 ebegin "Starting ${SVCNAME}" @@ -103,9 +103,7 @@ start() { grep -q "^[ \t]*group[ \t].*" "${VPNCONF}" || args="${args} --group openvpn" fi - if ${client} && [[ $(type -t mark_service_inactive) == "function" ]] ; then - mark_service_inactive "${SVCNAME}" - fi + ${client} && mark_service_inactive "${SVCNAME}" start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${VPNPID}" \ -- --config "${VPNCONF}" --writepid "${VPNPID}" --daemon ${args} eend $? "Check your logs to see why startup failed" @@ -114,9 +112,8 @@ start() { stop() { # If we are re-called by the openvpn gentoo-down.sh script # then we don't actually want to stop openvpn - if [[ ${IN_BACKGROUND} == "true" ]] ; then - [[ $(type -t mark_service_inactive) == "function" ]] \ - && mark_service_inactive "${SVCNAME}" + if [ "${IN_BACKGROUND}" = "true" ] ; then + mark_service_inactive "${SVCNAME}" return 0 fi |