slackbuilds_ponce/network/dnsproxy-bin/rc.dnsproxy
Alexander Verbovetsky 4dfa7f761f network/dnsproxy-bin: Added (DNS Proxy).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
2024-02-02 11:05:42 +07:00

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