-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·57 lines (51 loc) · 1.25 KB
/
install.sh
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
#!/bin/bash
INSTALL_PATH=${INSTALL_PATH:-""}
function doInstall(){
local arg1="$1"
shift
echo + install ".$arg1" " $INSTALL_PATH$arg1" "$@"
install "./$arg1" "$INSTALL_PATH$arg1" "$@"
}
function doInstallIfNotExits(){
local arg1="$1"
shift
if [ -f "$INSTALL_PATH$arg1" ]
then
echo " Skipping: $arg1 : already exists."
else
echo + install ".$arg1" " $INSTALL_PATH$arg1" "$@"
install "./$arg1" "$INSTALL_PATH$arg1" "$@"
fi
}
function doUninstall(){
echo + rm -f "$1"
rm -f "$1"
}
function doKeep (){
echo " Skipping: configuration file : $1"
rm -f "$1"
}
function performReplace(){
$1 /lib/systemd/system/usernetns-bridge.service
$1 /lib/systemd/system/[email protected]
$1 /lib/systemd/system/[email protected]
$1 /usr/local/bin/makebridge
$1 /usr/local/bin/makeusernetns
$1 /usr/local/bin/usernetnsexec
}
function performOnConfig(){
$1 /etc/usernetns.conf
}
if [ "$1" == "uninstall" ]
then
performReplace doUninstall
performOnConfig doKeep
elif [ "$#" == "0" ] || [ "$1" == "install"]
then
set -e
performReplace doInstall
performOnConfig doInstallIfNotExits
else
echo "Unknown options: " "$@" 1>&2
exit 1
fi