-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall.sh
77 lines (69 loc) · 2.04 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/data/data/com.termux/files/usr/bin/bash
# device arch
DEVICE_ARCH=$(uname -m)
# echo $DEVICE_ARCH
# which country
COUNTRY=$(curl -s "http://api.ipaddress.com/iptocountry?format=txt")
if [ "$COUNTRY" = "CN" ]
then
echo "You are in China, switching to tuna mirrors..."
SOURCES_OLD=/data/data/com.termux/files/usr/etc/apt/sources.list
SOURCES_NEW=/data/data/com.termux/files/usr/etc/apt/sources.list.bak
if [ -f "$SOURCES_OLD" ]; then # backup
cp $SOURCES_OLD $SOURCES_NEW
echo $SOURCES_OLD" ---> "$SOURCES_NEW" ok!"
fi
# update to tsinghua :)
echo "deb [arch=all,"$DEVICE_ARCH"] http://mirrors.tuna.tsinghua.edu.cn/termux stable main" > $SOURCES_OLD
apt update && echo "update cache success"
fi
if [ ! -f /data/data/com.termux/files/home/ngrok ]
then
case $DEVICE_ARCH in
arm | aarch64)
NGROK_URL=https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip
;;
i686)
NGROK_URL=https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip
;;
x86_64)
NGROK_URL=https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
;;
*)
echo "Unknown arch detected"
exit 1
;;
esac
echo "ngrok download url: "$NGROK_URL
curl -o /data/data/com.termux/files/home/ngrok.zip $NGROK_URL
unzip /data/data/com.termux/files/home/ngrok.zip
fi
echo "a. apache, b. nginx, c. python simple HTTP server"
while true
do
read -p "which backend of webserver would you prefer? " OPTION
case $OPTION in
a | b | c | A | B | C )
break
;;
*)
continue
;;
esac
done
case $OPTION in
a | A)
apt install -y apache2 && nohup httpd 1>/dev/null 2>&1 &
;;
b | B)
apt install -y nginx && nohup nginx 1>/dev/null 2>&1 &
;;
c | C)
apt install -y python && nohup python -m http.server 8080 1>/dev/null 2>&1 &
;;
*)
break
;;
esac
chmod 755 /data/data/com.termux/files/home/ngrok
./ngrok http 8080