2015-02-05 03:14:41 +01:00
|
|
|
#!/bin/bash
|
2012-05-31 02:24:49 +02:00
|
|
|
#
|
2014-09-27 00:11:10 +02:00
|
|
|
# tinyproxy Startup script for the tinyproxy server as Qubes updates proxy
|
2012-05-31 02:24:49 +02:00
|
|
|
#
|
2016-10-22 17:43:16 +02:00
|
|
|
# chkconfig: 345 85 15
|
2012-05-31 02:24:49 +02:00
|
|
|
# description: small, efficient HTTP/SSL proxy daemon
|
|
|
|
#
|
|
|
|
# processname: tinyproxy
|
2014-09-27 00:11:10 +02:00
|
|
|
# config: /etc/tinyproxy/tinyproxy-updates.conf
|
|
|
|
# config: /etc/sysconfig/tinyproxy-updates
|
|
|
|
# pidfile: /var/run/tinyproxy/tinyproxy-updates.pid
|
2012-05-31 02:24:49 +02:00
|
|
|
#
|
|
|
|
# Note: pidfile is created by tinyproxy in its config
|
|
|
|
# see PidFile in the configuration file.
|
|
|
|
|
|
|
|
# Source function library.
|
2017-09-30 04:56:02 +02:00
|
|
|
# shellcheck disable=SC1091
|
2012-05-31 02:24:49 +02:00
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
2016-10-22 17:43:16 +02:00
|
|
|
# Source Qubes library.
|
2017-09-30 04:56:02 +02:00
|
|
|
# shellcheck source=init/functions
|
2016-10-22 17:43:16 +02:00
|
|
|
. /usr/lib/qubes/init/functions
|
|
|
|
|
2012-05-31 02:24:49 +02:00
|
|
|
# Source networking configuration.
|
2017-09-30 04:56:02 +02:00
|
|
|
# shellcheck disable=SC1091
|
2012-05-31 02:24:49 +02:00
|
|
|
. /etc/sysconfig/network
|
|
|
|
|
|
|
|
# Check that networking is up.
|
|
|
|
[ "$NETWORKING" = "no" ] && exit 0
|
|
|
|
|
2019-04-16 11:39:44 +02:00
|
|
|
exec="$(command -v tinyproxy)"
|
2019-04-17 13:33:04 +02:00
|
|
|
prog=$(basename "$exec")
|
2014-09-27 00:11:10 +02:00
|
|
|
config="/etc/tinyproxy/tinyproxy-updates.conf"
|
2015-11-11 05:39:30 +01:00
|
|
|
pidfile="/var/run/tinyproxy-updates/tinyproxy.pid"
|
2012-05-31 02:24:49 +02:00
|
|
|
|
2017-09-30 04:56:02 +02:00
|
|
|
# shellcheck disable=SC1091
|
2014-09-27 00:11:10 +02:00
|
|
|
[ -e /etc/sysconfig/tinyproxy-updates ] && . /etc/sysconfig/tinyproxy-updates
|
2012-05-31 02:24:49 +02:00
|
|
|
|
2014-09-27 00:11:10 +02:00
|
|
|
lockfile=/var/lock/subsys/tinyproxy-updates
|
2012-05-31 02:24:49 +02:00
|
|
|
|
|
|
|
start() {
|
2016-10-22 17:43:16 +02:00
|
|
|
have_qubesdb || return
|
|
|
|
|
|
|
|
if qsvc qubes-updates-proxy ; then
|
2012-05-31 02:24:49 +02:00
|
|
|
# Yum proxy disabled
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-04-17 13:33:04 +02:00
|
|
|
[ -x "$exec" ] || exit 5
|
2012-05-31 02:24:49 +02:00
|
|
|
[ -f $config ] || exit 6
|
|
|
|
# setup network redirection
|
|
|
|
/sbin/iptables -I INPUT -i vif+ -p tcp --dport 8082 -j ACCEPT
|
|
|
|
/sbin/iptables -t nat -A PR-QBS-SERVICES -i vif+ -d 10.137.255.254 -p tcp --dport 8082 -j REDIRECT
|
|
|
|
|
2014-09-27 00:11:10 +02:00
|
|
|
echo -n $"Starting $prog (as Qubes updates proxy): "
|
2019-04-17 13:33:04 +02:00
|
|
|
daemon "$exec" -c $config
|
2012-05-31 02:24:49 +02:00
|
|
|
retval=$?
|
|
|
|
echo
|
|
|
|
[ $retval -eq 0 ] && touch $lockfile
|
|
|
|
return $retval
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo -n $"Stopping $prog: "
|
2017-09-30 04:49:21 +02:00
|
|
|
killproc -p $pidfile "$prog"
|
2012-05-31 02:24:49 +02:00
|
|
|
retval=$?
|
|
|
|
echo
|
|
|
|
/sbin/iptables -t nat -D PR-QBS-SERVICES -i vif+ -d 10.137.255.254 -p tcp --dport 8082 -j REDIRECT
|
|
|
|
/sbin/iptables -D INPUT -i vif+ -p tcp --dport 8082 -j ACCEPT
|
2017-09-30 04:49:21 +02:00
|
|
|
[ $retval -eq 0 ] && rm -f "$lockfile"
|
2012-05-31 02:24:49 +02:00
|
|
|
return $retval
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
echo -n $"Reloading $prog: "
|
2017-09-30 04:49:21 +02:00
|
|
|
killproc -p $pidfile "$prog" -HUP
|
2012-05-31 02:24:49 +02:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
force_reload() {
|
|
|
|
restart
|
|
|
|
}
|
|
|
|
|
|
|
|
rh_status() {
|
2017-09-30 04:49:21 +02:00
|
|
|
status "$prog"
|
2012-05-31 02:24:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
rh_status_q() {
|
|
|
|
rh_status >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
rh_status_q && exit 0
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
rh_status_q || exit 0
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
rh_status_q || exit 7
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
force-reload)
|
|
|
|
force_reload
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
rh_status
|
|
|
|
;;
|
|
|
|
condrestart|try-restart)
|
|
|
|
rh_status_q || exit 0
|
|
|
|
restart
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
|
|
|
exit 2
|
|
|
|
esac
|
|
|
|
exit $?
|
|
|
|
|