Skip to content

Commit

Permalink
feat: system setup + groups setup
Browse files Browse the repository at this point in the history
  • Loading branch information
babariviere committed May 14, 2024
1 parent ce5f8d9 commit cd4b46a
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ cp /tmp/build/flatpak-setup.service /usr/lib/systemd/user/flatpak-setup.service
#### Services

systemctl enable docker.socket
systemctl enable incus.socket
systemctl enable podman.socket
systemctl enable tailscaled.service
systemctl enable -f --global flatpak-setup.service

systemctl enable azure-system-setup.service
systemctl enable azure-groups.service
12 changes: 12 additions & 0 deletions files/usr/lib/systemd/system/azure-groups.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Add wheel members to docker, incus and libvirt groups

[Service]
Type=oneshot
ExecStart=/usr/libexec/azure-groups
Restart=on-failure
RestartSec=30
StartLimitInterval=0

[Install]
WantedBy=default.target
12 changes: 12 additions & 0 deletions files/usr/lib/systemd/system/azure-system-setup.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Configure system
After=rpm-ostreed.service
Before=systemd-user-sessions.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/azure-system-setup

[Install]
WantedBy=multi-user.target
25 changes: 25 additions & 0 deletions files/usr/libexec/azure-groups
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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"
3 changes: 3 additions & 0 deletions files/usr/libexec/azure-system-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

mkdir -p /etc/azure

0 comments on commit cd4b46a

Please sign in to comment.