Tile: Linux Adduser Script. You will have to modify some of the Paths to point to your system Files. This adduser script is based on a webhosting company, which will add virt hosting domains to your sendmail.cw, virtusertable and mailertable. Please read the source before you try adding this script to your system. -------------------------------------------------------------------------------- Source Code: #!/bin/bash export HTTP_CONF="/services/www/conf/httpd.conf"; export SHELL_PATH="/shell"; export SENDMAIL_CW="/etc/sendmail.cw"; export VIRTUSER_TABLE="/etc/mail/virtusertable"; uSAGE() { echo "Your not using the right syntax." echo echo "Please type just (adduser)." echo "Follow all the questions asked." echo echo "This adduser script will add everything possible to the system" echo "from httpd to sendmail, as long as you follow the questions." echo exit } function MAIL() { /usr/sbin/sendmail -t < Subject: Welcome new user to Furby. Jynx.NETworks. From: root@jynx.net To: $EMAILA Welcome to Jynx.NETworks... Hope you Enjoy your Stay... Below is your account information... First Name: $FNAME Last Name: $LNAME Username: $USER Password: $PW Email: $EMAILA Shell: $SHELL Group: $GROUP Path: $PATH2 New Email: $NEWEMAIL If you have any questions or comments please feel free to email chris@jynx.net. EOM } if [ "$1" != "" ]; then uSAGE fi if [ "$1" = "" ]; then echo -n "Enter username: " read USER if [ -z "$USER" ]; then echo "Sorry no username given" exit fi echo "Checking to see if $USER is taken..." sleep 1 RESULT="`cat /etc/passwd | grep ^$USER:`" if [ "$RESULT" != "" ]; then echo "$USER is already a user." exit fi echo -n "Enter password: " read PASS if [ -z "$PASS" ]; then echo "No password given, will use a randmon password" PASS2="`/usr/sbin/makepassword`" if [ "$PASS2" = "" ]; then echo "Script is broke.. you BROKE IT!" exit fi if [ "$PASS2" != "" ]; then sleep 1 echo "Generating a password" sleep 1 echo "Password that will be used is: $PASS2" PW=$PASS2 fi fi if [ "$PASS" != "" ]; then PW=$PASS fi echo "" sleep 1 echo -n "Enter Email: " read EMAILA if [ -z "$EMAILA" ]; then echo "No email address, I wont go on.." exit fi echo -n "Will this user need virtusertable setup?: " read VIRTU if [ "$VIRTU" = "y" ] || [ "$VIRTU" = "Y" ]; then echo -n "Enter new Address: " read NEWEMAIL fi echo -n "Enter First name: " read FNAME if [ -z "$FNAME" ]; then echo "No first name.." fi echo -n "Enter Last name: " read LNAME if [ -z "$LNAME" ]; then echo "No last name.." fi echo -n "Enter shell (/bin/bash): " read SHELL if [ -z "$SHELL" ]; then SHELL="/bin/bash" fi echo -n "Enter User Group (users): " read GROUP if [ -z "$GROUP" ]; then GROUP="users" fi echo -n "Will this user want a website? (y/n): " read WEB if [ -z "$WEB" ]; then PATH2="$SHELL_PATH/$USER" fi if [ "$WEB" = "y" ] || [ "$WEB" = "Y" ]; then echo -n "Will there be a Domain? (y/n): " read DOM if [ "$DOM" = "Y" ] || [ "$DOM" = "y" ]; then echo -n "Enter Domain Name: (no www.): " read DOMAIN if [ -z "$DOMAIN" ]; then echo "No domain.. cant go on."; exit fi PATH2="/export/web/people/$DOMAIN" echo "Enter Catch all email for $DOMAIN" echo -n "Default will be $USER@$DOMAIN: " read CATCHER if [ -z "$CATCH" ]; then CATCHER="$USER@$DOMAIN" fi fi fi if [ "$DOM" = "N" ] || [ "$DOM" = "n" ]; then PATH2="/export/web/people/$USER" fi if [ "$WEB" = "y" ] || [ "$WEB" = "Y" ]; then echo -n "Will this site need Front Page? (y/n): " read FP if [ -z "$FP" ]; then echo "You didnt answer my question" exit fi fi if [ "$WEB" = "N" ] || [ "$WEB" = "n" ]; then PATH2="$SHELL_PATH/$USER" fi /usr/bin/sleep 1 echo " " echo " First Name: $FNAME" echo " Last Name: $LNAME" echo " Username: $USER" echo " Password: $PW" echo " Email: $EMAILA" echo " Shell: $SHELL" echo " Group: $GROUP" echo " Path: $PATH2" if [ "$DOM" = "N" ] || [ "$DOM" = "n" ]; then echo " Domain: none." fi if [ "$DOM" = "y" ] || [ "$DOM" = "Y" ]; then echo " Domain: $DOMAIN" echo " Default Email: $CATCHER" fi if [ "$FP" = "y" ] || [ "$FP" = "Y" ]; then echo " Front Page: Yes" fi if [ "$FP" = "n" ] || [ "$FP" = "N" ]; then echo " Front Page: No" fi echo " " echo -n "Hit Enter if this information is right. If it is not hit (Control-C) to End now" read ENTER # Time to add all this stuff to the config.... O Joy # echo echo "Adding $USER to the system..." /usr/bin/sleep 1 # adding user /usr/sbin/useradd -c "$FNAME $LNAME" \ -g "$GROUP" \ -d "$PATH2" \ -s "$SHELL" \ -m "$USER" # setting the password echo "$USER":"$PW" | /usr/sbin/chpasswd # adding email to virtusertable if [ "$WEB" = "N" ] || [ "$WEB" = "n" ]; then echo "$USER@jynx.net $USER" >> /etc/mail/virtusertable /usr/sbin/makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable fi if [ "$DOM" = "Y" ] || [ "$DOM" = "y" ]; then echo "$CATCHER $USER" >> /etc/mail/virtusertable echo "@$DOMAIN $USER" >> /etc/mail/virtusertable /usr/sbin/makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable # adding domain to sendmail.cw echo "$DOMAIN" >> /etc/sendmail.cw /bin/killall -HUP sendmail fi # time to edit the http.conf for none domain users if [ "$WEB" = "Y" ] || [ "$WEB" = "y" ]; then if [ "$DOM" = "n" ] || [ "$DOM" = "N" ]; then echo "#" >> $HTTP_CONF echo "# $USER site.. " >> $HTTP_CONF echo "" >> $HTTP_CONF echo " ServerAdmin $USER@jynx.net" >> $HTTP_CONF echo " DocumentRoot /export/web/people/$USER/public_html" >> $HTTP_CONF echo " ServerName $USER.jynx.net" >> $HTTP_CONF echo " ErrorLog logs/$USER.jynx.net-error_log" >> $HTTP_CONF echo " CustomLog logs/$USER.jynx.net-access_log common" >> $HTTP_CONF echo " ScriptAlias /cgi-bin/ \"/export/web/people/$USER/public_html/cgi-bin/\" " >> $HTTP_CONF echo " " >> $HTTP_CONF echo " AllowOverride All" >> $HTTP_CONF echo " Options All" >> $HTTP_CONF echo " Order allow,deny" >> $HTTP_CONF echo " Allow from all" >> $HTTP_CONF echo " " >> $HTTP_CONF echo "" >> $HTTP_CONF /bin/mkdir /export/web/people/$USER/public_html /bin/mkdir /export/web/people/$USER/public_html/cgi-bin /bin/chmod 755 /export/web/people/$USER/public_html/cgi-bin /bin/chown -R $USER.$GROUP /export/web/people/$USER if [ "$FP" = "Y" ] || [ "$FP" = "y" ]; then /usr/local/frontpage/version4.0/bin/fpsrvadm.exe -o install -p 80 -m $USER.jynx.net -u $USER -pw $PW -t apache -s /services/www/conf/httpd.conf -xu $USER -xg $GROUP fi fi if [ "$DOM" = "Y" ] || [ "$DOM" = "y" ]; then echo "#" >> $HTTP_CONF echo "# $USER site.. " >> $HTTP_CONF echo "" >> $HTTP_CONF echo " ServerAdmin $USER@$DOMAIN" >> $HTTP_CONF echo " DocumentRoot $PATH2/public_html" >> $HTTP_CONF echo " ServerName www.$DOMAIN" >> $HTTP_CONF echo " ServerAlias $DOMAIN" >> $HTTP_CONF echo " ErrorLog logs/www.$DOMAIN-error_log" >> $HTTP_CONF echo " CustomLog logs/www.$DOMAIN-access_log common" >> $HTTP_CONF echo " ScriptAlias /cgi-bin/ \"$PATH2/public_html/cgi-bin/\" " >> $HTTP_CONF echo " " >> $HTTP_CONF echo " AllowOverride All" >> $HTTP_CONF echo " Options All" >> $HTTP_CONF echo " Order allow,deny" >> $HTTP_CONF echo " Allow from all" >> $HTTP_CONF echo " " >> $HTTP_CONF echo "" >> $HTTP_CONF /bin/mkdir /export/web/people/$DOMAIN/public_html /bin/mkdir /export/web/people/$DOMAIN/public_html/cgi-bin /bin/chmod 755 /export/web/people/$DOMAIN/public_html/cgi-bin /bin/chown -R $USER.$GROUP /export/web/people/$DOMAIN if [ "$FP" = "Y" ] || [ "$FP" = "y" ]; then /usr/local/frontpage/version4.0/bin/fpsrvadm.exe -o install -p 80 -m www.$DOMAIN -u $USER -pw $PW -t apache -s /services/www/conf/httpd.conf -xu $USER -xg $GROUP fi fi fi if [ "$VIRTU" = "y" ] || [ "$VIRTU" = "Y" ]; then echo "$NEWEMAIL $USER" >> /etc/mail/virtusertable /usr/sbin/makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable fi echo "Sending email to user" MAIL echo "User is added.. Enjoy" /usr/bin/sleep 1 echo -n "Would you like to do a system update? (y/n): " read UPDATE if [ -z "$UPDATE" ]; then exit fi if [ "$UPDATE" = "N" ] || [ "$UPDATE" = "n" ]; then exit fi if [ "$UPDATE" = "Y" ] || [ "$UPDATE" = "y" ] ; then /usr/bin/sleep 1 /services/www/bin/apachectl graceful /bin/killall -HUP sendmail fi exit fi Back to Scripts Show Source of (/scripts.php)