From 10f52ce3d09ac57be04ad819854dcd4d1819ade2 Mon Sep 17 00:00:00 2001 From: Lahire BIETTE Date: Thu, 28 May 2015 22:57:10 +0200 Subject: [PATCH] switch to apt repository finish. fix guiport in sysinit script --- README.md | 12 ++++++++-- conf/{syncthing => sysinit} | 5 +++-- scripts/install | 44 +++++++++++++++++++------------------ scripts/remove | 20 ++++++++--------- scripts/upgrade | 8 +++---- 5 files changed, 50 insertions(+), 39 deletions(-) rename conf/{syncthing => sysinit} (98%) diff --git a/README.md b/README.md index dfe83a1..6584f0d 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/conf/syncthing b/conf/sysinit similarity index 98% rename from conf/syncthing rename to conf/sysinit index feeb129..49a0a1d 100644 --- a/conf/syncthing +++ b/conf/sysinit @@ -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 diff --git a/scripts/install b/scripts/install index b9ca55e..2601411 100644 --- a/scripts/install +++ b/scripts/install @@ -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 $? diff --git a/scripts/remove b/scripts/remove index 4092aed..d0af13d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -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 diff --git a/scripts/upgrade b/scripts/upgrade index b2c575c..4b276b9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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