Merge "CentOS Setup Master CleanUp Script"
[eliot.git] / blueprints / iotgateway / scripts / ci_management / cleanup_master.sh
1 #!/bin/bash -ex
2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 # constants
12
13 TESTYAML="testk8s-nginx.yaml"
14 SUPERUSER="root"
15 value=$(whoami)
16
17 # start
18
19 # kubeedge reset internally undo the things done by ./kubeedge init
20
21 if [ -d "$GOPATH/src/github.com/kubeedge/kubeedge/keadm" ]; then
22    cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm
23    ./keadm reset
24 fi
25
26 # delete the previously existing certificates
27
28 if [ -d "/etc/kubeedge/ca" ]; then
29    sudo rm -rf /etc/kubeedge/ca
30 fi
31
32 if [ -d "/etc/kubeedge/certs" ]; then
33    cd /etc/kubeedge
34    sudo rm -rf certs
35 fi
36
37 cd /etc/kubeedge
38 if [ -f "certs.tgz" ]; then
39    sudo rm certs.tgz
40 fi
41
42 # delete the kubeedge code
43
44 if [ -d "$GOPATH/src" ]; then
45    cd $GOPATH
46    sudo rm -rf src
47 fi
48
49 # stop binaries edge_core edgecontroller
50
51 cd /usr/local/bin
52
53 if [ -f "edge_core" ]; then
54    sudo rm edge_core
55 fi
56
57 if [ -f "edgecontroller" ]; then
58    sudo rm edgecontroller
59 fi
60
61 if [ $value != $SUPERUSER ]; then
62    sudo su
63 fi
64
65 cd
66
67 if [ -f $TESTYAML ]; then
68    sudo rm $TESTYAML
69 fi
70