net-p2p/go-ipfs-bin: add services for openrc & systemd
authorDavid Roman <davidroman96@gmail.com>
Thu, 14 Jun 2018 20:07:46 +0000 (22:07 +0200)
committerMichał Górny <mgorny@gentoo.org>
Tue, 7 Aug 2018 15:09:05 +0000 (17:09 +0200)
Closes: https://bugs.gentoo.org/643634
Closes: https://github.com/gentoo/gentoo/pull/9223

net-p2p/go-ipfs-bin/files/ipfs.confd [new file with mode: 0644]
net-p2p/go-ipfs-bin/files/ipfs.init [new file with mode: 0644]
net-p2p/go-ipfs-bin/files/ipfs.service [new file with mode: 0644]
net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.15-r1.ebuild [moved from net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.15.ebuild with 57% similarity]

diff --git a/net-p2p/go-ipfs-bin/files/ipfs.confd b/net-p2p/go-ipfs-bin/files/ipfs.confd
new file mode 100644 (file)
index 0000000..f1e8eb7
--- /dev/null
@@ -0,0 +1 @@
+IPFS_PATH=/var/lib/ipfs/.ipfs
diff --git a/net-p2p/go-ipfs-bin/files/ipfs.init b/net-p2p/go-ipfs-bin/files/ipfs.init
new file mode 100644 (file)
index 0000000..7b38cf4
--- /dev/null
@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+export IPFS_PATH=${IPFS_PATH:-/var/lib/ipfs/.ipfs}
+
+pidfile="/run/ipfs.pid"
+command="/usr/bin/ipfs"
+command_args="daemon --enable-gc --migrate"
+command_user="ipfs:ipfs"
+start_stop_daemon_args="--wait 1000 -b \
+                        -1 /var/log/ipfs/ipfs.log \
+                        -2 /var/log/ipfs/ipfs.log"
+
+depend() {
+       need net
+}
diff --git a/net-p2p/go-ipfs-bin/files/ipfs.service b/net-p2p/go-ipfs-bin/files/ipfs.service
new file mode 100644 (file)
index 0000000..189ace2
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=InterPlanetary File System
+After=network.target
+
+[Service]
+ExecStart=/usr/bin/ipfs daemon --enable-gc --migrate
+ExecStop=/usr/bin/ipfs shutdown
+Group=%i
+Restart=always
+Type=simple
+User=%i
+
+[Install]
+WantedBy=multi-user.target
similarity index 57%
rename from net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.15.ebuild
rename to net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.15-r1.ebuild
index c810e8c42f963cfe15650b9fad72933347990c16..ac64426705660aa80f585038140a5c539bd75bb0 100644 (file)
@@ -3,7 +3,7 @@
 
 EAPI=6
 
-inherit bash-completion-r1
+inherit bash-completion-r1 systemd user
 
 DESCRIPTION="Main implementation of IPFS"
 HOMEPAGE="https://ipfs.io/"
@@ -25,5 +25,23 @@ QA_PREBUILT="/usr/bin/ipfs"
 src_install() {
        dobin ipfs
 
+       systemd_dounit "${FILESDIR}/ipfs.service"
+       newinitd "${FILESDIR}/ipfs.init" ipfs
+       newconfd "${FILESDIR}/ipfs.confd" ipfs
+
        newbashcomp "${DISTDIR}/${P}.bash" "ipfs"
+       keepdir /var/log/ipfs
+}
+
+pkg_preinst() {
+       enewgroup ipfs
+       enewuser ipfs "" "" /var/lib/ipfs ipfs
+
+       fowners -R ipfs:ipfs /var/log/ipfs
+}
+
+pkg_postinst() {
+       elog 'To be able to use the ipfs service you will need to create the ipfs repository'
+       elog '(eg: su -s /bin/sh -c "ipfs init -e" ipfs)'
+       elog 'or change IPFS_PATH of /etc/conf.d/ipfs with another with proper permissions.'
 }