summaryrefslogtreecommitdiffstats
path: root/src/os-plugins/plugins/qemukvm/files/ifdown
blob: b56be1dfd7fa4e4933ad1e400b36e0f1d175d6f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
# Copyright (c) 2009..11 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# ifdown
#    - Script used for network cleanup of qemukvm in stage4
# -----------------------------------------------------------------------------

# get VM_ID through tap name
VM_ID=$(echo $1 | grep -oE "0[0-4]$")
#QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID}
# not optimal if multiple machines run
case "$1" in
  tapbridge0*)
    sudo /sbin/sysctl -q -w net.ipv4.conf.$1.forwarding=0 || failed=1
  ;;
  tapnat0*)
    sudo /sbin/sysctl -q -w net.ipv4.conf.$1.forwarding=0 || failed=1
    sudo /sbin/iptables -t nat -D POSTROUTING -s 192.168.1${VM_ID}.0/24 -o br0 \
      -j MASQUERADE || failed=1
  ;;
esac
sudo /opt/openslx/rootfs/usr/bin/killall -9 udhcpd || failed=1
sudo /opt/openslx/rootfs/bin/ip link set dev $1 down || failed=1

# Produce a clean exit status
exit 0