Skip to content

Commit 8c4ce13

Browse files
committed
Remove duplicate code for cgroup/grub instruction
(cherry picked from commit f6f5736)
1 parent 95a8253 commit 8c4ce13

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

judge/create_cgroups.in

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,31 @@
99
JUDGEHOSTUSER=@DOMJUDGE_USER@
1010
CGROUPBASE=@judgehost_cgroupdir@
1111

12+
print_cgroup_instruction () {
13+
echo ""
14+
echo "To fix this, please make the following changes:
15+
1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT.
16+
On modern distros (e.g. Debian bullseye and Ubuntu Jammy Jellyfish) which have cgroup v2 enabled by default,
17+
you need to add 'systemd.unified_cgroup_hierarchy=0' as well.
18+
2. Run update-grub
19+
3. Reboot" >&2
20+
exit 1
21+
}
22+
1223
for i in cpuset memory; do
1324
mkdir -p $CGROUPBASE/$i
1425
if [ ! -d $CGROUPBASE/$i/ ]; then
1526
if ! mount -t cgroup -o$i $i $CGROUPBASE/$i/; then
16-
echo "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue.
17-
18-
To fix this, please make the following changes:
19-
1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT
20-
On modern distros (e.g. Debian bullseye and Ubuntu Jammy Jellyfish) which have cgroup v2 enabled by default,
21-
you need to add 'systemd.unified_cgroup_hierarchy=0' as well.
22-
2. Run update-grub
23-
3. Reboot" >&2
24-
exit 1
27+
echo "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue."
28+
print_cgroup_instruction
2529
fi
2630
fi
2731
mkdir -p $CGROUPBASE/$i/domjudge
2832
done
2933

3034
if [ ! -f $CGROUPBASE/memory/memory.limit_in_bytes ] || [ ! -f $CGROUPBASE/memory/memory.memsw.limit_in_bytes ]; then
31-
echo "Error: cgroup support missing memory features in running kernel. Unable to continue.
32-
33-
To fix this, please make the following changes:
34-
1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT.
35-
On modern distros (e.g. Debian bullseye and Ubuntu Jammy Jellyfish) which have cgroup v2 enabled by default,
36-
you need to add 'systemd.unified_cgroup_hierarchy=0' as well.
37-
2. Run update-grub
38-
3. Reboot" >&2
39-
exit 1
35+
echo "Error: cgroup support missing memory features in running kernel. Unable to continue."
36+
print_cgroup_instruction
4037
fi
4138

4239
chown -R $JUDGEHOSTUSER $CGROUPBASE/*/domjudge

0 commit comments

Comments
 (0)