blob: 4686be51cc9663dcd5956801bd5f0b038839ed86 [file] [log] [blame]
Matteo Scandoloaca86652017-08-08 13:05:27 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
AyumuUeha76a01bc2017-05-18 13:34:13 +090017#!/bin/bash
18#************************************************************/
19#** File: vsg_pppoe_cleanup.sh */
20#** Contents: Contains shell script to clean up all */
21#** artifacts tied to applications */
22#************************************************************/
23
24source /tmp/vsg_env.txt
25
26date
27echo "vsg_pppoe_cleanup.sh: Begin"
28vsgIp=$1
29vcpeproxy_prefix=vcpe; export vcpeproxy_prefix
30vcpe_gwbr_name=vcpe_gwbr; export vcpe_gwbr
31vsg_home_dir=$2
32vcpe_monitor_script=vsg_vcpe_monitor.sh
33container_volumes=/var/container_volumes
34if [ $# -ne 2 ]
35 then
36 echo "Usage: vsg_pppoe_cleanup.sh <vsgIp> <vsg_home_dir>"
37 exit 0
38fi
39
40getArray() {
41 array=() # Create array
42 while IFS= read -r line # Read a line
43 do
44 array+=("$line") # Append line to the array
45 done < "$1"
46}
47
48#
49# Restarting a vcpeproxy will force the Docker instance to be cleaned up
50# automatically.
51# Note: Since vcpeproxy is created from XOS, if you want to delete that
52# Docker instance, you will have to go through XOS make cleanup operation.
53#
54function restart_all_vcpeproxy() {
55
56 echo "Restart all vcpeproxy..."
57
58 file_temp="/tmp/vcpeproxy_names.txt"
59
60 sudo docker ps|grep $vcpeproxy_prefix|awk '{print $NF}' > $file_temp
61
62 getArray $file_temp
63
64 for id in "${array[@]}"
65 do
66 echo "Restarting docker instance $id"
67 sudo docker exec $id sed -i "s/POST/DELETE/g" $NODEJS_MODULES_DIR$AP_REST_NETCFG
68 sudo docker exec $id bash $NODEJS_MODULES_DIR$AP_REST_NETCFG
69 sudo docker restart $id
70 done
71}
72
73echo "Killall nodejs programs running in the VSG"
74sudo killall nodejs
75restart_all_vcpeproxy
76if ifconfig -a |grep $vcpe_gwbr_name ; then
77 sudo ifconfig $vcpe_gwbr_name down
78 sudo brctl delbr $vcpe_gwbr_name
79fi
80if [ -d $vsg_home_dir ]; then
81 rm -rf $vsg_home_dir/*
82fi
83pid=`ps -fade|grep vsg_vcpe_monitor.sh|grep -v grep |awk '{print $2}'`
84if echo $pid|grep [0-9] ; then
85 echo "Killing vsg_vcpe_monitor.sh script"
86 sudo kill -9 $pid
87fi
88date
89echo "vsg_vcpegw_cleanup.sh: End"