diff options
Diffstat (limited to 'network/dnsproxy-bin/rc.dnsproxy')
-rw-r--r-- | network/dnsproxy-bin/rc.dnsproxy | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/network/dnsproxy-bin/rc.dnsproxy b/network/dnsproxy-bin/rc.dnsproxy new file mode 100644 index 0000000000..f71496a467 --- /dev/null +++ b/network/dnsproxy-bin/rc.dnsproxy @@ -0,0 +1,62 @@ +#!/bin/bash +# Start/stop/restart the dnsproxy + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +name="dnsproxy" +pidfiles=/run/"$name" +mkdir -p $pidfiles +if /bin/id "$name" &>/dev/null; then + chown $name:$name $pidfiles + daemon="/usr/bin/daemon --name=$name --pidfiles=$pidfiles --user=$name" +else + daemon="/usr/bin/daemon --name=$name --pidfiles=$pidfiles" +fi + +start_dnsproxy() { +if $daemon --running; then + echo "$name is already running" +else + echo "Starting $name..." + $daemon -- /usr/sbin/dnsproxy --config-path=/etc/dnsproxy.yaml +fi +} + +stop_dnsproxy() { +if $daemon --running; then + echo "Stopping $name..." + $daemon --stop +else + echo "$name is not running" +fi +} + +restart_dnsproxy() { + stop_dnsproxy + sleep 1 + start_dnsproxy +} + +status_dnsproxy() { + $daemon --running --verbose +} + +case "$1" in +'start') + start_dnsproxy + ;; +'stop') + stop_dnsproxy + ;; +'restart') + restart_dnsproxy + ;; +'status') + status_dnsproxy + ;; +*) + echo "usage $0 start|stop|restart|status" +esac |