Gentoo Archives: gentoo-commits

From: "Tomas Chvatal (scarabeus)" <scarabeus@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sci-misc/boinc/files: boinc.init
Date: Fri, 24 Jul 2009 10:58:36
Message-Id: E1MUITx-0004Ri-Jz@stork.gentoo.org
1 scarabeus 09/07/24 10:58:33
2
3 Modified: boinc.init
4 Log:
5 Remove bashism in initscript. Per bug #278811. Thanks to Michał Górny for the patch.
6 (Portage version: 2.2_rc33/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.16 sci-misc/boinc/files/boinc.init
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sci-misc/boinc/files/boinc.init?rev=1.16&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sci-misc/boinc/files/boinc.init?rev=1.16&content-type=text/plain
13 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sci-misc/boinc/files/boinc.init?r1=1.15&r2=1.16
14
15 Index: boinc.init
16 ===================================================================
17 RCS file: /var/cvsroot/gentoo-x86/sci-misc/boinc/files/boinc.init,v
18 retrieving revision 1.15
19 retrieving revision 1.16
20 diff -u -r1.15 -r1.16
21 --- boinc.init 8 Jul 2009 09:00:32 -0000 1.15
22 +++ boinc.init 24 Jul 2009 10:58:33 -0000 1.16
23 @@ -9,31 +9,31 @@
24 }
25
26 create_work_directory() {
27 - if [[ ! -d ${RUNTIMEDIR} ]]; then
28 + if [ ! -d "${RUNTIMEDIR}" ]; then
29 einfo "Directory ${RUNTIMEDIR} not existing, creating now."
30 - mkdir ${RUNTIMEDIR}
31 - chown ${USER}:${GROUP} ${RUNTIMEDIR}
32 - if [[ ! -d ${RUNTIMEDIR} ]]; then
33 + mkdir "${RUNTIMEDIR}"
34 + chown "${USER}:${GROUP}" "${RUNTIMEDIR}"
35 + if [ ! -d "${RUNTIMEDIR}" ]; then
36 eeror "Directory ${RUNTIMEDIR} could not be created!"
37 return 1
38 fi
39 - ln -s /etc/ssl/certs/ca-certificates.crt ${RUNTIMEDIR}/ca-bundle.crt
40 + ln -s /etc/ssl/certs/ca-certificates.crt "${RUNTIMEDIR}"/ca-bundle.crt
41 fi
42 }
43
44 generate_logs() {
45 - if [[ ! -f ${LOGFILE} ]]; then
46 + if [ ! -f "${LOGFILE}" ]; then
47 einfo "No ${LOGFILE} around. Creating new..."
48 einfo "For good log rotation is great tool app-admin/logrotate"
49 - touch ${LOGFILE}
50 - chown ${USER}:${GROUP} ${LOGFILE}
51 + touch "${LOGFILE}"
52 + chown "${USER}:${GROUP}" "${LOGFILE}"
53 fi
54 }
55
56 cuda_check() {
57 - if [[ -f /opt/cuda/lib/libcudart.so ]]; then
58 + if [ -f /opt/cuda/lib/libcudart.so ]; then
59 # symlink wont harm :]
60 - ln -snf /opt/cuda/lib/libcudart.so ${RUNTIMEDIR}/libcudart.so
61 + ln -snf /opt/cuda/lib/libcudart.so "${RUNTIMEDIR}"/libcudart.so
62 fi
63 }
64
65 @@ -43,9 +43,9 @@
66 create_work_directory
67 cuda_check
68
69 - pushd ${RUNTIMEDIR} > /dev/null
70 + cd "${RUNTIMEDIR}"
71
72 - if [[ ! -f lockfile ]]; then
73 + if [ ! -f lockfile ]; then
74 einfo "File $RUNTIMEDIR/lockfile does not exist, assuming first run."
75 einfo "You need to setup an account on the BOINC project homepage beforehand!"
76 einfo "Go to http://boinc.berkeley.edu/ and locate your project."
77 @@ -58,36 +58,36 @@
78
79 generate_logs
80
81 - if [[ ${ALLOW_REMOTE_RPC} = "yes" ]]; then
82 + if [ "${ALLOW_REMOTE_RPC}" = "yes" ]; then
83 ARGS="${ARGS} -allow_remote_gui_rpc"
84 fi
85 -
86 +
87 # sys-apps/util-linux
88 CHRT="/usr/bin/chrt ${SCHED_PARAM}"
89
90 # check for baselayout version
91 - if [[ -n "${RC_UNAME}" ]]; then
92 - PARAMS="--background --stdout ${LOGFILE} --stderr ${LOGFILE} -- ${ARGS}"
93 + if [ -n "${RC_UNAME}" ]; then
94 + PARAMS="--background --stdout '${LOGFILE}' --stderr '${LOGFILE}' -- ${ARGS}"
95 else
96 - PARAMS="-- ${ARGS} >> ${LOGFILE} 2>&1 &"
97 + PARAMS="-- ${ARGS} >> '${LOGFILE}' 2>&1 &"
98 fi
99
100 eval ${CHRT} start-stop-daemon \
101 - --quiet --start --chdir ${RUNTIMEDIR} \
102 - --pidfile ${PIDFILE} \
103 + --quiet --start --chdir "${RUNTIMEDIR}" \
104 + --pidfile "${PIDFILE}" \
105 --make-pidfile \
106 - --exec ${BOINCBIN} --chuid ${USER}:${GROUP} \
107 - --nicelevel ${NICELEVEL} \
108 + --exec "${BOINCBIN}" --chuid "${USER}:${GROUP}" \
109 + --nicelevel "${NICELEVEL}" \
110 ${PARAMS}
111
112 RESULT=$?
113
114 - if [ "${CPU_SHARE}" -a -d /sys/kernel/uids ]; then
115 - BUID=`id -u ${USER}`
116 + if [ "${CPU_SHARE}" ] && [ -d /sys/kernel/uids ]; then
117 + BUID="$(id -u "${USER}")"
118 # It might take a moment for start-stop-daemon to chuid
119 - [[ -d /sys/kernel/uids/${BUID} ]] || sleep 5 # 5 was working always here
120 - if [[ -w /sys/kernel/uids/${BUID}/cpu_share ]]; then
121 - echo ${CPU_SHARE} > /sys/kernel/uids/${BUID}/cpu_share
122 + [ -d /sys/kernel/uids/"${BUID}" ] || sleep 5 # 5 was working always here
123 + if [ -w /sys/kernel/uids/"${BUID}"/cpu_share ]; then
124 + echo "${CPU_SHARE}" > /sys/kernel/uids/"${BUID}"/cpu_share
125 fi
126 fi
127
128 @@ -101,25 +101,24 @@
129 read key
130
131 RC_QUIET_STDOUT="yes" svc_status
132 - if [[ $? = 1 ]]; then
133 + if [ $? = 1 ]; then
134 svc_start
135 fi
136 ebegin "Attaching to project"
137 # we have to work in runtime directory
138 - pushd ${RUNTIMEDIR} > /dev/null
139 + cd "${RUNTIMEDIR}"
140 # boinc does not return 1 when it fails currently
141 - ${BOINCBIN} --chuid ${USER}:${GROUP} --attach_project ${url} ${key} &> /dev/null
142 - popd > /dev/null
143 + "${BOINCBIN}" --chuid "${USER}:${GROUP}" --attach_project "${url}" "${key}" &> /dev/null
144 eend $?
145
146 sleep 10
147 - tail ${LOGFILE}
148 + tail "${LOGFILE}"
149 }
150
151 stop() {
152 ebegin "Stopping BOINC"
153 - start-stop-daemon --stop --retry 3 --quiet --exec ${BOINCBIN}
154 - rm -f ${PIDFILE}
155 + start-stop-daemon --stop --retry 3 --quiet --exec "${BOINCBIN}"
156 + rm -f "${PIDFILE}"
157 eend $?
158 }