From af95c506590a6a3386c7e4fd75669fdfede23417 Mon Sep 17 00:00:00 2001 From: Stephane Camhaji Date: Mon, 11 May 2015 16:02:20 +0200 Subject: [PATCH 1/3] enable log file --- conf/syncthing | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/conf/syncthing b/conf/syncthing index ece03b6..feeb129 100644 --- a/conf/syncthing +++ b/conf/syncthing @@ -26,6 +26,7 @@ DAEMON_ARGS=" & " PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME DAEMONUSER=debian-syncthing +LOGFILE=/var/log/$NAME.log # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 @@ -52,9 +53,9 @@ do_start() # 2 if daemon could not be started start-stop-daemon --start --quiet --chuid $DAEMONUSER --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 - start-stop-daemon --start --quiet --chuid $DAEMONUSER --pidfile $PIDFILE --exec $DAEMON -- \ - $DAEMON_ARGS \ - || return 2 & > /dev/null + start-stop-daemon --start --quiet --chuid $DAEMONUSER --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- \ + $DAEMON_ARGS >> $LOGFILE 2>&1 \ + || return 2 & # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. @@ -157,4 +158,4 @@ case "$1" in ;; esac -: + From 3f6d53dcfa3b9b449d3f70539a0896d5c58b74f0 Mon Sep 17 00:00:00 2001 From: Stephane Camhaji Date: Mon, 11 May 2015 16:42:43 +0200 Subject: [PATCH 2/3] configure logrotate --- conf/logrotate.conf | 14 ++++++++++++++ scripts/install | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 conf/logrotate.conf diff --git a/conf/logrotate.conf b/conf/logrotate.conf new file mode 100644 index 0000000..514f203 --- /dev/null +++ b/conf/logrotate.conf @@ -0,0 +1,14 @@ +/var/log/syncthing.log { + rotate 4 + weekly + minsize 1M + missingok + create 640 root adm + notifempty + compress + delaycompress + postrotate + invoke-rc.d syncthing restart > /dev/null + endscript +} + diff --git a/scripts/install b/scripts/install index 9c8ee4d..ba75460 100644 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,12 @@ sudo update-rc.d syncthing defaults sudo yunohost service add synchting sudo service syncthing start +# Configure logrotate if present +if [ -d "/etc/logrotate.d" ]; then + sudo cp ../conf/logrotate.conf /etc/logrotate.d/syncthing + sudo chmod 0755 /etc/logrotate.d/syncthing +fi + # Configure Nginx and reload sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@PORTTOCHANGE@$syncUIport@g" ../conf/nginx.conf From a3b3b7b01914bbb9c60b6fa4b30f12d34dab4045 Mon Sep 17 00:00:00 2001 From: Stephane Camhaji Date: Mon, 11 May 2015 16:42:43 +0200 Subject: [PATCH 3/3] configure logrotate --- conf/logrotate.conf | 14 ++++++++++++++ scripts/install | 6 ++++++ scripts/remove | 6 ++++++ 3 files changed, 26 insertions(+) create mode 100644 conf/logrotate.conf diff --git a/conf/logrotate.conf b/conf/logrotate.conf new file mode 100644 index 0000000..514f203 --- /dev/null +++ b/conf/logrotate.conf @@ -0,0 +1,14 @@ +/var/log/syncthing.log { + rotate 4 + weekly + minsize 1M + missingok + create 640 root adm + notifempty + compress + delaycompress + postrotate + invoke-rc.d syncthing restart > /dev/null + endscript +} + diff --git a/scripts/install b/scripts/install index 9c8ee4d..ba75460 100644 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,12 @@ sudo update-rc.d syncthing defaults sudo yunohost service add synchting sudo service syncthing start +# Configure logrotate if present +if [ -d "/etc/logrotate.d" ]; then + sudo cp ../conf/logrotate.conf /etc/logrotate.d/syncthing + sudo chmod 0755 /etc/logrotate.d/syncthing +fi + # Configure Nginx and reload sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@PORTTOCHANGE@$syncUIport@g" ../conf/nginx.conf diff --git a/scripts/remove b/scripts/remove index 2397f26..a506dde 100644 --- a/scripts/remove +++ b/scripts/remove @@ -24,6 +24,12 @@ sudo userdel $syncUser # Close port in firewall sudo yunohost firewall disallow TCP $syncSyncport +# Remove syncthing logrotate configuration +if [ -f /etc/logrotate.d/syncthing ] +then + sudo rm /etc/logrotate.d/syncthing +fi + # Remove syncthing nginx configuration domain=$(sudo yunohost app setting syncthing domain) sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf