commit:     77700d6221afc3a293241b8547a9904be2bd434b
Author:     Sven Eden <yamakuzure <AT> gmx <DOT> net>
AuthorDate: Fri Apr 29 08:52:09 2016 +0000
Commit:     David Seifert <soap <AT> gentoo <DOT> org>
CommitDate: Wed May  4 22:00:03 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=77700d62

sci-misc/boinc: Upgraded init script

Gentoo-Bug: 574260

After hot-fixing bug 574260, the following fixes/additions, suggested
by Jan Chren were made:

- #!/sbin/runscript -> #!/sbin/openrc-run
- Variables from /etc/conf.d/boinc are checked, and empty variables
  are pre-filled with sane defaults.
- split start() to start_pre() and start()
- removed check_baselayout()
- replaced /etc/init.d/boinc with ${RC_SERVICE}
- replaced echo with einfo ""
- replaced ${SVCNAME} with ${RC_SVCNAME}
- removed unset for local vars

Package-Manager: portage-2.2.28

 sci-misc/boinc/Manifest         |  1 -
 sci-misc/boinc/files/boinc.init | 94 ++++++++++++++++++++++++++++++-----------
 2 files changed, 70 insertions(+), 25 deletions(-)

diff --git a/sci-misc/boinc/Manifest b/sci-misc/boinc/Manifest
index 01bb35e..4f1d78d 100644
--- a/sci-misc/boinc/Manifest
+++ b/sci-misc/boinc/Manifest
@@ -1,4 +1,3 @@
-DIST boinc-7.2.0.tar.xz 25138432 SHA256 
714ac3a10bec41afc224e8343f5bc221a488eefca4592dbc9ce4eea2c10cad5e SHA512 
4ee360c14117cf4bbc26dfb48682462cdd15ca04b16f40b76562c0f5fa1a4531775762a1ce1f59960b4d0166a5d429af1279199f5140d3e112c72361ad01c46e
 WHIRLPOOL 
3d41bf1f80d04aa9ec576da18bbb6a8078c98060bd6167dcf6a75fa34619fb95831695fb145a8f4400ec0d99a743f42539751667fcbc505fba7c747c0e0bedfd
 DIST boinc-7.2.42.tar.gz 45420832 SHA256 
c4e9c6aef80db15afa3617804f6cdbf15586865d260b242a06197681a8ac86e6 SHA512 
c702597b2469e40cdb1fe4d47ac7b808a2f5702d7199e8bc4f2e50ec7a1058057f4edc6baec9ff64b877da788a13bd74049348286c7cbc98a7f73232f25749d0
 WHIRLPOOL 
ddade063072bef0a9dfcba50ce3878c8d0318e8ed607af045e7c7561296742dd66612d68d013be627692a3dbf54296b02dbc50533cd1d0d4a6b2deb53c99305e
 DIST boinc-7.4.42.tar.gz 44075908 SHA256 
2656727628cae8b15c39e48e08e0521aae345dd1cf4674c6730150500b30145f SHA512 
6eabb130d38c55b551ce216afcb8b4a27d9755c4a20dfc30e7ab0c7e8ba5ab5af6995348ec5fee6b9711aa85f7fdbcef78b05894873d8780f20c9e29e17c8ad1
 WHIRLPOOL 
3b61de0a5a443d457ceda3c01bf824fa5d9a72c7e5d8e8da1bf35f1510a7d3fb72dbbf8ce329b2f8ca18c82afc16852df0cd047d4870b06537ddff473277d655
 DIST boinc-7.6.31.tar.gz 43534132 SHA256 
133490409d4a8513024253dd22ccf6ab26f210226db97f2021fd75eb79a27f08 SHA512 
b2f35e7446bf01f4557a0d3c18ccad49a3e71d72fd25d69ff2e023ac51b1293ce3a7066ca0959e35301d1d99fc66eabf11dd89845ac120326f27fcdfa30fcdeb
 WHIRLPOOL 
0d5de909dbe8a7f961d221f01e2ffc57bacc72fc91ac26bdf30fff73f4ce80c1b60f5a7e782da8b8cda222a23455275fd96f18b902c77c971aa86a4c4a010641

diff --git a/sci-misc/boinc/files/boinc.init b/sci-misc/boinc/files/boinc.init
index 6ed9041..1d78d0a 100644
--- a/sci-misc/boinc/files/boinc.init
+++ b/sci-misc/boinc/files/boinc.init
@@ -1,19 +1,21 @@
-#!/sbin/runscript
+#!/sbin/openrc-run
 # Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
 extra_started_commands="attach"
 
+
 depend() {
        # we can use dns and net, but we can also in most cases live without 
them
        use dns net ntp-client ntpd
 }
 
+
 create_work_directory() {
        if [ ! -d "${RUNTIMEDIR}" ]; then
-               einfo "Directory ${RUNTIMEDIR} not existing, creating now."
-               mkdir "${RUNTIMEDIR}"
+               einfo "Directory ${RUNTIMEDIR} does not exist, creating now."
+               mkdir -p "${RUNTIMEDIR}"
                if [ ! -d "${RUNTIMEDIR}" ]; then
                        eeror "Directory ${RUNTIMEDIR} could not be created!"
                        return 1
@@ -22,8 +24,11 @@ create_work_directory() {
        if [ ! -e "${RUNTIMEDIR}"/ca-bundle.crt ] ; then
                ln -s /etc/ssl/certs/ca-certificates.crt 
"${RUNTIMEDIR}"/ca-bundle.crt
        fi
+
+       return 0
 }
 
+
 cuda_check() {
        if [ -f /opt/cuda/lib/libcudart.so ]; then
                # symlink wont harm :]
@@ -31,15 +36,42 @@ cuda_check() {
        fi
 }
 
-check_baselayout() {
-       if [ "${RC_VERSION:-0}" = "0" ]; then
-               eerror "This script cannot be used for baselayout-1."
+
+env_check() {
+       # Make sure the configuration is sane
+       ${USER:="boinc"}
+       ${GROUP:="boinc"}
+       ${RUNTIMEDIR:="/var/lib/boinc"}
+       ${BOINCBIN:="$(which boinc_client)"}
+       ${ALLOW_REMOTE_RPC:="yes"}
+       ${NICELEVEL:="19"}
+       # ARGS is not checked, it could have been explicitly set
+       # to be empty by the user.
+
+       # If the client was not found (how?) something is seriously wrong
+       if [ ! -x "$BOINCBIN" ] ; then
+               eerror "No boinc_client found!"
                return 1
        fi
+
+       return 0
 }
 
-start() {
-       check_baselayout || return 1
+
+need_passwd_arg() {
+       local vers=$(${BOINCBIN} --version | cut -d '.' --output-delimiter='' 
-f 1,2)
+       [ -z "$vers" ] && vers=0
+       [ $vers -lt 74 ] && return 0
+
+       # From version 7.4 on, the default is to read
+       # gui_rpc_auth.cfg for the password.
+
+       return 1
+}
+
+
+start_pre() {
+       env_check || return 1
        create_work_directory || return 1
        cuda_check
 
@@ -50,24 +82,36 @@ start() {
                einfo "File \"${RUNTIMEDIR}/lockfile\" does not exist, assuming 
first run."
                einfo "You need to setup an account on the BOINC project 
homepage beforehand!"
                einfo "Go to http://boinc.berkeley.edu/ and locate your 
project."
-               einfo "Then either run /etc/init.d/boinc attach or connect with 
a gui client"
+               einfo "Then either run ${RC_SERVICE} attach or connect with a 
gui client"
                einfo "and attach to a project with that."
-               echo
+               einfo ""
                ewarn "Note that for attaching to some project you need your 
network up and running."
                ewarn "network is needed only for jobs fetching afterwards"
        fi
 
+       return 0
+}
+
+
+start() {
        if [ "${ALLOW_REMOTE_RPC}" = "yes" ]; then
                ARGS="${ARGS} --allow_remote_gui_rpc"
        fi
 
-       ebegin "Starting ${SVCNAME}"
-       start-stop-daemon -S -N ${NICELEVEL} -u ${USER} -q -x "${BOINCBIN}" -- 
${ARGS} --daemon --dir "${RUNTIMEDIR}" --redirectio
+       ARGS="${ARGS} --daemon --dir "${RUNTIMEDIR}" --redirectio"
+
+       ebegin "Starting ${RC_SVCNAME}"
+       start-stop-daemon -S -N ${NICELEVEL} -u ${USER} -q -x "${BOINCBIN}" -- 
${ARGS}
        eend $?
 }
 
+
 attach() {
-       local password url key
+       local password=""
+       local url=""
+       local key=""
+
+       env_check || return 1
 
        einfo "If you cant find your account key just try to obtain it by 
using:"
        einfo "    boinccmd --passwd PASSWORD_FROM_GUI_RPC_AUTH 
--lookup_account URL EMAIL PASSWORD"
@@ -81,26 +125,28 @@ attach() {
                "${RC_SERVICE}" start
        fi
 
-       password=$(cat "${RUNTIMEDIR}/gui_rpc_auth.cfg")
+       if need_passwd_arg; then
+               password="--passwd \"$(cat "${RUNTIMEDIR}/gui_rpc_auth.cfg")\""
+       fi
 
-       ebegin "${SVCNAME}: Attaching to project"
-       start-stop-daemon -u ${USER} -q -x boinccmd -- --passwd "${password}" 
--project_attach ${url} ${key}
+       ebegin "${RC_SVCNAME}: Attaching to project"
+       start-stop-daemon -u ${USER} -q -d "${RUNTIMEDIR}" -x boinccmd -- 
${password} --project_attach ${url} ${key}
        eend $?
 
-       unset password url key
-
        sleep 10
        tail "${RUNTIMEDIR}/stdoutdae.txt"
 }
 
 stop() {
-       local password
+       local password=""
 
-       password=$(cat "${RUNTIMEDIR}/gui_rpc_auth.cfg")
+       env_check || return 1
 
-       ebegin "Stopping ${SVCNAME}"
-       start-stop-daemon -u ${USER} -q -x boinccmd -- --passwd "${password}" 
--quit
-       eend $?
+       if need_passwd_arg; then
+               password="--passwd \"$(cat "${RUNTIMEDIR}/gui_rpc_auth.cfg")\""
+       fi
 
-       unset password
+       ebegin "Stopping ${RC_SVCNAME}"
+       start-stop-daemon -u ${USER} -q -d "${RUNTIMEDIR}" -x boinccmd -- 
${password} --quit
+       eend $?
 }

Reply via email to