Skip to content

Commit

Permalink
feat(dx): Add wheel users to docker,incus-admin,lxd,libvirt groups (u…
Browse files Browse the repository at this point in the history
  • Loading branch information
m2Giles authored Jan 2, 2024
1 parent e968ace commit 78bad33
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ RUN wget https://raw.githubusercontent.com/ahmetb/kubectx/master/kubectx -O /usr
RUN systemctl enable docker.socket && \
systemctl enable podman.socket && \
systemctl enable swtpm-workaround.service && \
systemctl enable bluefin-dx-groups.service && \
systemctl enable --global bluefin-dx-user-vscode.service && \
systemctl disable pmie.service && \
systemctl disable pmlogger.service
Expand Down
26 changes: 26 additions & 0 deletions dx/usr/bin/bluefin-dx-groups
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# SCRIPT VERSION
GROUP_SETUP_VER=1
GROUP_SETUP_VER_FILE="/etc/ublue/dx-groups"
GROUP_SETUP_VER_RAN=$(cat "$GROUP_SETUP_VER_FILE")

# Run script if updated
if [[ -f $GROUP_SETUP_VER_FILE && "$GROUP_SETUP_VER" = "$GROUP_SETUP_VER_RAN" ]]; then
echo "Group setup has already run. Exiting..."
exit 0
fi

# Setup Groups
wheelarray=($(getent group wheel | cut -d ":" -f 4 | tr ',' '\n'))
for user in $wheelarray
do
usermod -aG docker $user
usermod -aG incus-admin $user
usermod -aG lxd $user
usermod -aG libvirt $user
done

# Prevent future executions
echo "Writing state file"
echo "$GROUP_SETUP_VER" > "$GROUP_SETUP_VER_FILE"
12 changes: 12 additions & 0 deletions dx/usr/lib/systemd/system/bluefin-dx-groups.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Add wheel members to docker,incus-admin, and lxd groups

[Service]
Type=oneshot
ExecStart=/usr/bin/bluefin-dx-groups
Restart=on-failure
RestartSec=30
StartLimitInterval=0

[Install]
WantedBy=default.target
9 changes: 6 additions & 3 deletions just/custom.just
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ zsh:
sudo usermod $USER --shell /usr/bin/zsh
printf "${USER}'s shell is now %s." "$(cat /etc/passwd | grep ":$UID:" | cut '-d:' '-f7')"

# Configure Docker user permissions
docker:
# Configure docker,incus-admin,lxd,libvirt container manager permissions
dx-group:
sudo usermod -aG docker $USER
newgrp docker
sudo usermod -aG incus-admin $USER
sudo usermod -aG lxd $USER
sudo usermod -aG libvirt $USER
@echo "Logout to use docker, incus-admin, lxd, libvirt"

0 comments on commit 78bad33

Please sign in to comment.