forked from basiooo/andromodem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
95 lines (77 loc) · 2.42 KB
/
installer.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
#!/bin/sh
opkg update
echo "Installing Adb, Wget and Curl"
opkg install adb
opkg install wget
opkg install curl
if [ ! -d "/opt" ]; then
echo "Creating directory /opt..."
mkdir -p /opt
fi
echo "Kill existing andromodem proccess."
killall /opt/andromodem
arch=$(uname -m)
if [[ $arch == *"arm"* ]]; then
download_url="https://andromodem.bagasjulianto.my.id/download/latest/andromodem_arm"
elif [[ $arch == *"x86_64"* || $arch == *"amd64"* ]]; then
download_url="https://andromodem.bagasjulianto.my.id/download/latest/andromodem_amd64"
elif [[ $arch == *"x86"* ]]; then
download_url="https://andromodem.bagasjulianto.my.id/download/latest/andromodem_x86"
elif [[ $arch == *"aarch64"* || $arch == *"arm64"* ]]; then
download_url="https://andromodem.bagasjulianto.my.id/download/latest/andromodem_arm64"
else
echo "Unsupported architecture: $arch"
exit 1
fi
echo "Downloading Andromodem for $arch device..."
if curl -o /opt/andromodem "$download_url"; then
chmod +x /opt/andromodem
else
echo "Failed download using curl. Trying with wget..."
if wget -O /opt/andromodem "$download_url"; then
chmod +x /opt/andromodem
else
echo "Both curl and wget failed. Please check your internet connection and try again."
exit 1
fi
fi
echo "Add Andromodem in luci menu"
mkdir -p /usr/lib/lua/luci/view
cat << EOF > /usr/lib/lua/luci/view/andromodem.htm
<%+header%>
<div class="cbi-map"><br>
<iframe id="andromodem" style="width: 100%; min-height: 750px; border: none;"></iframe>
</div>
<script type="text/javascript">
document.getElementById("andromodem").src = \`http://\${window.location.hostname}:49153\`;
</script>
<%+footer%>
EOF
mkdir -p /usr/lib/lua/luci/controller
cat << EOF > /usr/lib/lua/luci/controller/andromodem.lua
module("luci.controller.andromodem", package.seeall)
function index()
entry({"admin","status","andromodem"}, template("andromodem"), _("Andromodem"), 4).leaf=true
end
EOF
cat <<EOF > /etc/init.d/andromodem
#!/bin/sh /etc/rc.common
# Copyright (C) 2024 Bagas Julianto
USE_PROCD=1
START=99
stop_service() {
killall andromodem
}
start_service() {
procd_open_instance
procd_set_param command "/opt/andromodem"
procd_close_instance
}
EOF
# Remove fucking startup code
if grep -qxF '/opt/andromodem' /etc/rc.local; then
sed -i '/\/opt\/andromodem/d' /etc/rc.local
fi
echo "Starting Andromodem"
chmod 775 /etc/init.d/andromodem
/etc/init.d/andromodem start