Created
March 20, 2014 17:18
-
-
Save drscream/9669060 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
WORKDIR='/opt/local/etc/openvpn' | |
OPENVPN='/opt/local/sbin/openvpn' | |
function openvpn_start() { | |
for config in ${WORKDIR}/*.conf; do | |
name=$(basename ${config//.conf}) | |
echo "Starting OpenVPN: ${name}" | |
${OPENVPN} --config ${config} --daemon ${name} | |
done | |
} | |
case "$1" in | |
'start') | |
openvpn_start | |
;; | |
'stop') | |
echo "not implemented" | |
;; | |
'refresh') | |
echo "not implemented" | |
;; | |
*) | |
echo $"Usage: $0 {start|refresh}" | |
exit 1 | |
;; | |
esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0'?> | |
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> | |
<service_bundle type='manifest' name='export'> | |
<service name='network/openvpn' type='service' version='0'> | |
<create_default_instance enabled='true'/> | |
<single_instance/> | |
<dependency name='fs' grouping='require_all' restart_on='none' type='service'> | |
<service_fmri value='svc:/system/filesystem/local'/> | |
</dependency> | |
<dependency name='net' grouping='require_all' restart_on='none' type='service'> | |
<service_fmri value='svc:/network/loopback'/> | |
</dependency> | |
<exec_method name='start' type='method' exec='/opt/local/etc/openvpn/svc/openvpn start' timeout_seconds='60'> | |
<method_context working_directory='/opt/local/etc/openvpn'> | |
<method_credential user='root' group='root'/> | |
<method_environment> | |
<envvar name='PATH' value='/opt/local/sbin:/opt/local/bin:/usr/sbin:/usr/bin:/bin'/> | |
</method_environment> | |
</method_context> | |
</exec_method> | |
<exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'/> | |
<stability value='External'/> | |
<template> | |
<common_name> | |
<loctext xml:lang='C'>openvpn</loctext> | |
</common_name> | |
<documentation> | |
<manpage title='openvpn' section='8' manpath='/usr/share/man'/> | |
<doc_link name='openvpn.net' uri='http://openvpn.net/index.php/manuals'/> | |
</documentation> | |
</template> | |
</service> | |
</service_bundle> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment