client-pull-installation/roles/base/files/pulseaudio-perms.sh

25 lines
662 B
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
domaingroup="domain users"
localgroups="pulse pulse-access"
baseusers="bglug"
domainusers=$(getent group '${domaingroup}' | awk 'BEGIN { FS = ":" }; { print $4 }' | sed -e 's/,/ /')
users="${baseusers} ${domainusers}"
for group in "${localgroups}"; do
actualusers=$(getent group '${group}' | awk 'BEGIN { FS = ":" }; { print $4 }' | sed -e 's/,/ /g')
# Removing users not in the group
for user in "${actualusers}"; do
[[ "${users}" =~ "${user}" ]] || gpasswd -d "${user}" "${group}"
done
# Adding users to group
for user in "${users}"; do
[[ "${actualusers}" =~ "${user}" ]] || gpasswd -a "${user}" "${group}"
done
done