#!/bin/bash # # 0.3 - wattersm@example.com # # $1 - username # $2 - password # $3 - email # $4 - full name # $5 - account type (rb50 or rb100) echo "" echo "" echo "" if [ -z "$1" ]; then echo "Usage backupuser.sh " exit fi if [ -z "$2" ]; then echo "Usage backupuser.sh " exit fi if [ -z "$3" ]; then echo "Usage backupuser.sh " exit fi if [ -z "$4" ]; then echo "Usage backupuser.sh " exit fi if [ -z "$5" ]; then echo "Usage backupuser.sh " exit fi if [ "$5" == "rb100" ]; then echo "Setting up RB100 User" adduser -p `perl -e "print crypt('$2','echo $RANDOM|cut -c 1-2');"` -s /sbin/nologin $1 setquota $1 102000000 102000000 0 0 /home echo "Done." else echo "Setting up RB50 User" adduser -p `perl -e "print crypt('$2','echo $RANDOM|cut -c 1-2');"` -s /sbin/nologin $1 setquota $1 51000000 51000000 0 0 /home echo "Done" fi echo "Sending welcome message..." sendmail -t -oi << To: $3 Reply-To: support@example.com Subject: Example Web Backup Network Account Information Hello $4, Your Example Web Remote Backup Network account has been created. Please use the following information to log in: Server Name : `hostname` IP Address : `ifconfig eth1|grep inet|cut -d : -f 2|cut -d " " -f 1` Rsync User Name : $1 Password : $2 All access is provided through rsync over ssh on the internal backup network. Please note that we have set up automatic nightly backups for you, you will receive a backup status report every night after the copy process is complete. Also note that your server will have a 10.x.x.x IP address on it. This is the IP address of the network card for the backup network. Do not assign this IP to any user accounts, nameservers, etc. It is for the backup network only and is not routeable on the Internet. If you have any questions, please contact our support team at support@example.com.