-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
executable file
·46 lines (37 loc) · 1.03 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
#!/data/data/com.termux/files/usr/bin/bash
# termux-reverse-ssh by ustcpetergu
# License: GPLv3
function fail
{
echo "Failed. "
exit 255
}
echo "Gather information..."
read -p "Enter remote server username: " user
read -p "Enter remote server address: " address
read -p "Enter remote server port: " port
read -p "Enter trigger URL: " url
echo ""
echo "Generate ssh key..."
idrsa="/data/data/com.termux/files/home/.ssh/id_rsa_trs"
ssh-keygen -t rsa -f "$idrsa" -q -P "" || fail
echo "Upload key(you'll need to enter password)..."
ssh-copy-id -i $idrsa ${user}@${address} -p $port || fail
cat > ~/.trs_config << EOF
# this trs config is generated by install.sh
user="$user"
address="$address"
port="$port"
idrsa="$idrsa"
url="$url"
EOF
echo "Install auto start script..."
cdir=$(pwd)
mkdir -p ~/.termux/boot 2>/dev/null
cat > ~/.termux/boot/90trs.sh << EOF
#!/data/data/com.termux/files/usr/bin/bash
# this trs auto-launch script is generated by install.sh
setsid bash $cdir/trs.sh >/dev/null 2>&1 < /dev/null &
sleep 1
EOF
echo "Finished. "