mirror of
https://github.com/get-aurora-dev/common.git
synced 2026-11-03 21:49:43 -09:00
40 lines
1 KiB
Bash
Executable file
40 lines
1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# SCRIPT VERSION
|
|
GROUP_SETUP_VER=2
|
|
GROUP_SETUP_VER_FILE="/etc/ublue/dx-groups"
|
|
GROUP_SETUP_VER_RAN=$(cat "$GROUP_SETUP_VER_FILE")
|
|
|
|
# make the directory if it doesn't exist
|
|
mkdir -p /etc/ublue
|
|
|
|
# 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
|
|
|
|
# Function to append a group entry to /etc/group
|
|
append_group() {
|
|
local group_name="$1"
|
|
if ! grep -q "^$group_name:" /etc/group; then
|
|
echo "Appending $group_name to /etc/group"
|
|
grep "^$group_name:" /usr/lib/group | tee -a /etc/group >/dev/null
|
|
fi
|
|
}
|
|
|
|
# Setup Groups
|
|
append_group docker
|
|
append_group incus-admin
|
|
append_group libvirt
|
|
|
|
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 libvirt $user
|
|
done
|
|
|
|
# Prevent future executions
|
|
echo "Writing state file"
|
|
echo "$GROUP_SETUP_VER" >"$GROUP_SETUP_VER_FILE"
|