84 lines
1.9 KiB
Plaintext
Raw Normal View History

2016-02-15 16:34:45 +03:00
#!/bin/sh /etc/rc.common
USE_PROCD=1
# start betfore firewall - we need ipset populated
START=18
2019-05-06 16:02:22 +03:00
ZAPRET_BASE=/opt/zapret
# SHOULD EDIT config
. "$ZAPRET_BASE/config"
2019-05-03 12:44:43 +03:00
2019-05-06 16:02:22 +03:00
# !!!!! in openwrt firewall rules are configured separately
2019-05-03 12:44:43 +03:00
PIDDIR=/var/run
IPSET_CR=$ZAPRET_BASE/ipset/create_ipset.sh
2016-02-15 16:34:45 +03:00
QNUM=200
NFQWS=$ZAPRET_BASE/nfq/nfqws
2019-05-03 12:44:43 +03:00
NFQWS_OPT_BASE="--qnum=$QNUM"
2019-05-05 23:35:10 +03:00
TPPORT_HTTP=1188
TPPORT_HTTPS=1189
TPWS=$ZAPRET_BASE/tpws/tpws
2016-02-15 16:34:45 +03:00
TPWS_USER=daemon
2019-05-09 19:03:50 +03:00
TPWS_HOSTLIST=$ZAPRET_BASE/ipset/zapret-hosts.txt.gz
[ -f "$TPWS_HOSTLIST" ] || TPWS_HOSTLIST=$ZAPRET_BASE/ipset/zapret-hosts-user.txt
2019-05-05 23:35:10 +03:00
TPWS_OPT_BASE="--user=$TPWS_USER --bind-addr=127.0.0.1"
TPWS_OPT_BASE_HTTP="--port=$TPPORT_HTTP $TPWS_OPT_BASE"
TPWS_OPT_BASE_HTTPS="--port=$TPPORT_HTTPS $TPWS_OPT_BASE"
2016-02-15 16:34:45 +03:00
2016-02-26 11:09:31 +03:00
2019-05-03 12:44:43 +03:00
run_daemon()
{
# $1 - daemon string id or number. can use 1,2,3,...
# $2 - daemon
# $3 - daemon args
# use $PIDDIR/$DAEMONBASE$1.pid as pidfile
local DAEMONBASE=$(basename $2)
echo "Starting daemon $1: $2 $3"
procd_open_instance
procd_set_param command $2 $3
procd_set_param pidfile $PIDDIR/$DAEMONBASE$1.pid
procd_close_instance
}
create_ipset()
{
echo "Creating ipset"
($IPSET_CR)
}
start_service() {
case "${MODE}" in
tpws_hostlist)
2019-05-05 23:35:10 +03:00
run_daemon 1 $TPWS "$TPWS_OPT_BASE_HTTP $TPWS_OPT_HTTP --hostlist=$TPWS_HOSTLIST"
2016-02-15 16:34:45 +03:00
;;
2019-05-05 23:35:10 +03:00
tpws_ipset|tpws_all)
2019-05-03 12:44:43 +03:00
create_ipset
2019-05-05 23:35:10 +03:00
run_daemon 1 $TPWS "$TPWS_OPT_BASE_HTTP $TPWS_OPT_HTTP"
2016-02-17 20:22:21 +03:00
;;
2019-05-05 23:35:10 +03:00
tpws_ipset_https|tpws_all_https)
create_ipset
run_daemon 1 $TPWS "$TPWS_OPT_BASE_HTTP $TPWS_OPT_HTTP"
run_daemon 2 $TPWS "$TPWS_OPT_BASE_HTTPS $TPWS_OPT_HTTPS"
2016-02-15 16:34:45 +03:00
;;
2019-05-05 23:35:10 +03:00
nfqws_ipset|nfqws_ipset_https)
2019-05-03 12:44:43 +03:00
create_ipset
run_daemon 1 $NFQWS "$NFQWS_OPT_BASE $NFQWS_OPT"
2016-02-15 16:34:45 +03:00
;;
2019-05-05 23:35:10 +03:00
nfqws_all|nfqws_all_https)
2019-05-03 12:44:43 +03:00
run_daemon 1 $NFQWS "$NFQWS_OPT_BASE $NFQWS_OPT"
2016-03-05 11:04:40 +03:00
;;
2019-05-03 12:44:43 +03:00
ipset)
create_ipset
2017-04-23 10:14:00 +03:00
;;
2016-12-09 16:33:29 +03:00
custom)
# PLACEHOLDER
echo !!! NEED ATTENTION !!!
2019-05-03 12:44:43 +03:00
echo Start daemon\(s\)
echo Study how other sections work
2016-12-09 16:33:29 +03:00
;;
2016-02-15 16:34:45 +03:00
esac
}