forked from chadit/dotfiles_old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_syncthing.sh
executable file
·90 lines (66 loc) · 2.34 KB
/
install_syncthing.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
#!/bin/bash
# installs syncthing
func ()
{
local INSTALLVER=0.14.36
local SCRIPTUSER=${SUDO_USER}
local FILETAR="syncthing-linux-amd64-v${INSTALLVER}.tar.gz"
local SOURCEURL="https://github.com/syncthing/syncthing/releases/download/v${INSTALLVER}/syncthing-linux-amd64-v${INSTALLVER}.tar.gz"
if test "$SCRIPTUSER" = "" || test "$SCRIPTUSER" = "root"; then
SCRIPTUSER=${USER}
fi
# stop the service for updating
sudo systemctl stop [email protected]
cd /tmp/
# Download the sources if file does not exist
if [ ! -f /tmp/${FILETAR} ]; then
sudo wget ${SOURCEURL}
fi
sudo tar -xvf ${FILETAR}
# make sure the go folder is created
sudo mkdir -p /usr/syncthing
sudo chown ${USER} /usr/syncthing
# Install to /usr/
sudo rsync -av syncthing-linux-amd64-v${INSTALLVER}// /usr/syncthing
sudo chmod +x /usr/syncthing/syncthing
# sudo chown chadit /usr/syncthing/syncthing
local APPSHORTCUT="[Desktop Entry]
Name=Syncthing
Comment=Syncthing
Exec=/usr/syncthing/syncthing
Icon=/home/chadit/Dropbox/Linux/syncthing.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility"
sudo touch /usr/share/applications/syncthing.desktop
sudo chown chadit /usr/share/applications/syncthing.desktop
sudo echo "${APPSHORTCUT}" > /usr/share/applications/syncthing.desktop
sudo chmod +x /usr/share/applications/syncthing.desktop
# create service file is does not exist
if [ ! -f /etc/systemd/system/[email protected] ]; then
local SERVICESETTINGS="[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=man:syncthing(1)
After=network.target
[Service]
User=%i
ExecStart=/usr/syncthing/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
[Install]
WantedBy=multi-user.target"
sudo touch /etc/systemd/system/syncthing.service
# sudo chown chadit /etc/systemd/system/syncthing.service
sudo echo "${SERVICESETTINGS}" > /etc/systemd/system/[email protected]
sudo chmod +x /etc/systemd/system/syncthing.service
sudo systemctl enable [email protected]
fi
sudo systemctl start [email protected]
sudo systemctl daemon-reload
# remove tar.gz
sudo rm -rf syncthing-linux-*
}
func