hide all error messages from cleanup function

This commit is contained in:
oblique 2015-02-22 21:37:26 +02:00
parent 3460580ce2
commit ac33c5b169

View File

@ -434,30 +434,27 @@ OLD_MACADDR=
IP_ADDRS= IP_ADDRS=
ROUTE_ADDRS= ROUTE_ADDRS=
cleanup() { _cleanup() {
trap "" SIGINT trap "" SIGINT
trap "" SIGUSR1 trap "" SIGUSR1
echo
echo -n "Doing cleanup.. "
# exiting # exiting
for x in $CONFDIR/*.pid; do for x in $CONFDIR/*.pid; do
# even if the $CONFDIR is empty, the for loop will assign # even if the $CONFDIR is empty, the for loop will assign
# a value in $x. so we need to check if the value is a file # a value in $x. so we need to check if the value is a file
if [[ -f $x ]]; then if [[ -f $x ]]; then
PID=$(cat $x) PID=$(cat $x)
disown $PID > /dev/null 2>&1 disown $PID
kill -9 $PID > /dev/null 2>&1 kill -9 $PID
fi fi
done done
rm -rf $CONFDIR rm -rf $CONFDIR
if [[ "$SHARE_METHOD" != "none" ]]; then if [[ "$SHARE_METHOD" != "none" ]]; then
if [[ "$SHARE_METHOD" == "nat" ]]; then if [[ "$SHARE_METHOD" == "nat" ]]; then
iptables -t nat -D POSTROUTING -o ${INTERNET_IFACE} -j MASQUERADE > /dev/null 2>&1 iptables -t nat -D POSTROUTING -o ${INTERNET_IFACE} -j MASQUERADE
iptables -D FORWARD -i ${WIFI_IFACE} -s ${GATEWAY%.*}.0/24 -j ACCEPT > /dev/null 2>&1 iptables -D FORWARD -i ${WIFI_IFACE} -s ${GATEWAY%.*}.0/24 -j ACCEPT
iptables -D FORWARD -i ${INTERNET_IFACE} -d ${GATEWAY%.*}.0/24 -j ACCEPT > /dev/null 2>&1 iptables -D FORWARD -i ${INTERNET_IFACE} -d ${GATEWAY%.*}.0/24 -j ACCEPT
[[ -n $OLD_IP_FORWARD ]] && echo $OLD_IP_FORWARD > /proc/sys/net/ipv4/ip_forward [[ -n $OLD_IP_FORWARD ]] && echo $OLD_IP_FORWARD > /proc/sys/net/ipv4/ip_forward
elif [[ "$SHARE_METHOD" == "bridge" ]]; then elif [[ "$SHARE_METHOD" == "bridge" ]]; then
if [[ -n $OLD_BRIDGE_IPTABLES ]]; then if [[ -n $OLD_BRIDGE_IPTABLES ]]; then
@ -497,9 +494,9 @@ cleanup() {
fi fi
if [[ "$SHARE_METHOD" != "bridge" ]]; then if [[ "$SHARE_METHOD" != "bridge" ]]; then
iptables -D INPUT -p tcp -m tcp --dport 53 -j ACCEPT > /dev/null 2>&1 iptables -D INPUT -p tcp -m tcp --dport 53 -j ACCEPT
iptables -D INPUT -p udp -m udp --dport 53 -j ACCEPT > /dev/null 2>&1 iptables -D INPUT -p udp -m udp --dport 53 -j ACCEPT
iptables -D INPUT -p udp -m udp --dport 67 -j ACCEPT > /dev/null 2>&1 iptables -D INPUT -p udp -m udp --dport 67 -j ACCEPT
fi fi
if [[ $NO_VIRT -eq 0 ]]; then if [[ $NO_VIRT -eq 0 ]]; then
@ -517,7 +514,12 @@ cleanup() {
fi fi
networkmanager_rm_unmanaged_if_needed ${WIFI_IFACE} ${OLD_MACADDR} networkmanager_rm_unmanaged_if_needed ${WIFI_IFACE} ${OLD_MACADDR}
fi fi
}
cleanup() {
echo
echo -n "Doing cleanup.. "
_cleanup > /dev/null 2>&1
echo "done" echo "done"
} }