Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dx): Add wheel users to docker,incus-admin,lxd,libvirt groups #775

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"