sci-misc/boinc: Add suspend/resume to boinc init script, fix null byte input.
authorSven Eden <yamakuzure@gmx.net>
Sat, 12 Nov 2016 15:23:43 +0000 (16:23 +0100)
committerDavid Seifert <soap@gentoo.org>
Sat, 12 Nov 2016 15:39:11 +0000 (16:39 +0100)
Gentoo-Bug: 493476

Enable users to suspend/resume all projects without having to start
and use the manager GUI.

Gentoo-Bug: 584386 (partly)

After upgrading to the current app-shells/bash-4.4 the stop command
provokes the following warning:

"command substitution: ignored null byte in input"

This happens due to the usage of "cut" with --output-delimiter=''.
Obviously "cut" puts a null byte out if the delimiter was set to
nothing. (Checked with hexdump, it does.)

The fix is to use "tr -d ." to concatenate the version numbers, and
then to compare against an "expr substr".

Package-Manager: portage-2.3.2
Closes: https://github.com/gentoo/gentoo/pull/2768

Signed-off-by: David Seifert <soap@gentoo.org>
sci-misc/boinc/files/boinc.init

index e20c8dfe423fe367b943d2d10d21c6dd44f9aa74..07b8b80c411ccb30e17131fc1867990567d39bf6 100644 (file)
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-extra_started_commands="attach"
+extra_started_commands="attach resume suspend"
 
 
 depend() {
@@ -59,9 +59,9 @@ env_check() {
 
 
 need_passwd_arg() {
-       local vers=$(${BOINCBIN} --version | cut -d '.' --output-delimiter='' -f 1,2)
-       [ -z "$vers" ] && vers=0
-       [ $vers -lt 74 ] && return 0
+       local vers=$(${BOINCBIN} --version | tr -d .)
+       [ -z "$vers" ] && vers="00"
+       [ $(expr substr "$vers" 1 2) -lt 74 ] && return 0
 
        # From version 7.4 on, the default is to read
        # gui_rpc_auth.cfg for the password.
@@ -151,3 +151,17 @@ stop() {
        start-stop-daemon -u ${USER} -q -d "${RUNTIMEDIR}" -x boinccmd -- ${password} --quit
        eend $?
 }
+
+
+resume() {
+       for url in $(boinccmd --get_project_status | sed -n 's/\s*master URL: //p'); do
+               boinccmd --project ${url} resume
+       done
+}
+
+
+suspend() {
+       for url in $(boinccmd --get_project_status | sed -n 's/\s*master URL: //p'); do
+               boinccmd --project ${url} suspend;
+       done
+}