-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoobe.sh
More file actions
executable file
·96 lines (83 loc) · 3.42 KB
/
Copy pathoobe.sh
File metadata and controls
executable file
·96 lines (83 loc) · 3.42 KB
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
#!/usr/bin/env bash
# This file is part of BOINC.
# https://boinc.berkeley.edu
# Copyright (C) 2026 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# BOINC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BOINC. If not, see <http://www.gnu.org/licenses/>.
set -ue
DEFAULT_UID='1000'
DEFAULT_USER='boinc'
echo "Creating default user account '$DEFAULT_USER'..."
/usr/sbin/useradd -m -u "$DEFAULT_UID" -c '' -s /bin/sh "$DEFAULT_USER"
echo "User account '$DEFAULT_USER' created"
echo "Updating package index..."
apt update
echo "Package index updated"
echo "Setting up certificates..."
apt install -y ca-certificates
update-ca-certificates
echo "Certificates setup complete"
echo "Fixing permissions..."
chmod 1777 /var/tmp
echo "Permissions fixed"
echo "Setting version..."
echo "version: 6" > /home/$DEFAULT_USER/version.txt
chown $DEFAULT_USER:$DEFAULT_USER /home/$DEFAULT_USER/version.txt
echo "Version set"
GPUS_JSON=/home/${DEFAULT_USER}/gpus.json
if [ -f /usr/lib/wsl/lib/libcuda.so ]; then
echo "Setting up NVIDIA Container Toolkit..."
apt install -y gnupg2 curl
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt update
apt install -y nvidia-container-toolkit
systemctl enable --now nvidia-cdi-refresh.path
systemctl enable --now nvidia-cdi-refresh.service
nvidia-ctk cdi generate --output=/var/run/cdi/nvidia.yaml
found=0
json="{\"gpus\":["
CUDA_TXT=/var/tmp/cuda.txt
/usr/lib/wsl/lib/nvidia-smi -L > ${CUDA_TXT}
echo "CUDA GPU(s) detected:"
while read -r line; do
if [[ "$line" =~ ^GPU[[:space:]]+([0-9]+):[[:space:]]*(.*)[[:space:]]+\(UUID: ]]; then
gpu_number="${BASH_REMATCH[1]}"
gpu_name="${BASH_REMATCH[2]}"
if [ "x$gpu_number" != "x" ] && [ "x$gpu_name" != "x" ]; then
echo "$gpu_number: $gpu_name"
if [ $found -eq 1 ]; then
json="$json,"
fi
json="$json{\"name\":\"nvidia\",\"has_cuda\":true,\"has_opencl\":false,\"gpu_name\":\"$gpu_name\",\"cuda_number\":$gpu_number,\"opencl_number\":null}"
found=1
fi
fi
done < ${CUDA_TXT}
rm -f ${CUDA_TXT}
json="$json]}"
if [ $found -eq 1 ]; then
echo $json > ${GPUS_JSON}
fi
echo "NVIDIA Container Toolkit setup complete"
else
echo "No CUDA GPU detected"
fi
if [ -f ${GPUS_JSON} ]; then
chown $DEFAULT_USER:$DEFAULT_USER ${GPUS_JSON}
fi
echo "Setting up podman..."
apt install -y podman iptables
echo $DEFAULT_USER:100000:65536 >/etc/subuid
echo $DEFAULT_USER:100000:65536 >/etc/subgid
echo "Podman setup complete"