net-p2p/syncting: fix init scripts for strelaysrv
authorAlexey Korepanov <kaikaikai@yandex.ru>
Sun, 24 Jul 2016 20:05:41 +0000 (21:05 +0100)
committerDirkjan Ochtman <djc@gentoo.org>
Wed, 27 Jul 2016 20:18:44 +0000 (22:18 +0200)
net-p2p/syncthing/files/strelaysrv.confd [new file with mode: 0644]
net-p2p/syncthing/files/strelaysrv.initd [new file with mode: 0644]
net-p2p/syncthing/files/strelaysrv.logrotate [new file with mode: 0644]
net-p2p/syncthing/syncthing-0.14.0-r1.ebuild [moved from net-p2p/syncthing/syncthing-0.14.0.ebuild with 73% similarity]

diff --git a/net-p2p/syncthing/files/strelaysrv.confd b/net-p2p/syncthing/files/strelaysrv.confd
new file mode 100644 (file)
index 0000000..00564f1
--- /dev/null
@@ -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 (file)
index 0000000..7eb77be
--- /dev/null
@@ -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 (file)
index 0000000..f168cbf
--- /dev/null
@@ -0,0 +1,6 @@
+/var/log/syncthing/relaysrv.log {
+    missingok
+    notifempty
+    sharedscripts
+    copytruncate
+}
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 08ebbea4bfce3a8860db752feaec75be75be11bd..6b30bdc1cf8805f73829ec81e446172dd125474a 100644 (file)
@@ -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
 }