Gentoo Archives: gentoo-commits

From: "Anthony G. Basile (blueness)" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-p2p/datacoin-hp/files: datacoin.initd
Date: Tue, 25 Feb 2014 18:22:21
Message-Id: 20140225182217.0B9502004C@flycatcher.gentoo.org
1 blueness 14/02/25 18:22:16
2
3 Modified: datacoin.initd
4 Log:
5 Add imrpoved initd, bug #500602
6
7 (Portage version: 2.2.7/cvs/Linux x86_64, signed Manifest commit with key 0xF52D4BBA)
8
9 Revision Changes Path
10 1.2 net-p2p/datacoin-hp/files/datacoin.initd
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-p2p/datacoin-hp/files/datacoin.initd?rev=1.2&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-p2p/datacoin-hp/files/datacoin.initd?rev=1.2&content-type=text/plain
14 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-p2p/datacoin-hp/files/datacoin.initd?r1=1.1&r2=1.2
15
16 Index: datacoin.initd
17 ===================================================================
18 RCS file: /var/cvsroot/gentoo-x86/net-p2p/datacoin-hp/files/datacoin.initd,v
19 retrieving revision 1.1
20 retrieving revision 1.2
21 diff -u -r1.1 -r1.2
22 --- datacoin.initd 28 Dec 2013 16:15:40 -0000 1.1
23 +++ datacoin.initd 25 Feb 2014 18:22:16 -0000 1.2
24 @@ -1,104 +1,29 @@
25 #!/sbin/runscript
26 -# Distributed under the terms of the GNU General Public License, v2 or later
27 -
28 -VARDIR="/var/lib/datacoin"
29 -CONFFILE="${VARDIR}/.datacoin/datacoin.conf"
30 +# Copyright 1999-2014 Gentoo Foundation
31 +# Distributed under the terms of the GNU General Public License v2
32 +# $Header: /var/cvsroot/gentoo-x86/net-p2p/datacoin-hp/files/datacoin.initd,v 1.2 2014/02/25 18:22:16 blueness Exp $
33 +
34 +vardir="/var/lib/datacoin"
35 +conffile="${vardir}/.datacoin/datacoin.conf"
36 +datacoind_user="${DATACOIN_USER:-nobody:nobody}"
37 +
38 +description="Bitcoin crypto-currency wallet for automated services"
39 +pidfile="/run/${SVCNAME}.pid"
40 +command="/usr/bin/datacoind"
41 +command_args="${DATACOIN_OPTS}"
42 +command_background="true"
43 +start_stop_daemon_args="-u ${datacoind_user} -e HOME=${vardir} -N ${NICELEVEL:-0} -w 2000"
44
45 depend() {
46 need net
47 }
48
49 -checkconfig() {
50 - if [[ "${DATACOIN_USER}" == "" ]] ; then
51 - eerror "Please edit /etc/conf.d/datacoind"
52 - eerror "A user must be specified to run datacoind as that user."
53 - eerror "Modify USER to your needs (you may also add a group after a colon)"
54 - return 1
55 - fi
56 - if ! `getent passwd | cut -d ':' -f 1 | grep $( echo "${DATACOIN_USER}" | cut -d ':' -f 1 ) -sq` ; then
57 - eerror "Please edit /etc/conf.d/datacoind"
58 - eerror "Specified user must exist!"
59 - return 1
60 - fi
61 - if `echo "${DATACOIN_USER}" | grep ':' -sq` ; then
62 - if ! `cut -d ':' -f 1 /etc/group | grep $( echo "${DATACOIN_USER}" | cut -d ':' -f 2 ) -sq` ; then
63 - eerror "Please edit /etc/conf.d/datacoind"
64 - eerror "Specified group must exist!"
65 - return 1
66 - fi
67 - fi
68 - if ! grep -q '^rpcpassword=' "${CONFFILE}"; then
69 - eerror "Please edit `readlink -f ${CONFFILE}`"
70 +start_pre() {
71 + checkpath -f -o ${datacoind_user} -m 0400 ${conffile} || return 1
72 +
73 + if ! grep -q '^rpcpassword=' "${conffile}"; then
74 + eerror "Please edit `readlink -f ${conffile}`"
75 eerror "There must be at least a line assigning rpcpassword=something-secure"
76 return 1
77 fi
78 - if ! stat -Lc '%a' "${CONFFILE}" | grep -q '^[4567]00$'; then
79 - eerror "`readlink -f ${CONFFILE}` should not be readable by other users"
80 - return 1
81 - fi
82 - return 0
83 -}
84 -
85 -start() {
86 - checkconfig || return 1
87 - ebegin "Starting Datacoind daemon"
88 -
89 - pkg-config openrc
90 - if [ $? = 0 ]; then
91 - start_openrc
92 - else
93 - start_baselayout
94 - fi
95 -}
96 -
97 -stop() {
98 - ebegin "Stopping Datacoin daemon"
99 -
100 - pkg-config openrc
101 - if [ $? = 0 ]; then
102 - stop_openrc
103 - else
104 - stop_baselayout
105 - fi
106 -}
107 -
108 -start_openrc() {
109 - start-stop-daemon \
110 - --start --user "${DATACOIN_USER}" --name datacoind \
111 - --pidfile /var/run/datacoind.pid --make-pidfile \
112 - --env HOME="${VARDIR}" --exec /usr/bin/datacoind \
113 - --nicelevel "${NICELEVEL}" \
114 - --background \
115 - --wait 2000 \
116 - -- ${DATACOIN_OPTS}
117 - eend $?
118 -}
119 -
120 -stop_openrc() {
121 - start-stop-daemon --stop --user "${DATACOIN_USER}" \
122 - --name datacoind --pidfile /var/run/datacoind.pid \
123 - --wait 30000 \
124 - --progress
125 - eend $?
126 -}
127 -
128 -start_baselayout() {
129 - start-stop-daemon \
130 - --start --user "${DATACOIN_USER}" --name datacoind \
131 - --pidfile /var/run/datacoind.pid --make-pidfile \
132 - --env HOME="${VARDIR}" --exec /usr/bin/datacoind \
133 - --chuid "${DATACOIN_USER}" \
134 - --nicelevel "${NICELEVEL}" \
135 - --background \
136 - -- ${DATACOIN_OPTS}
137 - eend $?
138 -}
139 -
140 -stop_baselayout() {
141 - start-stop-daemon \
142 - --stop \
143 - --user "${DATACOIN_USER}" \
144 - --name datacoind \
145 - --pidfile /var/run/datacoind.pid
146 - eend $?
147 }