Skip to content

Commit

Permalink
net-p2p/go-ipfs-bin: add services for openrc & systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
stkw0 committed Jul 14, 2018
1 parent ec359b7 commit 9a7758b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions net-p2p/go-ipfs-bin/files/ipfs.confd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IPFS_PATH=/var/lib/ipfs/.ipfs
27 changes: 27 additions & 0 deletions net-p2p/go-ipfs-bin/files/ipfs.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/sbin/openrc-run
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

IPFS_PATH=${IPFS_PATH:-/var/lib/ipfs/.ipfs}

depend() {
need net
}

start() {
ebegin "Starting ipfs"
start-stop-daemon --wait 1000 -b --start -u ipfs \
-e IPFS_PATH=${IPFS_PATH} \
--make-pidfile --pidfile /run/ipfs.pid \
--exec /usr/bin/ipfs \
-- daemon --enable-gc --migrate
eend $?
}

stop() {
ebegin "Stopping ipfs"
start-stop-daemon --stop --exec /usr/bin/ipfs \
--pidfile /run/ipfs.pid \
-- shutdown
eend $?
}
14 changes: 14 additions & 0 deletions net-p2p/go-ipfs-bin/files/ipfs.service
Original file line number Diff line number Diff line change
@@ -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
15 changes: 14 additions & 1 deletion net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.15.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand All @@ -25,5 +25,18 @@ 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"
}

pkg_postinst() {
enewgroup ipfs
enewuser ipfs "" "" /var/lib/ipfs ipfs

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.'
}

0 comments on commit 9a7758b

Please sign in to comment.