File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed
Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments