blob: a3101774438029a954a98f609182dd16284b3641 [file] [log] [blame]
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +01001#! /bin/bash
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15function remove_iptables() {
16 stack=$1
17 if [ -z "$OSM_VCA_HOST" ]; then
18 OSM_VCA_HOST=`sg lxd -c "juju show-controller controller"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
19 [ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
20 fi
21
22 if [ -z "$DEFAULT_IP" ]; then
23 DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'`
24 [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
25 DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
26 [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
27 fi
28
29 if sudo iptables -t nat -C PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST; then
30 sudo iptables -t nat -D PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST
31 sudo netfilter-persistent save
32 fi
33}
34
35remove_iptables
Dominik Fleischmannc57296f2020-06-09 11:45:08 +020036juju destroy-model osm --destroy-storage -y
37juju destroy-model test --destroy-storage -y
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010038sudo snap unalias osm
39sudo snap remove osmclient