forked from techrelay/GL.iNet-CellularModels-SMSonBoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
51 lines (41 loc) · 1.23 KB
/
install.sh
File metadata and controls
51 lines (41 loc) · 1.23 KB
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
#!/bin/sh
set -eu
PHONE="${1:-}"
WEBHOOK_URL="${2:-}"
REPO_RAW_BASE="https://raw.githubusercontent.com/techrelay/GL.iNet-CellularModels-SMSonBoot/main"
if [ "$(id -u)" -ne 0 ]; then
echo "Run as root." >&2
exit 1
fi
if ! command -v sendsms >/dev/null 2>&1; then
echo "ERROR: sendsms not found. GL.iNet firmware required." >&2
exit 1
fi
echo "[*] Downloading sms_on_boot.sh..."
curl -fsSL \
"$REPO_RAW_BASE/sms_on_boot.sh" \
-o /usr/bin/sms_on_boot.sh
chmod +x /usr/bin/sms_on_boot.sh
if [ -n "$PHONE" ]; then
sed -i "s|^PHONE=\".*\"|PHONE=\"$PHONE\"|g" /usr/bin/sms_on_boot.sh
echo "[*] Set PHONE to: $PHONE"
else
echo "[!] No phone provided. Edit /usr/bin/sms_on_boot.sh later."
fi
if [ -n "$WEBHOOK_URL" ]; then
sed -i "s|^WEBHOOK_URL=\".*\"|WEBHOOK_URL=\"$WEBHOOK_URL\"|g" /usr/bin/sms_on_boot.sh
echo "[*] Set WEBHOOK_URL to: $WEBHOOK_URL"
fi
echo "[*] Creating init.d service..."
cat > /etc/init.d/sms_on_boot <<'EOF'
#!/bin/sh /etc/rc.common
START=99
start() {
/usr/bin/sms_on_boot.sh &
}
EOF
chmod +x /etc/init.d/sms_on_boot
/etc/init.d/sms_on_boot enable
echo "[OK] Installed."
echo "To test immediately (no reboot required):"
echo " rm -f /etc/sms_on_boot.last && /usr/bin/sms_on_boot.sh && cat /tmp/sms_on_boot.log"