-
Notifications
You must be signed in to change notification settings - Fork 3
/
S98tailscale
executable file
·84 lines (72 loc) · 1.83 KB
/
S98tailscale
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
#!/bin/bash
set -e -o pipefail
PROG="/usr/bin/tailscaled"
PROG_TMP="/tmp/tailscale.tgz"
PROG_TMP_FOLDER="/tmp/tailscale"
FORCE_INIT="0"
TAILSCALE_VER="1.48.1"
PROG_URL="https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VER}_arm.tgz"
test -n "${OS_VERSION}" || source /etc/init.d/base
install() {
if [ -f "${PROG}" ] && [ "${FORCE_INIT}" == "0" ];
then
/bin/true
else
if [ ! -f "/tmp/S98tailscale" ]
then
echo "Plese run:"
echo "curl -L https://raw.githubusercontent.com/goldfix/motioneyeos_ext/main/src/S98tailscale -o /tmp/S98tailscale && bash /tmp/S98tailscale install"
echo "to reinstall."
exit 1
fi
mount -o remount,rw /
mount -o remount,rw /boot
rm -rf /usr/bin/tailscale*
rm -rf /tmp/tailscale*
cd /tmp
curl -L ${PROG_URL} --output ${PROG_TMP}
tar xvf ${PROG_TMP}
mv /tmp/tailscale_${TAILSCALE_VER}_arm ${PROG_TMP_FOLDER}
cp ${PROG_TMP_FOLDER}/tailscale /usr/bin/
cp ${PROG_TMP_FOLDER}/tailscaled /usr/bin/
rm -rf /tmp/tailscale*
# rmmod tun
# modprobe tun
chmod ugo+rx /tmp/S98tailscale
cp -a /tmp/S98tailscale /etc/init.d/
fi
}
start() {
msg_begin "Starting tailscale"
modprobe tun
${PROG} --state=/usr/bin/tailscaled.state > /var/log/tailscaled.log 2>&1 &
test $? == 0 && msg_done || msg_fail
return 0
}
stop() {
msg_begin "Stopping tailscale"
killall -q $(basename ${PROG})
msg_done
}
case "$1" in
start)
install
start
;;
stop)
stop
;;
restart)
stop
start
;;
install)
FORCE_INIT="1"
install
;;
*)
echo "Usage: $0 {start|stop|restart|install}"
exit 1
;;
esac
exit $?