-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·45 lines (35 loc) · 1017 Bytes
/
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
#!/bin/sh
set -euxvo pipefail
PIDFILE="/var/run/tailscaled.pid"
__error() {
echo "$@" >&2
exit 1
}
if [[ $# -lt 1 ]] ; then
__error "usage: $0 <init-file>"
fi
init_file="$1"
base_dir=$(dirname $0)
backup_dir="$base_dir/backup"
if [[ -e "$PIDFILE" ]] ; then
sudo pkill -P $(cat $PIDFILE) || true
sudo start-stop-daemon -K -p $PIDFILE || true
fi
__backup_if_exist() {
backup_dir=$1
shift
mkdir -p $backup_dir
for f in $@ ; do
if [[ -e $f ]] ; then
cp -r $f $backup_dir/
fi
done
}
__backup_if_exist $backup_dir /usr/local/bin/tailscale /usr/local/sbin/tailscaled /usr/local/etc/init.d/$init_file
sudo cp -f $base_dir/tailscale /usr/local/bin/tailscale
sudo cp -f $base_dir/tailscaled /usr/local/sbin/tailscaled
sudo cp -f $base_dir/$init_file /usr/local/etc/init.d/$init_file
sudo chmod +x /usr/local/bin/tailscale
sudo chmod +x /usr/local/sbin/tailscaled
sudo chmod +x /usr/local/etc/init.d/$init_file
sudo /usr/local/etc/init.d/$init_file