UserID를 텍스트 파일로 받아 다수의 사용자 추가 스크립트


#!/bin/sh
clear
echo    "*************************************************************"
echo    "Please choose from the following options; type the"
echo    "option number and hit the <Enter> key."
echo    "
echo    "
echo    "  1) To Run this script"
echo    "  2) Exit"
echo    "*************************************************************"

if [ "$(whoami)" != "root" ] ; then
  echo "Error: You must be root to run this command." >&2
  exit 1
fi

read option

if [ $? -eq 1 ]
then
clear
        echo "You need to be root before running this script."
        echo "Please restart this script as root and all will be fine."
exit
fi


if [ "$option" = "1" ]
then
## This is going to be future implementation of chosing password at creation
echo "Type password for the new users."


grub-md5-crypt

echo "Please MD5 type passwd Copy & Paste"

read pass
echo $pass

echo "Type in the path for the file (ex. /root/user.txt)"
read users
echo "Type in the group name. If there is not a group, Press to [Enter] key"
read group

        groupadd $group 2>/dev/null >/dev/null
        for i in `sed 's/\(..\).*@\(..\).*/\1\2/' $users`
do
if [ $group ]
then
        useradd -g $group -p $pass -s /bin/bash -m -d /home/$group/$i $i 2>/dev/null >/dev/null
else
        useradd -p $pass -s /bin/bash -m -d /home/$i $i 2>/dev/null >/dev/null
fi


done

echo "Done!"

elif ["$option" = "2"]
then
        echo "exiting script"
exit
fi



읽어주셔서 감사합니다. 혹시라도 더 좋은 방법 있으시면 조언좀 부탁드릴께요~
1 ... 33 34 35 36 37 38 39 40 41 ... 82