Files
Keenetic-Split-DNS/init.d/S98smartdns
Андрей Бобырев bc9355fe40 Initial release: install, uninstall, SmartDNS, web UI
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-24 22:15:37 +03:00

42 lines
892 B
Bash
Executable File

#!/bin/sh
# SmartDNS for Keenetic-Split-DNS (wraps Entware smartdns)
KSD_ETC="/opt/etc/keenetic-split-dns"
CONF="${KSD_ETC}/smartdns.conf"
PIDFILE="/opt/var/run/keenetic-split-dns/smartdns.pid"
LOGDIR="/opt/var/log/keenetic-split-dns"
start() {
mkdir -p "$LOGDIR" "$(dirname "$PIDFILE")"
[ -f "$CONF" ] || return 1
if pidof smartdns >/dev/null 2>&1; then
return 0
fi
smartdns -c "$CONF" -p "$PIDFILE" >/dev/null 2>&1 &
sleep 1
pidof smartdns >/dev/null 2>&1
}
stop() {
if [ -f "$PIDFILE" ]; then
kill "$(cat "$PIDFILE" 2>/dev/null)" 2>/dev/null || true
rm -f "$PIDFILE"
fi
killall smartdns 2>/dev/null || true
}
case "$1" in
start) start ;;
stop) stop ;;
restart) stop; sleep 1; start ;;
status)
if pidof smartdns >/dev/null 2>&1; then
echo "smartdns running"
exit 0
fi
echo "smartdns stopped"
exit 1
;;
esac
exit 0