Delete user before deleting group

This commit is contained in:
Robin 2021-12-20 23:56:42 +01:00
parent 8ec873f009
commit 57ba7611bd
2 changed files with 18 additions and 18 deletions

View File

@ -1,14 +1,5 @@
#!/bin/sh
if [ -n "$(getent group "$WWW_DATA_GID")" ]
then
GROUPNAME=$(getent passwd "$WWW_DATA_GID" | cut -d: -f1)
echo "Deleting group $GROUPNAME which already uses GID $WWW_DATA_GID"
groupdel "$GROUPNAME"
else
echo "GID $WWW_DATA_GID not in use"
fi
if [ -n "$(getent passwd "$WWW_DATA_UID")" ]
then
USERNAME=$(getent passwd "$WWW_DATA_UID" | cut -d: -f1)
@ -18,6 +9,15 @@ else
echo "UID $WWW_DATA_UID not in use"
fi
if [ -n "$(getent group "$WWW_DATA_GID")" ]
then
GROUPNAME=$(getent passwd "$WWW_DATA_GID" | cut -d: -f1)
echo "Deleting group $GROUPNAME which already uses GID $WWW_DATA_GID"
groupdel "$GROUPNAME"
else
echo "GID $WWW_DATA_GID not in use"
fi
if [ -n "$(getent group www-data)" ]
then
echo "Modifying existing www-data group, setting GID to $WWW_DATA_GID"

View File

@ -1,15 +1,6 @@
#!/bin/sh
set -e
if [ -n "$(getent group "$WWW_DATA_GID")" ]
then
GROUPNAME=$(getent passwd "$WWW_DATA_GID" | cut -d: -f1)
echo "Deleting group $GROUPNAME which already uses GID $WWW_DATA_GID"
groupdel "$GROUPNAME"
else
echo "GID $WWW_DATA_GID not in use"
fi
if [ -n "$(getent passwd "$WWW_DATA_UID")" ]
then
USERNAME=$(getent passwd "$WWW_DATA_UID" | cut -d: -f1)
@ -19,6 +10,15 @@ else
echo "UID $WWW_DATA_UID not in use"
fi
if [ -n "$(getent group "$WWW_DATA_GID")" ]
then
GROUPNAME=$(getent passwd "$WWW_DATA_GID" | cut -d: -f1)
echo "Deleting group $GROUPNAME which already uses GID $WWW_DATA_GID"
groupdel "$GROUPNAME"
else
echo "GID $WWW_DATA_GID not in use"
fi
if [ -n "$(getent group www-data)" ]
then
echo "Modifying existing www-data group, setting GID to $WWW_DATA_GID"