From 16262790cb6ddacf6c632625cc865e03b1b8671f Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sun, 25 Nov 2012 21:24:58 +0100 Subject: rcdscripts: import first snapshot of rc.d scripts as of 11.25.2012 In 30 days these scripts will start dissapearing from official Arch Linux packages. This is an attempt to conserve them, and keep sysvinit usable. --- src/openvpn/openvpn-tapdev.rc | 40 ++++++++++++++++++++++++++++++++++++++++ src/openvpn/openvpn.rc | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100755 src/openvpn/openvpn-tapdev.rc create mode 100755 src/openvpn/openvpn.rc (limited to 'src/openvpn') diff --git a/src/openvpn/openvpn-tapdev.rc b/src/openvpn/openvpn-tapdev.rc new file mode 100755 index 0000000..2c51f82 --- /dev/null +++ b/src/openvpn/openvpn-tapdev.rc @@ -0,0 +1,40 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +. /etc/conf.d/openvpn-tapdev + +case "$1" in + start) + stat_busy "Creating tap devices for OpenVPN ... " + success=0 + for tapdev in ${TAPDEVS}; do + stat_append "${tapdev} " + /usr/sbin/openvpn --mktun --dev-type tap --dev ${tapdev} >/dev/null 2>&1 || success=$? + done + if [ $success -eq 0 ]; then + add_daemon openvpn-tapdev + stat_done + else + stat_fail + fi + ;; + stop) + stat_busy "Destroying tap devices for OpenVPN ..." + for tapdev in ${TAPDEVS}; do + stat_append "${tapdev} " + /usr/sbin/openvpn --rmtun --dev-type tap --dev ${tapdev} >/dev/null 2>&1 || success=$? + done + rm_daemon openvpn-tapdev + stat_done + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 diff --git a/src/openvpn/openvpn.rc b/src/openvpn/openvpn.rc new file mode 100755 index 0000000..96c28b6 --- /dev/null +++ b/src/openvpn/openvpn.rc @@ -0,0 +1,43 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +CFGDIR="/etc/openvpn" +STATEDIR="/var/run/openvpn" + +case "$1" in + start) + stat_busy "Starting OpenVPN ... " + success=0 + mkdir -p "${STATEDIR}" + for cfg in "${CFGDIR}"/*.conf; do + stat_append "$(basename "${cfg}" .conf) " + /usr/sbin/openvpn --daemon --writepid "${STATEDIR}"/"$(basename "${cfg}" .conf)".pid --cd "${CFGDIR}" --config "${cfg}" || success=$? + done + if [ $success -eq 0 ]; then + add_daemon openvpn + stat_done + else + stat_fail + fi + ;; + stop) + stat_busy "Stopping OpenVPN ..." + for pidfile in "${STATEDIR}"/*.pid; do + stat_append "$(basename "${pidfile}" .pid) " + kill $(cat "${pidfile}" 2>/dev/null) 2>/dev/null + rm -f "${pidfile}" + done + rm_daemon openvpn + stat_done + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 -- cgit v1.2.3