blob: 70aee3d2e6941ce2f84ce9e04446f15454a13ff7 [file] [log] [blame]
AyumuUeha76a01bc2017-05-18 13:34:13 +09001#!/bin/bash
2#************************************************************/
3#** File: vsg_pppoe_cleanup.sh */
4#** Contents: Contains shell script to clean up all */
5#** artifacts tied to applications */
6#************************************************************/
7
8source /tmp/vsg_env.txt
9
10date
11echo "vsg_pppoe_cleanup.sh: Begin"
12vsgIp=$1
13vcpeproxy_prefix=vcpe; export vcpeproxy_prefix
14vcpe_gwbr_name=vcpe_gwbr; export vcpe_gwbr
15vsg_home_dir=$2
16vcpe_monitor_script=vsg_vcpe_monitor.sh
17container_volumes=/var/container_volumes
18if [ $# -ne 2 ]
19 then
20 echo "Usage: vsg_pppoe_cleanup.sh <vsgIp> <vsg_home_dir>"
21 exit 0
22fi
23
24getArray() {
25 array=() # Create array
26 while IFS= read -r line # Read a line
27 do
28 array+=("$line") # Append line to the array
29 done < "$1"
30}
31
32#
33# Restarting a vcpeproxy will force the Docker instance to be cleaned up
34# automatically.
35# Note: Since vcpeproxy is created from XOS, if you want to delete that
36# Docker instance, you will have to go through XOS make cleanup operation.
37#
38function restart_all_vcpeproxy() {
39
40 echo "Restart all vcpeproxy..."
41
42 file_temp="/tmp/vcpeproxy_names.txt"
43
44 sudo docker ps|grep $vcpeproxy_prefix|awk '{print $NF}' > $file_temp
45
46 getArray $file_temp
47
48 for id in "${array[@]}"
49 do
50 echo "Restarting docker instance $id"
51 sudo docker exec $id sed -i "s/POST/DELETE/g" $NODEJS_MODULES_DIR$AP_REST_NETCFG
52 sudo docker exec $id bash $NODEJS_MODULES_DIR$AP_REST_NETCFG
53 sudo docker restart $id
54 done
55}
56
57echo "Killall nodejs programs running in the VSG"
58sudo killall nodejs
59restart_all_vcpeproxy
60if ifconfig -a |grep $vcpe_gwbr_name ; then
61 sudo ifconfig $vcpe_gwbr_name down
62 sudo brctl delbr $vcpe_gwbr_name
63fi
64if [ -d $vsg_home_dir ]; then
65 rm -rf $vsg_home_dir/*
66fi
67pid=`ps -fade|grep vsg_vcpe_monitor.sh|grep -v grep |awk '{print $2}'`
68if echo $pid|grep [0-9] ; then
69 echo "Killing vsg_vcpe_monitor.sh script"
70 sudo kill -9 $pid
71fi
72date
73echo "vsg_vcpegw_cleanup.sh: End"