-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostinstall.sh
More file actions
executable file
·54 lines (43 loc) · 1.31 KB
/
postinstall.sh
File metadata and controls
executable file
·54 lines (43 loc) · 1.31 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
#!/usr/bin/env bash
set -e
GROUP_NAME="gpuman"
DATA_DIR="/var/lib/gpuman"
echo "[gpuman] Running post-install setup..."
# Must be run as root
if [[ "$EUID" -ne 0 ]]; then
echo "[gpuman] ERROR: postinstall must be run as root"
exit 1
fi
# -------------------------------
# Create group if it doesn't exist
# -------------------------------
if ! getent group "${GROUP_NAME}" > /dev/null; then
echo "[gpuman] Creating group: ${GROUP_NAME}"
groupadd --system "${GROUP_NAME}"
else
echo "[gpuman] Group ${GROUP_NAME} already exists"
fi
# -------------------------------
# Create data directory
# -------------------------------
echo "[gpuman] Ensuring ${DATA_DIR} exists"
mkdir -p "${DATA_DIR}"
# -------------------------------
# Set ownership & permissions
# -------------------------------
echo "[gpuman] Setting ownership and permissions on ${DATA_DIR}"
chown root:"${GROUP_NAME}" "${DATA_DIR}"
chmod 2775 "${DATA_DIR}"
# -------------------------------
# Final instructions
# -------------------------------
cat <<EOF
[gpuman] Installation complete.
To enable and start the daemon:
sudo systemctl daemon-reload
sudo systemctl enable gpumand.service
sudo systemctl start gpumand.service
To allow a user to run the gpuman CLI without sudo:
sudo usermod -aG ${GROUP_NAME} <username>
(log out and log back in)
EOF