mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-22 19:44:21 +01:00
4dfa7f761f
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
62 lines
1 KiB
Bash
62 lines
1 KiB
Bash
#!/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
|