#!/bin/bash # THIS SCRIPT AUTOMATES THE SETTING REQUIRED FOR EACH NODE.THE SCRIPT HAS TO RUN AS ROOT ####################################################################################### # AUTOSET ###################################################################################### #script created by FAHAD SAEED on 13 june 2005 #Backup procedures by FAHAD ALI ARSHAD #############Keep all the scripts(testlogin,scriptm4,remote1,loggedip,fileworm and commandworm) ###############################in /home/auto folder AND RUN THIS SCRIPT ##################### service nfs restart service iptables stop ########################## SECTION 0 #################################### # this section creates the necessary accounts for this home machine # this ip is used for various other scripts ip="" echo Please Enter the IP of this machine read ip>/home/auto/terminalip homeaccnt="" echo PLEASE ENTER THE HOME ACCOUNT FOR THIS MACHINE read homeaccnt useradd $homeaccnt echo Home account $homeaccnt created :- echo PLEASe enter The password for this machine passwd $homeaccnt echo echo CONGRATS echo bkaccnt="" echo Enter the backup account for this machine--The terminalip-1 home account echo Enter the user of the previous machine read bkaccnt useradd $bkaccnt echo Backup account for the previous machine created echo Please enter the password for this machine echo Recommended:Same as the previous machine home account !! passwd $bkaccnt echo echo echo Creating the student account for this machine useradd student echo please enter the password for the student account echo RECOMMENDED password:student passwd student echo Creating the ADMIN account for this machine useradd admin echo Please enter the password for admin passwd admin ################################# SECTION 0 -1 ################################# ###################### determines the neighbours of the terminal ################ ######## used in the admin processes ############ perl ./ipinrc ######### the neighbours are saved in the admin folder for adminstration processes ############################# SECTION 1 ############################### # this SECTION changes the .bash_profile and .bash_logout for the account # in which the student logs in echo changing .bash_profile of the student account printf 'cd /home/script \n'>tmphold; printf 'bash /home/script/scriptm4 & \n'>>tmphold; cat tmphold >> /home/student/.bash_profile ## makes sure to unmount the nfs mounts when the student logs out echo Changing .bash_logout of the student account printf 'bash /home/script/unmount \n'>tmphold printf 'clear' >>tmphold cat tmphold > /home/student/.bash_logout ################################## SECTION 2 -A ########################### ########### This changes the .bash_profile of the home account ##################### ########################### and the backup account ######################### echo changing the .bash_profile for the home account printf 'bash /home/script1/remote1 \n'>tmphold; printf 'exit \n'>>tmphold cat tmphold >> /home/$homeaccnt/.bash_profile echo changing the .bash_profile for the backup account printf 'bash /home/script1/remote2 \n'>tmphold printf 'exit \n'>>tmphold cat tmphold >> /home/$bkaccnt/.bash_profile rm -vf tmphold ############################## SECTION 2 -B ############################## ############### This customises the remote1/remote2 script for the ############# ################ home machine/backup account ######### cp -v ./remote1 ./remote2 echo 'echo' /home/$homeaccnt'" "$ipvar"(rw,sync)" >>/etc/exports'>>./remote1 echo /usr/sbin/exportfs -ra>>./remote1 echo 'echo' /home/$bkaccnt'" "$ipvar"(rw,sync)" >>/etc/exports'>>./remote2 echo /usr/sbin/exportfs -ra>>./remote2 #################################### SECTION 3 ############################### ################## This section makes the various folders required for the operation ######### mkdir /home/localwork mkdir /home/script cp -v ./scriptm4 /home/script cp -v ./testlogin /home/script cp -v ./database /home/script cp -v ./unmount /home/script cp -v ./back /home/script mkdir /home/script1 cp -v ./remote1 /home/script1 cp -v ./remote2 /home/script1 cp -v ./loggedip /home/script1 cp -v ./chngpass /home/script1 ##### admin scripts cp -v ./keygenerator /home/admin cp -v ./keygen2 /home/admin cp -v ./fileworm /home/admin cp -v ./commandworm /home/admin ################################## SECTION 4 ################################ ############## This section configures the terminal for backup procedures####### ################################################################################ echo echo installing rdiff echo cd /home/auto/librsync-0.9.7 make make all make install cd /home/auto/rdiff-backup-0.12.8 python setup.py build python setup.py install echo echo echo CONFIGURING TERMINAL FOR THE BACKUP PROCEDURES touch /var/spool/cron/$homeaccnt read backupip < /home/admin/ip1 echo Configuring Cron printf "0 13 * * * rdiff-backup /home/$homeaccnt $backupip::/home/$homeaccnt \n">/var/spool/cron/copy cp /var/spool/cron/copy /var/spool/cron/$homeaccnt printf "0 13 * * * rdiff-backup $backupip::/home/$homeaccnt /home/$homeaccnt \n">>/var/spool/cron/$homeaccnt /sbin/service crond restart