-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
executable file
·131 lines (98 loc) · 3.59 KB
/
script.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
check_or_create(){
FILE=~/.ssh/id_dsa
if [ -f "$FILE" ]; then
echo "$FILE exists."
else
ssh-keygen -b 2048 -t rsa -f $FILE -q -N ""
fi
}
if [ -z $1 ]; then
echo "Enter the Username:"
read USER
else
USER=$1
fi
stty -echo ; read -p "Enter New Password: " PASSWD; stty echo
echo "Your username $USER and your password only you know"
UNAME=$(uname)
tmux_job(){
## If want to enable authentication and readonly just uncomment this:
tmux new-session -s "set ssh in browser" -d "ttyd -p 8080 -c $USER:$PASSWD -B -R bash -lic 'tmux a'"
## and comment default one
#tmux new-session -s "set ssh in browser" -d "ttyd -p 8080 bash x"
## If you want to be 'readonly' just add -R. Example:
#tmux new-session -s "set ssh in browser" -d "ttyd -p 8080 -R bash x"
tmux split-window -h -p 50 -t 0 "ssh -R 80:localhost:8080 ssh.localhost.run"
tmux split-window -v
tmux a -t "set ssh in browser"
}
git_job(){
git clone https://github.com/tsl0922/ttyd.git ~/ttyd
cd ~/ttyd
mkdir build
cd build
sudo cmake ..
sudo make && sudo make install
cd ../../
}
PKG_PACKAGE_NAME="git-lite cmake tmux ttyd"
DEB_PACKAGE_NAME="git cmake make tmux build-essential libjson-c-dev libwebsockets-dev"
APK_PACKAGE_NAME="git musl-dev zlib zlib-dev make libzip libuv-dev json-c-dev cmake tmux gcc libwebsockets-dev libwebsockets"
PACMAN_PACKAGE_NAME="git cmake tmux libwebsockets"
DNF_PACKAGE_NAME="git cmake.x86_64 make tmux libjson-rpc-cpp-devel.x86_64 libwebsockets-devel.x86_64 json-c-devel.x86_64 openssl-devel.x86_64 zlib-devel.x86_64"
if cat /etc/*release | grep ^NAME | grep Alpine; then
check_or_create
echo "==============================================="
echo "Installing packages $APK_PACKAGE_NAME on Alpine"
echo "==============================================="
sudo apk add $APK_PACKAGE_NAME
git_job
tmux_job
elif cat /etc/*release | grep ^NAME | grep Arch; then
check_or_create
echo "==============================================="
echo "Installing packages $PACMAN_PACKAGE_NAME on Arch"
echo "==============================================="
sudo pacman -S -y $PACMAN_PACKAGE_NAME
git_job
tmux_job
elif cat /etc/*release | grep ^NAME | grep Fedora; then
check_or_create
echo "==============================================="
echo "Installing packages $DNF_PACKAGE_NAME on Fedora"
echo "==============================================="
sudo dnf install -y $DNF_PACKAGE_NAME
git_job
tmux_job
elif cat /etc/*release | grep ^NAME | grep Ubuntu; then
check_or_create
echo "==============================================="
echo "Installing packages $DEB_PACKAGE_NAME on Ubuntu"
echo "==============================================="
sudo apt-get update
sudo apt-get install -y $DEB_PACKAGE_NAME
git_job
tmux_job
elif cat /etc/*release | grep ^NAME | grep Debian; then
check_or_create
echo "==============================================="
echo "Installing packages $DEB_PACKAGE_NAME on Debian"
echo "==============================================="
sudo apt-get update
sudo apt-get install -y $DEB_PACKAGE_NAME
git_job
tmux_job
elif uname -a | awk '{ print $1}' | grep FreeBSD; then
check_or_create
echo "================================================="
echo "Installing packages $PKG_PACKAGE_NAME on FreeBSD"
echo "================================================="
sudo pkg update
sudo pkg install -y $PKG_PACKAGE_NAME
tmux_job
else
echo "OS NOT DETECTED, couldn't install package $PACKAGE"
exit 1;
fi
exit 0