FwVM network changes watcher script
This commit is contained in:
parent
dc8325f564
commit
bba0e6e1ef
27
fwvm/bin/qubes_netwatcher
Executable file
27
fwvm/bin/qubes_netwatcher
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
PIDFILE=/var/run/qubes/qubes_netwatcher.pid
|
||||
CURR_NETCFG=""
|
||||
|
||||
# PIDfile handling
|
||||
[[ -e $PIDFILE ]] && kill -s 0 $(<$PIDFILE) 2>/dev/null && exit 0
|
||||
echo $$ >$PIDFILE
|
||||
|
||||
trap 'exit 0' SIGTERM
|
||||
|
||||
while true; do
|
||||
NET_DOMID=$(/usr/bin/xenstore-read qubes_netvm_domid)
|
||||
if [[ -n "$NET_DOMID" ]] && [[ $NET_DOMID -gt 0 ]]; then
|
||||
NETCFG=$(/usr/bin/xenstore-read /local/domain/$NET_DOMID/qubes_netvm_external_ip)
|
||||
if [[ "$NETCFG" != "$CURR_NETCFG" ]]; then
|
||||
/sbin/service qubes_firewall stop
|
||||
/sbin/service qubes_firewall start
|
||||
CURR_NETCFG="$NETCFG"
|
||||
fi
|
||||
|
||||
/usr/bin/xenstore-watch /local/domain/$NET_DOMID/qubes_netvm_external_ip
|
||||
else
|
||||
/usr/bin/xenstore-watch qubes_netvm_domid
|
||||
fi
|
||||
done
|
42
fwvm/init.d/qubes_netwatcher
Executable file
42
fwvm/init.d/qubes_netwatcher
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# chkconfig: 345 92 92
|
||||
# description: Starts Qubes Network monitor
|
||||
#
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
PIDFILE=/var/run/qubes/qubes_netwatcher.pid
|
||||
|
||||
start()
|
||||
{
|
||||
echo -n $"Starting Qubes Network monitor:"
|
||||
/sbin/ethtool -K eth0 sg off
|
||||
/usr/bin/qubes_netwatcher &
|
||||
success
|
||||
echo ""
|
||||
return 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
echo -n "Stopping Qubes Network monitor:"
|
||||
kill -9 $(cat $PIDFILE) 2>/dev/null && success || failure
|
||||
echo ""
|
||||
return 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop}"
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
Loading…
Reference in New Issue
Block a user