#!/bin/sh # # Short: make mounts, shares, groups, users and all relevant folders # Version: 2.06, 11-09-02 # Author: Mark J Swift, msw AT blackpool.ac.uk # Long: Utilises the shell scripts: mkmounts.sh, mkshares.sh, # mksharefldrs.sh, mkgroups.sh, mkgroupfldrs.sh, mkusers.sh, # mknetscaperegs.sh and lsgroups.sh to create automounts, # sharepoints , groups, users and all relevant folders. You # must create the files: mounts.txt, groups.txt and users.txt # prior to running the script. # # 1. Log in as root # # 2. Copy this script into roots home directory # (/private/var/root/Documents). # # 3. Start a new shell process and change directory to roots home. # # cd ~/Documents # # 4. Set the execute flag is set on the script, type: # # chmod u+x mkall.sh # # 5. Create a text file containing a line for every mount # that gives the following information': # # machine_name,machine_ip,mountpoint ...i.e: # # oak,192.168.1.2,/share1 # oak,192.168.1.2,/Volumes/STORE1/share2 # cedar,192.168.1.3,/Volumes/STORE2/share3 # # 6. Save the file as "mounts.txt" in roots' home directory # # 7. Create a text file containing a line for every group # that gives the following information': # # group_realname,group_shortname,owner,host_name,share_point ...i.e: # # art-staff,artstaff,superu,oak,share1 # art-ba-gd-2003,bagd2003,superu,oak,share1 # art-ba-gd-2004,bagd2004,superu,oak,share1 # art-ba-ph-2003,baph2003,superu,oak,share2 # art-ba-ph-2004,baph2004,superu,oak,share2 # # 8. Save the file as "groups.txt" in root's home directory # # 9. Create a text file containing a line for every user # that gives the following information: # # short_name,full_name,group,password ...i.e: # # dwa,duncan waketch,art-staff,ectonger # kqu,kevin quington,art-staff,croferes # 20013141,oliver mcapman,art-ba-gd-2003,decier # 20015926,grant winson,art-ba-gd-2003,plamme # 20029793,benjamin brockson,art-ba-gd-2004,cabloste # 20022384,william alkine,art-ba-gd-2004,teurvant # 20013383,jakob croucks,art-ba-ph-2003,decrite # 20012795,kathryn dallind,art-ba-ph-2003,phystion # 20024197,patrick burris,art-ba-ph-2004,permient # 20021693,craig stocks,art-ba-ph-2004,affraie # # Note, if no password is specified on the line - i.e: # # short_name,full_name,group # # ...then the user's password is generated using the # command line utility babelpass. babelpass requires a # language template file (see mkuser.sh script). # # If babelpass or the required language template file is not # available, then the password is set to be the short name. # # 10. Save the file as "users.txt" in root's home directory # # 11. Execute the "mkall.sh" script with the following command: # # ~/Documents/mkall.sh # # 12. Check the file "mkusers.txt" for generated passwords. # get the name of this workstation node_name=`uname -n` # -------------------------------- # debug - print host details to screen # -------------------------------- # echo " node_name:$node_name" # -------------------------------- # NetInfo: are we sharing, are we master? # -------------------------------- ni_notshared=`niutil -rparent . | grep -c -y "[.]*no parent"` if [ $ni_notshared -eq 1 ] then ni_isshared=0 ni_ismaster=0 ni_host_name=$node_name else ni_isshared=1 ni_ismaster=`niutil -rparent . | grep -c -y "^$node_name[]*/[]*"` ni_host_name=`niutil -rparent . | cut -d/ -f1 | cut -d. -f1 ` fi if [ $ni_isshared -eq 0 -o $ni_ismaster -eq 1 ] then ni_canmodify=1 else ni_canmodify=0 fi # -------------------------------- # debug - print host NetInfo details to screen # -------------------------------- # echo " ni_is_shared:$ni_isshared" # echo " ni_is_master:$ni_ismaster" # echo " ni_canmodify:$ni_canmodify" # echo " ni_host_name:$ni_host_name" if test ! -f "mounts.txt" then echo " ERROR : Create a text file containing a line for every" echo " mount that gives the following information" echo "" echo " machine_name,machine_ip,mountpoint ...i.e:" echo "" echo " oak,192.168.1.2,/share1" echo " oak,192.168.1.2,/Volumes/STORE1/share2" echo " cedar,192.168.1.3,/Volumes/STORE2/share3" echo "" echo " Save the file as mounts.txt in roots home directory" exit 0 fi if test ! -f "groups.txt" then echo " ERROR : Create a text file containing a line for every" echo " group that gives the following information:" echo "" echo " group_realname,group_shortname,owner,host_name,share_point ...i.e:" echo "" echo " art-staff,artstaff,superu,oak,share1" echo " art-ba-gd-2003,bagd2003,superu,oak,share1" echo " art-ba-gd-2004,bagd2004,superu,oak,share1" echo " art-ba-ph-2003,baph2003,superu,oak,share2" echo " art-ba-ph-2004,baph2004,superu,oak,share2" echo "" echo " Save the file as groups.txt in roots home directory" exit 0 fi if test ! -f "users.txt" then echo " ERROR : Create a text file containing a line for every" echo " user that gives the following information:" echo "" echo " short_name,full_name,group,password ...i.e:" echo "" echo " dwa,duncan waketch,art-staff,ectonger" echo " kqu,kevin quington,art-staff,croferes" echo " 20013141,oliver mcapman,art-ba-gd-2003,decier" echo " 20015926,grant winson,art-ba-gd-2003,plamme" echo " 20029793,benjamin brockson,art-ba-gd-2004,cabloste" echo " 20022384,william alkine,art-ba-gd-2004,teurvant" echo " 20013383,jakob croucks,art-ba-ph-2003,decrite" echo " 20012795,kathryn dallind,art-ba-ph-2003,phystion" echo " 20024197,patrick burris,art-ba-ph-2004,permient" echo " 20021693,craig stocks,art-ba-ph-2004,affraie" echo "" echo " Save the file as users.txt in roots home directory" echo "" echo " Note, if no password is specified on the line - i.e:" echo "" echo " short_name,full_name,group" echo "" echo " ...then the user password is set to be the same as" echo " the users short name." exit 0 fi if test ! -f "mkmounts.sh" then echo " ERROR : Copy the script mkmounts.sh into roots home directory" exit 0 else chmod u+x mkmounts.sh fi if test ! -f "mkshares.sh" then echo " ERROR : Copy the script mkshares.sh into roots home directory" exit 0 else chmod u+x mkshares.sh fi if test ! -f "mksharefldrs.sh" then echo " ERROR : Copy the script mksharefldrs.sh into roots home directory" exit 0 else chmod u+x mksharefldrs.sh fi if test ! -f "mkgroups.sh" then echo " ERROR : Copy the script mkgroups.sh into roots home directory" exit 0 else chmod u+x mkgroups.sh fi if test ! -f "mkgroupfldrs.sh" then echo " ERROR : Copy the script mkgroupfldrs.sh into roots home directory" exit 0 else chmod u+x mkgroupfldrs.sh fi if test ! -f "mkusers.sh" then echo " ERROR : Copy the script mkusers.sh into roots home directory" exit 0 else chmod u+x mkusers.sh fi if test ! -f "mkuserfldrs.sh" then echo " ERROR : Copy the script mkuserfldrs.sh into roots home directory" exit 0 else chmod u+x mkuserfldrs.sh fi if test ! -f "mknetscaperegs.sh" then echo " ERROR : Copy the script mknetscaperegs.sh into roots home directory" exit 0 else chmod u+x mknetscaperegs.sh fi if test ! -f "lsgroups.sh" then echo " ERROR : Copy the script lsgroups.sh into roots home directory" exit 0 else chmod u+x lsgroups.sh fi if test ! -f "babelpass" then echo " ERROR : Copy the utility babelpass into roots home directory" exit 0 else chmod u+x babelpass fi if [ $ni_canmodify -eq 0 ] then # not master, we can only create LOCAL folders and shares. `pwd`/mkshares.sh `pwd`/mksharefldrs.sh `pwd`/mkgroupfldrs.sh `pwd`/mkuserfldrs.sh `pwd`/mknetscaperegs.sh echo " : exporting users & groups..." `pwd`/lsgroups.sh > mmgroups.txt else # we are the master, we can do what we like. `pwd`/mkmounts.sh mounts.txt `pwd`/mkshares.sh `pwd`/mksharefldrs.sh `pwd`/mkgroups.sh groups.txt `pwd`/mkgroupfldrs.sh `pwd`/mkusers.sh users.txt `pwd`/mkuserfldrs.sh `pwd`/mknetscaperegs.sh echo " : exporting users & groups..." `pwd`/lsgroups.sh > mmgroups.txt fi