Incorporated changes for release 1.1.1

This commit is contained in:
2026-02-14 11:26:01 -05:00
parent a6331f7fed
commit 16d1ff9bb8
45 changed files with 459 additions and 155 deletions

View File

@@ -2,17 +2,27 @@
SRC=$1
DEST=$2
if [ $# -ne 2 ]; then
echo "Usage: cloneuser source_user destination_user"
exit 1
fi
if ! grep -q $SRC /etc/passwd ;then echo "Source user doesn't exist!"; exit 1; fi
if grep -q $DEST /etc/passwd ;then echo "Destination user already exists!"; exit 1; fi
SRC_GROUPS=`id -Gn ${SRC}`
SRC_SHELL=$(awk -F : -v name=${SRC} '(name == $1) { print $7 }' /etc/passwd)
RAND_PW=`date +%s | sha256sum | base64 | head -c 32 ; echo`
echo "Creating user $DEST"
useradd --shell ${SRC_SHELL} --create-home ${DEST}
echo "Creating user $DEST with a random password"
useradd --shell ${SRC_SHELL} --password ${RAND_PW} --create-home ${DEST}
for grp in ${SRC_GROUPS};do
if [ "$grp" != "$SRC" ]; then
echo "Adding user $DEST to group $grp."
usermod -a -G $grp ${DEST}
fi
done
passwd ${DEST}
echo "Finished. Please set an actual password for $DEST if you want them to be able to log in."