Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- author "Mariusz Kaczmarczyk <[email protected]>"
- description "OpenVPN connections initiator - starts configured connections"
- version "1.2"
- start on runlevel [2345]
- respawn
- normal exit 0
- console output
- # defaults
- env AUTOSTART=''
- env CONFIG_DIR='/etc/openvpn'
- env CONFIG_EXT='.conf'
- env CONN_NAMES=''
- env DEFAULTS_FILE='/etc/default/openvpn'
- pre-start script
- # load global defaults file
- if [ -f "${DEFAULTS_FILE}" ]; then
- . "${DEFAULTS_FILE}"
- fi
- # list available connections to be run
- if [ "${AUTOSTART}" = '*' ]; then
- # list all connection files from the directory
- cd "${CONFIG_DIR}/"
- for T_FILE in $(ls -1 *"${CONFIG_EXT}"); do
- CONN_NAMES=${CONN_NAMES}\ "${T_FILE%${CONFIG_EXT}}"
- done
- else
- # assign list of named connections
- CONN_NAMES=${AUTOSTART}
- fi
- # emit starting event for listed connections
- for T_CONN_NAME in $CONN_NAMES; do
- initctl emit openvpn-init-connections CONN="${T_CONN_NAME}"
- done
- end script
- script
- # wait indefinitely to make Upstart happy and make job wait for stop command
- while true; do
- exec /bin/sleep 2147483647d
- done
- end script
- pre-stop script
- # this has to be in pre-stop phase, as should only be run on manual job stop and not on kill
- initctl emit openvpn-stop-connections
- end script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement