Lines 9-39
depend() {
Link Here
|
9 |
} |
9 |
} |
10 |
|
10 |
|
11 |
create_work_directory() { |
11 |
create_work_directory() { |
12 |
if [[ ! -d ${RUNTIMEDIR} ]]; then |
12 |
if [ ! -d "${RUNTIMEDIR}" ]; then |
13 |
einfo "Directory ${RUNTIMEDIR} not existing, creating now." |
13 |
einfo "Directory ${RUNTIMEDIR} not existing, creating now." |
14 |
mkdir ${RUNTIMEDIR} |
14 |
mkdir "${RUNTIMEDIR}" |
15 |
chown ${USER}:${GROUP} ${RUNTIMEDIR} |
15 |
chown "${USER}:${GROUP}" "${RUNTIMEDIR}" |
16 |
if [[ ! -d ${RUNTIMEDIR} ]]; then |
16 |
if [ ! -d "${RUNTIMEDIR}" ]; then |
17 |
eeror "Directory ${RUNTIMEDIR} could not be created!" |
17 |
eeror "Directory ${RUNTIMEDIR} could not be created!" |
18 |
return 1 |
18 |
return 1 |
19 |
fi |
19 |
fi |
20 |
ln -s /etc/ssl/certs/ca-certificates.crt ${RUNTIMEDIR}/ca-bundle.crt |
20 |
ln -s /etc/ssl/certs/ca-certificates.crt "${RUNTIMEDIR}"/ca-bundle.crt |
21 |
fi |
21 |
fi |
22 |
} |
22 |
} |
23 |
|
23 |
|
24 |
generate_logs() { |
24 |
generate_logs() { |
25 |
if [[ ! -f ${LOGFILE} ]]; then |
25 |
if [ ! -f "${LOGFILE}" ]; then |
26 |
einfo "No ${LOGFILE} around. Creating new..." |
26 |
einfo "No ${LOGFILE} around. Creating new..." |
27 |
einfo "For good log rotation is great tool app-admin/logrotate" |
27 |
einfo "For good log rotation is great tool app-admin/logrotate" |
28 |
touch ${LOGFILE} |
28 |
touch "${LOGFILE}" |
29 |
chown ${USER}:${GROUP} ${LOGFILE} |
29 |
chown "${USER}:${GROUP}" "${LOGFILE}" |
30 |
fi |
30 |
fi |
31 |
} |
31 |
} |
32 |
|
32 |
|
33 |
cuda_check() { |
33 |
cuda_check() { |
34 |
if [[ -f /opt/cuda/lib/libcudart.so ]]; then |
34 |
if [ -f /opt/cuda/lib/libcudart.so ]; then |
35 |
# symlink wont harm :] |
35 |
# symlink wont harm :] |
36 |
ln -snf /opt/cuda/lib/libcudart.so ${RUNTIMEDIR}/libcudart.so |
36 |
ln -snf /opt/cuda/lib/libcudart.so "${RUNTIMEDIR}"/libcudart.so |
37 |
fi |
37 |
fi |
38 |
} |
38 |
} |
39 |
|
39 |
|
Lines 43-51
start() {
Link Here
|
43 |
create_work_directory |
43 |
create_work_directory |
44 |
cuda_check |
44 |
cuda_check |
45 |
|
45 |
|
46 |
pushd ${RUNTIMEDIR} > /dev/null |
46 |
cd "${RUNTIMEDIR}" |
47 |
|
47 |
|
48 |
if [[ ! -f lockfile ]]; then |
48 |
if [ ! -f lockfile ]; then |
49 |
einfo "File $RUNTIMEDIR/lockfile does not exist, assuming first run." |
49 |
einfo "File $RUNTIMEDIR/lockfile does not exist, assuming first run." |
50 |
einfo "You need to setup an account on the BOINC project homepage beforehand!" |
50 |
einfo "You need to setup an account on the BOINC project homepage beforehand!" |
51 |
einfo "Go to http://boinc.berkeley.edu/ and locate your project." |
51 |
einfo "Go to http://boinc.berkeley.edu/ and locate your project." |
Lines 58-93
start() {
Link Here
|
58 |
|
58 |
|
59 |
generate_logs |
59 |
generate_logs |
60 |
|
60 |
|
61 |
if [[ ${ALLOW_REMOTE_RPC} = "yes" ]]; then |
61 |
if [ "${ALLOW_REMOTE_RPC}" = "yes" ]; then |
62 |
ARGS="${ARGS} -allow_remote_gui_rpc" |
62 |
ARGS="${ARGS} -allow_remote_gui_rpc" |
63 |
fi |
63 |
fi |
64 |
|
64 |
|
65 |
# sys-apps/util-linux |
65 |
# sys-apps/util-linux |
66 |
CHRT="/usr/bin/chrt ${SCHED_PARAM}" |
66 |
CHRT="/usr/bin/chrt ${SCHED_PARAM}" |
67 |
|
67 |
|
68 |
# check for baselayout version |
68 |
# check for baselayout version |
69 |
if [[ -n "${RC_UNAME}" ]]; then |
69 |
if [ -n "${RC_UNAME}" ]; then |
70 |
PARAMS="--background --stdout ${LOGFILE} --stderr ${LOGFILE} -- ${ARGS}" |
70 |
PARAMS="--background --stdout '${LOGFILE}' --stderr '${LOGFILE}' -- ${ARGS}" |
71 |
else |
71 |
else |
72 |
PARAMS="-- ${ARGS} >> ${LOGFILE} 2>&1 &" |
72 |
PARAMS="-- ${ARGS} >> '${LOGFILE}' 2>&1 &" |
73 |
fi |
73 |
fi |
74 |
|
74 |
|
75 |
eval ${CHRT} start-stop-daemon \ |
75 |
eval ${CHRT} start-stop-daemon \ |
76 |
--quiet --start --chdir ${RUNTIMEDIR} \ |
76 |
--quiet --start --chdir "${RUNTIMEDIR}" \ |
77 |
--pidfile ${PIDFILE} \ |
77 |
--pidfile "${PIDFILE}" \ |
78 |
--make-pidfile \ |
78 |
--make-pidfile \ |
79 |
--exec ${BOINCBIN} --chuid ${USER}:${GROUP} \ |
79 |
--exec "${BOINCBIN}" --chuid "${USER}:${GROUP}" \ |
80 |
--nicelevel ${NICELEVEL} \ |
80 |
--nicelevel "${NICELEVEL}" \ |
81 |
${PARAMS} |
81 |
${PARAMS} |
82 |
|
82 |
|
83 |
RESULT=$? |
83 |
RESULT=$? |
84 |
|
84 |
|
85 |
if [ "${CPU_SHARE}" -a -d /sys/kernel/uids ]; then |
85 |
if [ "${CPU_SHARE}" ] && [ -d /sys/kernel/uids ]; then |
86 |
BUID=`id -u ${USER}` |
86 |
BUID="$(id -u "${USER}")" |
87 |
# It might take a moment for start-stop-daemon to chuid |
87 |
# It might take a moment for start-stop-daemon to chuid |
88 |
[[ -d /sys/kernel/uids/${BUID} ]] || sleep 5 # 5 was working always here |
88 |
[ -d /sys/kernel/uids/"${BUID}" ] || sleep 5 # 5 was working always here |
89 |
if [[ -w /sys/kernel/uids/${BUID}/cpu_share ]]; then |
89 |
if [ -w /sys/kernel/uids/"${BUID}"/cpu_share ]; then |
90 |
echo ${CPU_SHARE} > /sys/kernel/uids/${BUID}/cpu_share |
90 |
echo "${CPU_SHARE}" > /sys/kernel/uids/"${BUID}"/cpu_share |
91 |
fi |
91 |
fi |
92 |
fi |
92 |
fi |
93 |
|
93 |
|
Lines 101-125
attach() {
Link Here
|
101 |
read key |
101 |
read key |
102 |
|
102 |
|
103 |
RC_QUIET_STDOUT="yes" svc_status |
103 |
RC_QUIET_STDOUT="yes" svc_status |
104 |
if [[ $? = 1 ]]; then |
104 |
if [ $? = 1 ]; then |
105 |
svc_start |
105 |
svc_start |
106 |
fi |
106 |
fi |
107 |
ebegin "Attaching to project" |
107 |
ebegin "Attaching to project" |
108 |
# we have to work in runtime directory |
108 |
# we have to work in runtime directory |
109 |
pushd ${RUNTIMEDIR} > /dev/null |
109 |
cd "${RUNTIMEDIR}" |
110 |
# boinc does not return 1 when it fails currently |
110 |
# boinc does not return 1 when it fails currently |
111 |
${BOINCBIN} --chuid ${USER}:${GROUP} --attach_project ${url} ${key} &> /dev/null |
111 |
"${BOINCBIN}" --chuid "${USER}:${GROUP}" --attach_project "${url}" "${key}" &> /dev/null |
112 |
popd > /dev/null |
|
|
113 |
eend $? |
112 |
eend $? |
114 |
|
113 |
|
115 |
sleep 10 |
114 |
sleep 10 |
116 |
tail ${LOGFILE} |
115 |
tail "${LOGFILE}" |
117 |
} |
116 |
} |
118 |
|
117 |
|
119 |
stop() { |
118 |
stop() { |
120 |
ebegin "Stopping BOINC" |
119 |
ebegin "Stopping BOINC" |
121 |
start-stop-daemon --stop --retry 3 --quiet --exec ${BOINCBIN} |
120 |
start-stop-daemon --stop --retry 3 --quiet --exec "${BOINCBIN}" |
122 |
rm -f ${PIDFILE} |
121 |
rm -f "${PIDFILE}" |
123 |
eend $? |
122 |
eend $? |
124 |
} |
123 |
} |
125 |
|
124 |
|