1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/syncthing_ynh.git synced 2024-09-03 20:26:23 +02:00

switch to apt repository finish. fix guiport in sysinit script

This commit is contained in:
Lahire BIETTE 2015-05-28 22:57:10 +02:00
parent 7cec8137d5
commit 10f52ce3d0
5 changed files with 50 additions and 39 deletions

View file

@ -16,6 +16,7 @@ Usage:
syncthing [options]
Options:
-audit Write events to audit file
-generate="" Generate key and config in specified dir, then exit
-gui-address="" Override GUI address
-gui-apikey="" Override GUI API key
@ -24,16 +25,17 @@ Options:
-logflags="2" Select information in log line prefix
-no-browser Do not start browser
-no-restart Do not restart; just exit
-reset Prepare to resync from cluster
-reset Reset the database
-upgrade Perform upgrade
-upgrade-check Check for available upgrade
-upgrade-to="" Force upgrade directly from specified URL
-verbose Print verbose log output
-version Show version
The default configuration directory is:
~/.config/syncthing
/home/lahire/.config/syncthing
The -logflags value is a sum of the following:
@ -64,6 +66,8 @@ are mostly useful for developers. Use with care.
- "discover" (the discover package)
- "events" (the events package)
- "files" (the files package)
- "http" (the main package; HTTP requests)
- "locks" (the sync package; trace long held locks)
- "net" (the main package; connections & network messages)
- "model" (the model package)
- "scanner" (the scanner package)
@ -90,3 +94,7 @@ are mostly useful for developers. Use with care.
GOMAXPROCS Set the maximum number of CPU cores to use. Defaults to all
available CPU cores.
GOGC Percentage of heap growth at which to trigger GC. Default is
100. Lower numbers keep peak memory usage down, at the price
of CPU usage (ie. performance).

View file

@ -21,8 +21,9 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Syncthing daemonisation service"
NAME=syncthing
DAEMON=/home/yunohost.syncthing/bin/$NAME
DAEMON_ARGS=" & "
DAEMON=/usr/bin/$NAME
GUIADDRESS="GUIADDRESSTOCHANGE"
DAEMON_ARGS=" -gui-address="$GUIADDRESS" & "
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMONUSER=debian-syncthing

View file

@ -4,15 +4,15 @@
domain=$1
path=$2
# channel: release or devel. will add choise on install
syncChannel=release
CHANNEL=release
# Configurable variables
syncVersion="0.11.5"
syncHome="/home/yunohost.syncthing"
syncUser=debian-syncthing
syncSyncport=22000
syncUIport=8384
VERSION="0.11.5"
SYNCHOME="/home/yunohost.syncthing"
USER=debian-syncthing
SYNCPORT=22000
GUIPORT=8080
sudo yunohost app checkurl $domain$path -a syncthing
if [[ ! $? -eq 0 ]]; then
@ -24,38 +24,40 @@ fi
path=${path%/}
# Check port availability
sudo yunohost app checkport $syncUIport
sudo yunohost app checkport $GUIPORT
if [[ ! $? -eq 0 ]]; then
echo Port $syncUIport for Syncthing UI is not available.
echo Port $GUIPORT for Syncthing UI is not available.
exit 1
fi
sudo yunohost app checkport $syncSyncport
sudo yunohost app checkport $SYNCPORT
if [[ ! $? -eq 0 ]]; then
echo Port $syncSyncport is for Syncthing protocol is not available.
echo Port $SYNCPORT is for Syncthing protocol is not available.
exit 1
fi
# Open port in firewall
sudo yunohost firewall allow TCP $syncSyncport > /dev/null 2>&1
sudo yunohost firewall allow TCP $SYNCPORT > /dev/null 2>&1
# Create $syncUser user to run syncthing service
sudo useradd -m -d $syncHome/ -s /bin/bash $syncUser
# Create $USER user to run syncthing service
sudo useradd -m -d $SYNCHOME/ -s /bin/bash $USER
# Make directories and set rights
sudo mkdir -p $syncHome/{bin,storage}
sudo chown -R $syncUser:$syncUser $syncHome/
sudo find $syncHome/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
sudo find $syncHome/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
sudo mkdir -p $SYNCHOME/{bin,storage}
sudo chown -R $USER:$USER $SYNCHOME/
sudo find $SYNCHOME/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
sudo find $SYNCHOME/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
# Download and install syncthing binary
sudo apt-get install curl
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
echo "deb http://apt.syncthing.net/ syncthing $syncChannel" | sudo tee /etc/apt/sources.list.d/syncthing-$syncChannel.list
echo "deb http://apt.syncthing.net/ syncthing $CHANNEL" | sudo tee /etc/apt/sources.list.d/syncthing-$CHANNEL.list
sudo apt-get update
sudo apt-get install syncthing
sudo apt-get install syncthing -y
# Install and monitor service
sudo cp ../conf/syncthing /etc/init.d/syncthing
GUIADDRESS="127.0.0.1:$GUIPORT"
sed -i "s@GUIADDRESSTOCHANGE@$GUIADDRESS@g" ../conf/sysinit
sudo cp ../conf/sysinit /etc/init.d/syncthing
sudo chmod 0755 /etc/init.d/syncthing
sudo update-rc.d syncthing defaults
sudo yunohost service add -l /var/log/syncthing.log syncthing
@ -69,7 +71,7 @@ fi
# Configure Nginx and reload
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
sed -i "s@PORTTOCHANGE@$syncUIport@g" ../conf/nginx.conf
sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf
sudo service nginx reload
echo $?

View file

@ -1,8 +1,8 @@
#!/bin/bash
syncHome="/home/yunohost.syncthing"
syncUser=debian-syncthing
syncSyncport=22000
SYNCHOME="/home/yunohost.syncthing"
SYNCUSER=debian-syncthing
SYNCPORT=22000
# Stop and remove syncthing service
sudo service syncthing stop
@ -11,22 +11,22 @@ sudo update-rc.d -f syncthing remove
sudo rm -f /etc/init.d/syncthing
# Remove syncthing binairy
sudo rm -rf $syncHome/bin/
sudo apt-get remove syncthing
# Backup syncthign HOME directory
sudo mv $syncHome $syncHome.lod
# sudo rm -rf $syncHome
# Backup syncthign SYNCHOME directory
sudo mv $SYNCHOME $SYNCHOME.old
# sudo rm -rf $SYNCHOME
# Remove syncthing user
sudo userdel $syncUser
sudo userdel $SYNCUSER
# Close port in firewall
sudo yunohost firewall disallow TCP $syncSyncport
sudo yunohost firewall disallow TCP $SYNCPORT
# Remove syncthing logrotate configuration
if [ -f /etc/logrotate.d/syncthing ]
then
sudo rm /etc/logrotate.d/syncthing
sudo rm /etc/logrotate.d/syncthing
fi
# Remove syncthing nginx configuration

View file

@ -1,8 +1,8 @@
#!/bin/bash
# Configurable variables
syncUser=debian-syncthing
syncHome="/home/yunohost.syncthing"
USER=debian-syncthing
SYNCHOME="/home/yunohost.syncthing"
# Retrieve arguments
domain=$(sudo yunohost app setting syncthing domain)
@ -12,14 +12,14 @@ path=$(sudo yunohost app setting syncthing path)
path=${path%/}
# Update syncthing sysvinit script
sudo cp -f ../conf/syncthing /etc/init.d/syncthing
sudo cp -f ../conf/sysinit /etc/init.d/syncthing
sudo chmod 0755 /etc/init.d/syncthing
sudo update-rc.d syncthing defaults
sudo yunohost service add syncthing
sudo service syncthing restart
# Upgrade official debian package
sudo -i -u $syncUser $syncHome/bin/syncthing -upgrade
sudo apt-get upgrade syncthing -y
# Update and reload Nginx
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf