Skip to content

Commit 0d1112f

Browse files
committed
feat: add bluefin libvirt groups setup
1 parent 7bfadce commit 0d1112f

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
#!/usr/bin/env bash
3+
4+
# SCRIPT VERSION
5+
GROUP_SETUP_VER=1
6+
GROUP_SETUP_VER_FILE="/etc/ublue/dx-groups"
7+
GROUP_SETUP_VER_RAN=$(cat "$GROUP_SETUP_VER_FILE")
8+
9+
# make the directory if it doesn't exist
10+
mkdir -p /etc/ublue
11+
12+
# Run script if updated
13+
if [[ -f $GROUP_SETUP_VER_FILE && "$GROUP_SETUP_VER" = "$GROUP_SETUP_VER_RAN" ]]; then
14+
echo "Group setup has already run. Exiting..."
15+
exit 0
16+
fi
17+
18+
# Function to append a group entry to /etc/group
19+
append_group() {
20+
local group_name="$1"
21+
if ! grep -q "^$group_name:" /etc/group; then
22+
echo "Appending $group_name to /etc/group"
23+
grep "^$group_name:" /usr/lib/group | tee -a /etc/group >/dev/null
24+
fi
25+
}
26+
27+
# Setup Groups
28+
append_group docker
29+
append_group incus-admin
30+
append_group libvirt
31+
32+
wheelarray=($(getent group wheel | cut -d ":" -f 4 | tr ',' '\n'))
33+
for user in $wheelarray; do
34+
usermod -aG docker $user
35+
usermod -aG incus-admin $user
36+
usermod -aG libvirt $user
37+
done
38+
39+
# Prevent future executions
40+
echo "Writing state file"
41+
echo "$GROUP_SETUP_VER" >"$GROUP_SETUP_VER_FILE"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Add wheel members to docker,and incus-admin groups
3+
4+
[Service]
5+
Type=oneshot
6+
ExecStart=/usr/bin/bluefin-dx-groups
7+
Restart=on-failure
8+
RestartSec=30
9+
StartLimitInterval=0
10+
11+
[Install]
12+
WantedBy=default.target

recipes/features/virtualization.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,18 @@ modules:
77
install:
88
packages:
99
- libvirt
10+
- libvirt-nss
1011
- ublue-os-libvirt-workarounds
1112
- cockpit-machines
13+
14+
- type: files
15+
files:
16+
- source: virtualization
17+
- dest: /
18+
19+
- type: systemd
20+
system:
21+
enable:
22+
- bluefin-dx-groups.service
1223

1324

0 commit comments

Comments
 (0)