zapret/init.d/sysv/zapret

74 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-03-04 14:30:38 +03:00
#!/bin/sh
### BEGIN INIT INFO
# Provides: zapret
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
SCRIPT=$(readlink -f "$0")
EXEDIR=$(dirname "$SCRIPT")
ZAPRET_BASE=$(readlink -f "$EXEDIR/../..")
. "$EXEDIR/functions"
NAME=zapret
DESC=anti-zapret
2021-11-06 10:56:15 +03:00
do_start()
{
zapret_run_daemons
[ "$INIT_APPLY_FW" != "1" ] || zapret_apply_firewall
}
do_stop()
{
zapret_stop_daemons
[ "$INIT_APPLY_FW" != "1" ] || zapret_unapply_firewall
}
2021-03-04 14:30:38 +03:00
case "$1" in
start)
2021-11-06 10:56:15 +03:00
do_start
2021-03-04 14:30:38 +03:00
;;
stop)
2021-11-06 10:56:15 +03:00
do_stop
;;
restart)
do_stop
do_start
2021-03-04 14:30:38 +03:00
;;
start-fw)
zapret_apply_firewall
;;
stop-fw)
zapret_unapply_firewall
;;
2021-11-06 10:56:15 +03:00
restart-fw)
zapret_unapply_firewall
zapret_apply_firewall
;;
2021-03-04 14:30:38 +03:00
start-daemons)
zapret_run_daemons
;;
stop-daemons)
zapret_stop_daemons
;;
2021-11-06 10:56:15 +03:00
restart-daemons)
zapret_stop_daemons
zapret_run_daemons
;;
2021-03-04 14:30:38 +03:00
*)
N=/etc/init.d/$NAME
2021-11-06 10:56:15 +03:00
echo "Usage: $N {start|stop|restart|start-fw|stop-fw|restart-fw|start-daemons|stop-daemons|restart-daemons}" >&2
2021-03-04 14:30:38 +03:00
exit 1
;;
esac
exit 0