commit:     5210bac33931b2b8716f1bf45ab39a27c481582c
Author:     Alexey Korepanov <kaikaikai <AT> yandex <DOT> ru>
AuthorDate: Sun Jul 24 20:05:41 2016 +0000
Commit:     Dirkjan Ochtman <djc <AT> gentoo <DOT> org>
CommitDate: Wed Jul 27 20:18:44 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5210bac3

net-p2p/syncting: fix init scripts for strelaysrv

 net-p2p/syncthing/files/strelaysrv.confd           |  3 +++
 net-p2p/syncthing/files/strelaysrv.initd           | 30 +++++++++++++++++++++
 net-p2p/syncthing/files/strelaysrv.logrotate       |  6 +++++
 ...ng-0.14.0.ebuild => syncthing-0.14.0-r1.ebuild} | 31 +++++++++++++++-------
 4 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/net-p2p/syncthing/files/strelaysrv.confd 
b/net-p2p/syncthing/files/strelaysrv.confd
new file mode 100644
index 0000000..00564f1
--- /dev/null
+++ b/net-p2p/syncthing/files/strelaysrv.confd
@@ -0,0 +1,3 @@
+# Options to pass to relaysrv
+# see /usr/libexec/syncthing/strelaysrv --help for more information
+SR_OPTS=

diff --git a/net-p2p/syncthing/files/strelaysrv.initd 
b/net-p2p/syncthing/files/strelaysrv.initd
new file mode 100644
index 0000000..7eb77be
--- /dev/null
+++ b/net-p2p/syncthing/files/strelaysrv.initd
@@ -0,0 +1,30 @@
+#!/sbin/openrc-run
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+SR_USER=strelaysrv
+SR_GROUP=strelaysrv
+SR_HOMEDIR=/var/lib/strelaysrv
+SR_LOGFILE=/var/log/syncthing/strelaysrv.log
+
+
+description="Relay service for syncthing"
+command="/usr/libexec/syncthing/strelaysrv"
+command_args="${SR_OPTS}"
+pidfile="/run/strelaysrv.pid"
+start_stop_daemon_args="--background
+  --user ${SR_USER}
+  --group ${SR_GROUP}
+  --chdir \"${SR_HOMEDIR}\"
+  --make-pidfile
+  --stdout \"${SR_LOGFILE}\"
+  --stderr \"${SR_LOGFILE}\"
+  "
+
+depend() {
+  need net
+}
+
+start_pre() {
+  checkpath -q -d -o ${SR_USER}:${SR_GROUP} ${SR_HOMEDIR}
+  checkpath -q -f -o ${SR_USER}:${SR_GROUP} ${SR_LOGFILE}
+}

diff --git a/net-p2p/syncthing/files/strelaysrv.logrotate 
b/net-p2p/syncthing/files/strelaysrv.logrotate
new file mode 100644
index 0000000..f168cbf
--- /dev/null
+++ b/net-p2p/syncthing/files/strelaysrv.logrotate
@@ -0,0 +1,6 @@
+/var/log/syncthing/relaysrv.log {
+    missingok
+    notifempty
+    sharedscripts
+    copytruncate
+}

diff --git a/net-p2p/syncthing/syncthing-0.14.0.ebuild 
b/net-p2p/syncthing/syncthing-0.14.0-r1.ebuild
similarity index 73%
rename from net-p2p/syncthing/syncthing-0.14.0.ebuild
rename to net-p2p/syncthing/syncthing-0.14.0-r1.ebuild
index 08ebbea..6b30bdc 100644
--- a/net-p2p/syncthing/syncthing-0.14.0.ebuild
+++ b/net-p2p/syncthing/syncthing-0.14.0-r1.ebuild
@@ -25,16 +25,19 @@ pkg_setup() {
        enewuser ${PN} -1 -1 /var/lib/${PN} ${PN}
 
        if use tools ; then
-               # separate user for relaysrv
-               enewgroup ${PN}-relaysrv
-               enewuser ${PN}-relaysrv -1 -1 /var/lib/${PN}-relaysrv 
${PN}-relaysrv
+               # separate user for the relay server
+               enewgroup strelaysrv
+               enewuser strelaysrv -1 -1 /var/lib/strelaysrv strelaysrv
+               # and his home folder
+               keepdir /var/lib/strelaysrv
+               fowners strelaysrv:strelaysrv /var/lib/strelaysrv
        fi
 }
 
 src_prepare() {
        default
        sed -i \
-               's|^ExecStart=.*|ExecStart=/usr/libexec/syncthing/relaysrv|' \
+               's|^ExecStart=.*|ExecStart=/usr/libexec/syncthing/strelaysrv|' \
                
src/${EGO_PN}/cmd/strelaysrv/etc/linux-systemd/strelaysrv.service \
                || die
 }
@@ -86,14 +89,11 @@ src_install() {
        if use tools ; then
                # openrc and systemd service files
                systemd_dounit 
"${S}"/src/${EGO_PN}/cmd/strelaysrv/etc/linux-systemd/strelaysrv.service
-               newconfd "${FILESDIR}/${PN}-relaysrv.confd" ${PN}-relaysrv
-               newinitd "${FILESDIR}/${PN}-relaysrv.initd" ${PN}-relaysrv
-
-               keepdir /var/lib/${PN}-relaysrv
-               fowners ${PN}-relaysrv:${PN}-relaysrv /var/{lib,log}/${PN}
+               newconfd "${FILESDIR}/strelaysrv.confd" strelaysrv
+               newinitd "${FILESDIR}/strelaysrv.initd" strelaysrv
 
                insinto /etc/logrotate.d
-               newins "${FILESDIR}/syncthing-relaysrv.logrotate" 
syncthing-relaysrv
+               newins "${FILESDIR}/strelaysrv.logrotate" strelaysrv
        fi
 }
 
@@ -108,4 +108,15 @@ pkg_postinst() {
                                "0.$(get_version_component_range 2).0."
                fi
        done
+
+       # check if user syncthing-relaysrv exists
+       # if yes, warn that it has been moved to strelaysrv
+       if [ -n "$(egetent passwd syncthing-relaysrv 2>/dev/null)" ]; then
+               ewarn
+               ewarn "The user and group for the relay server have been 
changed"
+               ewarn "from syncthing-relaysrv to strelaysrv"
+               ewarn "The old user and group are not deleted automatically. 
Delete them by running:"
+               ewarn "    userdel -r syncthing-relaysrv"
+               ewarn "    groupdel syncthing-relaysrv"
+       fi
 }

Reply via email to