Files
debian-web-server/bin/user.sh
T
bachirandClaude Sonnet 5 2e3ec7883f Replace echo -e with printf for portable ANSI banners
dash (Debian's /bin/sh) doesn't support echo's -e flag: it prints "-e"
literally as text before processing the rest of the string's backslash
escapes. Every script's colored banner was affected. printf's escape
handling is POSIX-mandated and behaves identically under dash and bash,
so swap all 90 echo -e calls for printf, appending the trailing \n that
echo used to add implicitly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-04 09:35:02 +02:00

47 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
printf '\033[35m
__ _______ __________
/ / / / ___// ____/ __ \
/ / / /\__ \/ __/ / /_/ /
/ /_/ /___/ / /___/ _, _/
\____//____/_____/_/ |_|
\033[0m\n'
printf "\033[35;1mCreate new user (you will be asked a user name and a password) \033[0m\n"
if [ "$(id -u)" -ne 0 ]; then
echo "Please run as root"
exit
fi
sleep 3
echo -n "Enter user name: "
read user
while [ "$user" = "" ]
do
read -p "enter a user name ? " user
if [ "$user" != "" ]; then
# check if user already exists
if id "$user" >/dev/null 2>&1; then
echo "user $user alreday exists, you must provide a non existing user name."
user=""
else
read -p "is user name $user correcte [y|n] " validated
if [ "$validated" = "y" ]; then
break
else
user=""
fi
fi
fi
done
adduser "$user"
echo "adding $user to admin group and limiting su to the admin group"
groupadd admin
usermod -a -G admin "$user"
# allow admin group to su
dpkg-statoverride --update --add root admin 4750 /bin/su
printf "\033[92;1muser $user configured\033[Om\n"