Skip to content

Commit

Permalink
Translate PREF_* to settings in global_prefs_override.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
MentalFS committed Feb 11, 2024
1 parent a0a876b commit 244c21a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ WORKDIR /var/lib/boinc-client
ENTRYPOINT ["/start"]
CMD ["boinc", "--allow_remote_gui_rpc"]
ENV ENV=/start \
CPU_SCHEDULING_PERIOD_MINUTES=60 \
CPU_USAGE_LIMIT=100 \
MAX_NCPUS_PCT=100 \
PREF_RUN_GPU_IF_USER_ACTIVE=1 \
PREF_RUN_IF_USER_ACTIVE=1 \
PREF_SUSPEND_CPU_USAGE=50 \
PREF_SUSPEND_IF_NO_RECENT_INPUT=0 \
HEALTHCHECK_PATTERN=EXECUTING
HEALTHCHECK --interval=5m CMD boinccmd --get_tasks | egrep -q "${HEALTHECK_PATTERN}" && exit 0 || exit 1

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ When the GUI RPC Port is routed, it is also possible to control the client remot

## Supported settings

| Environment Variable | Default | |
|---------------------------------|-------------|----------------------------------------------------------------------------------|
| `GUI_RPC_AUTH` | *empty* | The password for GUI RPC, empty means no password |
| `HOST_VENUE` | *empty* | Host venue type: `none`, `home`, `school` or `work` |
| `CPU_SCHEDULING_PERIOD_MINUTES` | *empty* | Switch between tasks/projects every X minutes |
| `CPU_USAGE_LIMIT` | `100` | Load percentage to use, *empty* uses website preferences |
| `MAX_NCPUS_PCT` | `100` | Percentage of CPU cores to use, *empty* uses website preferences |
| `GLOBAL_PREFERENCES_XML` | *empty* | XML tags to inject into `global_prefs_override.xml` |
| `HEALTHCHECK_PATTERN` | `EXECUTING` | Will make the conainer unhealthy when no task is executing. Set to `.` to avoid. |
| Environment Variable | Default | |
|---------------------------------|-------------|------------------------------------------------------------------------------------------------|
| `GUI_RPC_AUTH` | *empty* | The password for GUI RPC, empty means no password |
| `HOST_VENUE` | *empty* | Host venue type: `none`, `home`, `school` or `work` |
| `CPU_USAGE_LIMIT` | `100` | Load percentage to use, *empty* uses website preferences |
| `MAX_NCPUS_PCT` | `100` | Percentage of CPU cores to use, *empty* uses website preferences |
| `PREF_*` | *empty* | Variables starting with `PREF_` will be translated to a setting in `global_prefs_override.xml` |
| `GLOBAL_PREFERENCES_XML` | *empty* | Raw XML tags to inject into `global_prefs_override.xml` |
| `HEALTHCHECK_PATTERN` | `EXECUTING` | Will make the conainer unhealthy when no task is executing. Set to `.` to avoid. |

## Download

Expand Down
27 changes: 14 additions & 13 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ if [ "`whoami`"=="boinc" ]; then
# Setup environment
echo "${GUI_RPC_AUTH}" > /etc/boinc-client/gui_rpc_auth.cfg

cat > "/var/lib/boinc-client/global_prefs_override.xml" <<- END
<global_preferences>
${HOST_VENUE:+"<host_venue>$([ "${HOST_VENUE}" = "none" ] || echo "${HOST_VENUE}")</host_venue>"}
${CPU_SCHEDULING_PERIOD_MINUTES:+"<cpu_scheduling_period_minutes>${CPU_SCHEDULING_PERIOD_MINUTES}</cpu_scheduling_period_minutes>"}
${CPU_USAGE_LIMIT:+"<cpu_usage_limit>${CPU_USAGE_LIMIT}</cpu_usage_limit>"}
${MAX_NCPUS_PCT:+"<max_ncpus_pct>${MAX_NCPUS_PCT}</max_ncpus_pct>"}
<run_gpu_if_user_active>1</run_gpu_if_user_active>
<run_if_user_active>1</run_if_user_active>
<suspend_cpu_usage>50</suspend_cpu_usage>
<suspend_if_no_recent_input>0</suspend_if_no_recent_input>
${GLOBAL_PREFERENCES_XML}
</global_preferences>
END
[ -n "${CPU_SCHEDULING_PERIOD_MINUTES}" ] && export PREF_CPU_SCHEDULING_PERIOD_MINUTES="${CPU_SCHEDULING_PERIOD_MINUTES}"
[ -n "${CPU_USAGE_LIMIT}" ] && export PREF_CPU_USAGE_LIMIT="${CPU_USAGE_LIMIT}"
[ -n "${HOST_VENUE}" ] && export PREF_HOST_VENUE="${HOST_VENUE}"
[ -n "${MAX_NCPUS_PCT}" ] && export PREF_MAX_NCPUS_PCT="${MAX_NCPUS_PCT}"
PREFS_OVERRIDE_FILE="/var/lib/boinc-client/global_prefs_override.xml"
echo "<global_preferences>" > "${PREFS_OVERRIDE_FILE}"
env | egrep -o '^PREF_[^=]+' | while read PREF; do
KEY="$(echo "${PREF#PREF_}" | tr '[:upper:]' '[:lower:]')"
eval VALUE="\${$PREF}"
echo "<${KEY}>$([ "${VALUE}" = "none" ] || echo "${VALUE}")</${KEY}>" >> "${PREFS_OVERRIDE_FILE}"
done
[ -n "${GLOBAL_PREFERENCES_XML}" ] && echo "${GLOBAL_PREFERENCES_XML}" >> "${PREFS_OVERRIDE_FILE}"
echo "</global_preferences>" >> "${PREFS_OVERRIDE_FILE}"
echo "</global_preferences>" >> "${PREFS_OVERRIDE_FILE}"

cat > "/var/lib/boinc-client/.boinctui.cfg" <<- END
<boinctui_cfg>
Expand Down

0 comments on commit 244c21a

Please sign in to comment.