first commit

This commit is contained in:
Roy
2025-06-23 21:19:51 +02:00
commit a4f9ea11f3
69 changed files with 4857 additions and 0 deletions

54
scripts/adduser_schrpt.sh Normal file
View File

@ -0,0 +1,54 @@
#!/bin/bash
if [ $# -lt 1 ]
then
echo "Syntax: ./`basename $0` <file name>"
exit
fi
# Parameters
USER_DATA_FILE=$1
for userdetails in `cat $1`
do
ENVIRONMENT_NAME=`echo $userdetails | cut -f 1 -d:`
ORGANIZARION_NUMBER=`echo $userdetails | cut -f 2 -d:`
PASSWD=`echo $userdetails | cut -f 3 -d:`
USER_NAME=${ENVIRONMENT_NAME}_${ORGANIZARION_NUMBER}
egrep "^$USER_NAME" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
else
ENCR_PASSWD=$(perl -e 'print crypt($ARGV[0], "password")' $PASSWD)
useradd -m -p $ENCR_PASSWD $USER_NAME
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Only root may add a user to the system"
exit 2
done
USER_NAME=${ENVIRONMENT_NAME}_${ORGANIZARION_NUMBER}
#!/bin/bash
# Script to add a user to Linux system
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
else
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Only root may add a user to the system"
exit 2
fi