Skip to content

Instantly share code, notes, and snippets.

@iTeeLion
Last active September 28, 2023 17:15
Show Gist options
  • Save iTeeLion/ecc7e3b31577f87828f86306deb3cc05 to your computer and use it in GitHub Desktop.
Save iTeeLion/ecc7e3b31577f87828f86306deb3cc05 to your computer and use it in GitHub Desktop.
gameap user permissions
#!/bin/bash
# Add user for gameap (raplace USERNAME with yours)
#
# useradd -m -U -G gap -s /bin/bash -d /srv/gameap/USERNAME USERNAME
# apt install members
PKG=members
PKG_STATUS="$(dpkg-query -W --showformat='${db:Status-Status}' "$PKG" 2>&1)"
if [ ! $? = 0 ] || [ ! "$PKG_STATUS" = installed ]; then
sudo apt install $PKG
fi
# create group for gap users
if grep -q gap /etc/group
then
echo "Group "gap" exists."
else
echo "Group gap does not exist, creating..."
groupadd gap
fi
# set permissions
USERS=$(members gap)
GAPDIR="/srv/gameap"
cd $GAPDIR
for USER in $USERS
do
if [ -d "$GAPDIR/$USER" ]
then
chown -R $USER:$USER ./$USER
chmod -R 0770 ./$USER
echo "Set permissions for: $USER"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment