forked from ramzimalhas/termius-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·116 lines (99 loc) · 2.74 KB
/
bootstrap.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
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
108
109
110
111
112
113
114
115
116
#!/bin/sh
tar_url='https://github.com/termius/termius-cli/archive/master.zip'
command_exists() {
command -v "$@" > /dev/null 2>&1
}
eval_sh_c() {
user="$(id -un 2>/dev/null || true)"
_sh_c='sh -c'
if [ "$user" != 'root' ]; then
if command_exists sudo; then
_sh_c='sudo -E sh -c'
elif command_exists su; then
_sh_c='su -c'
else
cat >&2 <<-'EOF'
Error: this installer needs the ability to run commands as root.
We are unable to find either "sudo" or "su" available to make this happen.
EOF
exit 1
fi
fi
echo $_sh_c
}
do_install() {
sh_c=$(eval_sh_c)
curl=''
if command_exists curl; then
curl='curl -sSL'
elif command_exists wget; then
curl='wget -qO-'
elif command_exists busybox && busybox --list-modules | grep -q wget; then
curl='busybox wget -qO-'
fi
apt_requirements='python gcc python-dev libffi-dev libssl-dev'
yum_requirements='python gcc python-devel libffi-devel openssl-devel'
zypper_requirements='python gcc python-devel libffi-devel openssl-devel'
lsb_dist=''
if command_exists lsb_release; then
lsb_dist="$(lsb_release -si)"
fi
if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then
lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
fi
if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then
lsb_dist='debian'
fi
if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then
lsb_dist='fedora'
fi
if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
case "$lsb_dist" in
amzn|fedora|centos)
(
set -x
$sh_c "sleep 3; yum -y -q install $yum_requirements"
)
;;
'opensuse project'|opensuse|'suse linux'|sled)
(
set -x
$sh_c "sleep 3; zypper -n install $zypper_requirements"
)
;;
ubuntu|debian|linuxmint|'elementary os'|kali)
export DEBIAN_FRONTEND=noninteractive
if [ -z "$curl" ]; then
apt_get_update
( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' )
curl='curl -sSL'
fi
did_apt_get_update=
apt_get_update() {
if [ -z "$did_apt_get_update" ]; then
( set -x; $sh_c 'sleep 3; apt-get update' )
did_apt_get_update=1
fi
}
apt_get_update
(
set -x
$sh_c "sleep 3; apt-get install -y -q $apt_requirements"
)
;;
esac
if ! (command_exists easy_install); then
$sh_c "$curl https://bootstrap.pypa.io/ez_setup.py | python"
fi
easy_install -U $tar_url
if command_exists termius; then
(
set -x
) || true
fi
exit 0
}
do_install