mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-12-26 13:29:45 +00:00
f64fa2bd12
* Add User Control Panel * Fix non posix * Split script * Update userguide.md * Update utility_functions.sh * Remove clear * Add checkEnv
27 lines
794 B
Bash
Executable File
27 lines
794 B
Bash
Executable File
#!/bin/sh -e
|
|
|
|
. ../../common-script.sh
|
|
. ./utility_functions.sh
|
|
|
|
clear
|
|
printf "%b\n" "${YELLOW}Create a new user${RC}"
|
|
printf "%b\n" "${YELLOW}=================${RC}"
|
|
|
|
username=$(promptUsername "add" "non-root") || exit 1
|
|
|
|
# Check if username is valid
|
|
if ! echo "$username" | grep '^[a-z][-a-z0-9_]*$' > /dev/null; then
|
|
printf "%b\n" "${RED}Username must only contain letters, numbers, hyphens, and underscores. It cannot start with a number or contain spaces.${RC}"
|
|
exit 1
|
|
fi
|
|
|
|
password=$(promptPassword) || exit 1
|
|
|
|
$ESCALATION_TOOL useradd -m "$username" -g users -s /bin/bash
|
|
echo "$username:$password" | $ESCALATION_TOOL chpasswd
|
|
|
|
printf "%b\n" "${GREEN}User $username created successfully${RC}"
|
|
printf "%b\n" "${GREEN}To add additional groups use Add User To Groups${RC}"
|
|
|
|
checkEnv
|