-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart
executable file
·116 lines (110 loc) · 5.02 KB
/
start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
if [ "`whoami`" = "boinc" ]; then
# Remove symbolic links
test -L "/var/lib/boinc-client/cc_config.xml" && rm -f "/var/lib/boinc-client/cc_config.xml"
test -L "/var/lib/boinc-client/global_prefs_override.xml" && rm -f "/var/lib/boinc-client/global_prefs_override.xml"
test -L "/var/lib/boinc-client/gui_rpc_auth.cfg" && rm -f "/var/lib/boinc-client/gui_rpc_auth.cfg"
test -L "/var/lib/boinc-client/remote_hosts.cfg" && rm -f "/var/lib/boinc-client/remote_hosts.cfg"
# Setup environment
echo "${GUI_RPC_AUTH}" > /var/lib/boinc-client/gui_rpc_auth.cfg
sed '/^[[:space:]]*$/d' > "/var/lib/boinc-client/global_prefs_override.xml" <<- END
<global_preferences>
${HOST_VENUE:+"<host_venue>$([ "${HOST_VENUE}" = "none" ] || echo "${HOST_VENUE}")</host_venue>"}
<run_if_user_active>1</run_if_user_active>
<run_gpu_if_user_active>1</run_gpu_if_user_active>
${MAX_NCPUS_PCT:+"<max_ncpus_pct>${MAX_NCPUS_PCT}</max_ncpus_pct>"}
${CPU_USAGE_LIMIT:+"<cpu_usage_limit>${CPU_USAGE_LIMIT}</cpu_usage_limit>"}
${SUSPEND_CPU_USAGE:+"<suspend_cpu_usage>${SUSPEND_CPU_USAGE}</suspend_cpu_usage>"}
${RAM_MAX_USED_PCT:+"<ram_max_used_busy_pct>${RAM_MAX_USED_PCT}</ram_max_used_busy_pct>"}
${MAX_NCPUS_PCT:+"<niu_max_ncpus_pct>${MAX_NCPUS_PCT}</niu_max_ncpus_pct>"}
${CPU_USAGE_LIMIT:+"<niu_cpu_usage_limit>${CPU_USAGE_LIMIT}</niu_cpu_usage_limit>"}
${SUSPEND_CPU_USAGE:+"<niu_suspend_cpu_usage>${SUSPEND_CPU_USAGE}</niu_suspend_cpu_usage>"}
${RAM_MAX_USED_PCT:+"<ram_max_used_idle_pct>${RAM_MAX_USED_PCT}</ram_max_used_idle_pct>"}
<suspend_if_no_recent_input>0</suspend_if_no_recent_input>
${CPU_SCHEDULING_PERIOD_MINUTES:+"<cpu_scheduling_period_minutes>${CPU_SCHEDULING_PERIOD_MINUTES}</cpu_scheduling_period_minutes>"}
${DISK_INTERVAL:+"<disk_interval>${DISK_INTERVAL}</disk_interval>"}
${LEAVE_APPS_IN_MEMORY:+"<leave_apps_in_memory>${LEAVE_APPS_IN_MEMORY}</leave_apps_in_memory>"}
${WORK_BUF_MIN_DAYS:+"<work_buf_min_days>${WORK_BUF_MIN_DAYS}</work_buf_min_days>"}
${WORK_BUF_ADDITIONAL_DAYS:+"<work_buf_additional_days>${WORK_BUF_ADDITIONAL_DAYS}</work_buf_additional_days>"}
${DISK_MAX_USED_GB:+"<disk_max_used_gb>${DISK_MAX_USED_GB}</disk_max_used_gb>"}
${DISK_MIN_FREE_GB:+"<disk_min_free_gb>${DISK_MIN_FREE_GB}</disk_min_free_gb>"}
${DISK_MAX_USED_PCT:+"<disk_max_used_pct>${DISK_MAX_USED_PCT}</disk_max_used_pct>"}
</global_preferences>
END
sed '/^[[:space:]]*$/d' > "/var/lib/boinc-client/cc_config.xml" <<- END
<cc_config>
<options>
<allow_remote_gui_rpc>1</allow_remote_gui_rpc>
${DEVICE_NAME:+"<device_name>${DEVICE_NAME}</device_name>"}
<dont_use_vbox>1</dont_use_vbox>
${EXIT_WHEN_IDLE:+"<exit_when_idle>${EXIT_WHEN_IDLE}</exit_when_idle>"}
${FETCH_MINIMAL_WORK:+"<fetch_minimal_work>${FETCH_MINIMAL_WORK}</fetch_minimal_work>"}
${FETCH_ON_UPDATE:+"<fetch_on_update>${FETCH_ON_UPDATE}</fetch_on_update>"}
${PROCESS_PRIORITY:+"<process_priority>${PROCESS_PRIORITY}</process_priority>"}
${PROCESS_PRIORITY_SPECIAL:+"<process_priority_special>${PROCESS_PRIORITY_SPECIAL}</process_priority_special>"}
${REC_HALF_LIFE_DAYS:+"<rec_half_life_days>${REC_HALF_LIFE_DAYS}</rec_half_life_days>"}
<use_all_gpus>1</use_all_gpus>
${START_DELAY:+"<start_delay>${START_DELAY}</start_delay>"}
${ZERO_DEBT:+"<zero_debt>${ZERO_DEBT}</zero_debt>"}
</options>
<log_flags>
${LOG_CPU_SCHED:+"<cpu_sched>${LOG_CPU_SCHED}</cpu_sched>"}
<file_xfer>1</file_xfer>
<sched_ops>1</sched_ops>
<task>1</task>
${LOG_UNPARSED_XML:+"<unparsed_xml>${LOG_UNPARSED_XML}</unparsed_xml>"}
</log_flags>
</cc_config>
END
# Project-sepcific configuration
if [ -n "${MILKYWAY_NCPUS}" ]; then
mkdir -p /var/lib/boinc-client/projects/milkyway.cs.rpi.edu_milkyway
rm -f "/var/lib/boinc-client/projects/milkyway.cs.rpi.edu_milkyway/app_config.xml"
cat > "/var/lib/boinc-client/projects/milkyway.cs.rpi.edu_milkyway/app_config.xml" <<- END
<app_config>
<app_version>
<app_name>milkyway_nbody</app_name>
<plan_class>mt</plan_class>
<avg_ncpus>${MILKYWAY_NCPUS}</avg_ncpus>
<cmdline>--nthreads ${MILKYWAY_NCPUS}</cmdline>
</app_version>
<app_version>
<app_name>milkyway_nbody_orbit_fitting</app_name>
<plan_class>mt</plan_class>
<avg_ncpus>${MILKYWAY_NCPUS}</avg_ncpus>
<cmdline>--nthreads ${MILKYWAY_NCPUS}</cmdline>
</app_version>
</app_config>
END
fi
# tool setup
cat > "/var/lib/boinc-client/.boinctui.cfg" <<- END
<boinctui_cfg>
<server>
<host>localhost</host>
<pwd>${GUI_RPC_AUTH}</pwd>
<port>31416</port>
<hostid>${DEVICE_NAME:-"DOCKER"}</hostid>
</server>
<version>2.7.0</version>
<transparent_background>1</transparent_background>
</boinctui_cfg>
END
cp -rn /etc/skel/. /var/lib/boinc-client/
if [ ! -f "/var/lib/boinc-client/.vimrc" ]; then
cat > "/var/lib/boinc-client/.vimrc" <<- END
runtime! debian.vim
set mouse=a
map <Tab> :tabnext<CR>
map <S-Tab> :tabprevious<CR>
END
fi
if [ "$0" = "/bin/sh" ] && [ -z "$*" ]; then
# This appears on the Docker Desktop Exec tab
clear
boinctui
bash -l
exit
fi
fi
test -n "$*" && exec "$@"