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] syncthing [options]
Options: Options:
-audit Write events to audit file
-generate="" Generate key and config in specified dir, then exit -generate="" Generate key and config in specified dir, then exit
-gui-address="" Override GUI address -gui-address="" Override GUI address
-gui-apikey="" Override GUI API key -gui-apikey="" Override GUI API key
@ -24,16 +25,17 @@ Options:
-logflags="2" Select information in log line prefix -logflags="2" Select information in log line prefix
-no-browser Do not start browser -no-browser Do not start browser
-no-restart Do not restart; just exit -no-restart Do not restart; just exit
-reset Prepare to resync from cluster -reset Reset the database
-upgrade Perform upgrade -upgrade Perform upgrade
-upgrade-check Check for available upgrade -upgrade-check Check for available upgrade
-upgrade-to="" Force upgrade directly from specified URL -upgrade-to="" Force upgrade directly from specified URL
-verbose Print verbose log output
-version Show version -version Show version
The default configuration directory is: The default configuration directory is:
~/.config/syncthing /home/lahire/.config/syncthing
The -logflags value is a sum of the following: 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) - "discover" (the discover package)
- "events" (the events package) - "events" (the events package)
- "files" (the files 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) - "net" (the main package; connections & network messages)
- "model" (the model package) - "model" (the model package)
- "scanner" (the scanner 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 GOMAXPROCS Set the maximum number of CPU cores to use. Defaults to all
available CPU cores. 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 PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Syncthing daemonisation service" DESC="Syncthing daemonisation service"
NAME=syncthing NAME=syncthing
DAEMON=/home/yunohost.syncthing/bin/$NAME DAEMON=/usr/bin/$NAME
DAEMON_ARGS=" & " GUIADDRESS="GUIADDRESSTOCHANGE"
DAEMON_ARGS=" -gui-address="$GUIADDRESS" & "
PIDFILE=/var/run/$NAME.pid PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME SCRIPTNAME=/etc/init.d/$NAME
DAEMONUSER=debian-syncthing DAEMONUSER=debian-syncthing

View file

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

View file

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

View file

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