25 lines
628 B
Text
25 lines
628 B
Text
|
#!/usr/bin/env bash
|
||
|
|
||
|
# SCRIPT VERSION
|
||
|
GROUP_SETUP_VER=1
|
||
|
GROUP_SETUP_VER_FILE="/etc/azure/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 libvirt $user
|
||
|
done
|
||
|
|
||
|
# Prevent future executions
|
||
|
echo "Writing state file"
|
||
|
echo "$GROUP_SETUP_VER" > "$GROUP_SETUP_VER_FILE"
|