-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSTOP-LISP
executable file
·107 lines (97 loc) · 2.96 KB
/
STOP-LISP
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/tcsh
# -----------------------------------------------------------------------------
#
# Copyright 2013-2019 lispers.net - Dino Farinacci <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# -----------------------------------------------------------------------------
#
# STOP-LISP
#
# Stop all LISP processes and remove the named socket descriptors and any
# iptables rules created by lispers.net.
#
#------------------------------------------------------------------------------
cd `dirname $0`
ls lisp-itr >& /dev/null
set itr = $status
#
# Check to see if python2 is installed and if symlink python is set in installed directory.
# In recent versions of ubuntu, the command "python" has been removed. We do this check
# in RUN-LISP too. Just in case the user issues the RUN-LISP command, but if they issue
# the ./RL script, then STOP-LISP is called first. So we need the symlink set here.
#
which python > /dev/null
if ($status != "0") then
set PY = `which python2`
set PY = `dirname $PY`
echo "Installing 'ln -s python2 python' in $PY"
pushd $PY; ln -s python2 python; popd
endif
#
# Remove each lispers.net LISP processes. Do not continue until they are
# all gone.
#
set pids = `./pslisp | egrep "lisp-" | egrep -v "lisp-join|lisp-ztr" | cut -f 1 -d " "`
echo "Stopping LISP processes [$pids] ..."
foreach p ($pids)
sudo kill $p
end
while 1
set pids = `./pslisp | egrep "lisp-" | egrep -v "lisp-join|lisp-ztr" | cut -f 1 -d " "`
if ($pids == "") then
break
else
echo "Waiting on processes ["$pids"]"
endif
end
#
# Wait for UDP well-known port sockets to clear.
echo "Clearing sockets ..."
sleep 1
#
# Point to correct python version.
#
set PY = "python"
set SUFFIX = "pyo"
if (-f ./remove-lisp-locks.pyc) then
set PY = "python3.8"
set SUFFIX = "pyc"
endif
#
# Remove LISP lock files.
#
$PY ./remove-lisp-locks.$SUFFIX
#
# Remove /tmp/lisp-lig if lisp-lig.py crashed and wasn't able to remove the
# named socket.
#
rm -f /tmp/lisp-lig > /dev/null
#
# User created iptables rules and doesn't want lispers.net to remove anything.
#
if ($?LISP_NO_IPTABLES) then
echo "User bypass removing LISP iptables"
exit(0)
endif
#
# Remove iptables lispers.net created if we are an ITR.
#
if ($itr == 0) then
$PY ./remove-lisp-iptables.$SUFFIX
else
echo "Bypass removing LISP iptables, ITR process not running"
endif
exit(0)
#------------------------------------------------------------------------------