-- MikeGore - 2015-08-25

common shell scripts used by ClusterTools

  • common_functions common_functions
    • Common SHELL functions used by image deployment system
  • common_vars common_vars
    • Common SHELL variables specific to most systems
  • common_host common_host
    • Common HOST specific variables used for the Image Deployment System
  • NODES NODES
    • List of NODES and ILOMS in the cluster

Documentation notes

  • Note: Documentation for all of the *ipmi commands below were automatically generated using the sh2twiki command*
    • ssh cscf-adm@asimov
    • cd /cscf-adm/src
    • sudo bash
    • * make docs - invokes sh2wtiki to create both HTML adn TWIKI documents
    • All of the generated TWIKI files will be found under /cscf-adm/src/twiki

common_functions

  • Updated: Tue Aug 25 10:58:50 2015

Common SHELL functions used by image deployment system

  • common_functions - document source
  • Author: Mike Gore
  • Date:
    • *10 APr 2015 *
  • Notes:
  • Assumed:
    • Normally called by "common_vars" first
  • What:
    • A collection of shell utilities we use everywhere
    • Part of three file group: common_vars common_host common_functions

  • Note:
    • test to make sure this script is not called recursively
    • COMMON_FUNCIONS="TRUE"

  • Note:
    • Groups that an administrator is part of
    • ADMIN_GROUPS="adm cdrom sudo dip plugdev fuse lpadmin sambashare staff_cscf"

root test functions

need_root()

  • What:
    • Make sure we are root or die
  • Arguments:
    • None
  • Returns:
    • Exit 1 on fail
  • Example:
    • need_root

  • What:
    • set enviornment, We assume common_vars and common_functions is copied there
    • export PATH=$PATH:/sbin:/usr/sbin:/usr/local/bin:
  • What:
    • List of network interfaces
    • export NETS=`ifconfig -a | grep -e "^[a-z0-9][a-z0-9]*" | cut -d' ' -f1 | sed -e "/^lo$/d"`

  • What:
    • Version number of our Ubuntu Release
    • RELEASENO=`lsb_release -rs 2>/dev/null`
  • What:
    • Day of Week
    • DAYWEEK=`date +%w`
  • What:
    • Day of Month
    • DAYMON=`date +%d`

argument processing

check_args()

  • What:
    • Arguments Processing
  • Arguments:
    • -d = debug
    • -l = logging
    • -y = yes for all default yes prompting
    • -n = no for all default no prompting
  • Returns:
    • nothing
  • Notes:
    • -d sets DEBUG=TRUE
    • -l sets LOGGING=ON
    • -y sets ANSWER=Y and DEBUG=TRUE
    • -n sets ANSWER=N and DEBUG=TRUE
  • Example:
    • check_args -d -l -y

File handeling Functions

script_name()

  • What:
    • *Echo the the absolute path of this script *
  • Example:
    • script_name

Functions that log/echo a message

sep()

  • What:
    • echo a separator using "======"
  • Example:
    • sep
    • sep

log()

  • What:
    • *Echo arguments *
  • Arguments:
    • $*
  • Example:
    • log "this is a test"

error()

  • What:
    • Echo ERROR: and arguments
  • Arguments:
    • $*
  • Example:
    • error "user made a mistake"

warn()

  • What:
    • Echo WARN: and arguments
  • Arguments:
    • $*
  • Example:
    • warn "square peg in round hole alert"

fatal()

  • What:
    • Echo ERROR: and arguments
  • Arguments:
    • $*
  • Returns:
    • Exit 1
  • Example:
    • fatal "we failed"

Functions that turn logging on or off

logging()

  • What:
    • Turn LOGGING on or off
  • Arguments:
    • OFF or ON
  • Example:
    • logging ON

logit()

  • What:
    • echo arguments - only if LOGGING or DEBUG are set
  • Arguments:
    • $@
  • Example:
    • logit "this is a test"

Functions that run a command and output a message

try()

  • What:
    • run a command and aguments, die on error, log if LOGGING is set
  • Arguments:
    • $*
    • Example
    • try stat /tmp/logfile

run()

  • What:
    • run a command and aguments
    • logs commend but only it if LOGGING is set
  • Arguments:
    • $*
  • Example:

echo_run()

  • What:
    • run a command and aguments, log always
  • Arguments:
    • $@
  • Example:

run_echo()

  • What:
    • run a command and aguments, log always
  • Arguments:
    • $@
  • Notes:
    • Only used for older scripts
  • Example:

User prompt functions

prompt_input()

  • What:
    • Prompt for input with a message
  • Arguments:
    • message
  • Returns:
    • TRUE if Y/y or or FALSE if N/n
  • Notes:
    • Diplay usage message if no arguments are present and returns FALSE
  • Example:
    • if prompt_input "Continue y/n [n]?"
    • then
    • echo "yes"
    • else"
    • echo "no"
    • fi

pause_no()

  • What:
    • Pause with default NO
  • Returns:
    • TRUE or FALSE, true = Y, false = N
  • Notes:
    • if ANSWER=N then always returns FALSE
  • Example:
    • pause_no Remove Network Manager Completely - Answer NO on laptops
    • if [ $? -eq 0 ]
    • then
    • apt-get -y purge network-manager-gnome network-manager-pptp network-mana
    • ger-pptp-gnome
    • else
    • echo skipping
    • fi

pause_yes()

  • What:
    • Pause with default YES
  • Returns:
    • TRUE or FALSE, true = Y, false = N
  • Notes:
    • if ANSWER=Y then always returns TRUE
  • Example:

pause ()

  • What:
    • Echo arguments and if DEBUG=TRUE wait for Return/Enter key
  • Arguments:
    • all argumnts are valid
  • Returns:
    • nothing
  • Example:
    • DEBUG=TRUE
    • pause "We just finished installing the software"

uprompt()

  • What:
    • Prompt for input with message and default value if any
  • Arguments:
    • [-s] message default
  • Returns:
    • TRUE with string in USER_PROMPT
    • FALSE if default is used
    • EXIT 1 if arguments unexpected
  • Notes:
    • -s will supress echo using '*' characters instead
  • Example:
    • uprompt "Enter Cost" 100
    • uprompt -s "Enter Password" "xyzzy"

hostname functions

hostbase()

  • What:
    • echo hostname without any domain parts

ip_address()

  • Arguments:
    • hostname
  • Returns:
    • address or error message
  • What:
    • echo IP address of given host

Directory related commands

absolute()

  • What:
    • Display the absolute path of a file - uses echo
  • Arguments:
    • path
  • Notes:
    • if argument is -bash then return absolute of current directory
  • Example:
    • absolute ~/file.txt

check_cd()

  • What:
    • Change directory and verify we actually end up there
  • Argument:
    • directory
  • Notes:
    • Useful if verifying permission of traget directory
  • Example:
    • check_cd /tmp/projects

expect()

  • What:
    • Expect a file/object or exit fatal error
  • Argument:
    • file/object to check
  • Returns:
    • EXIT 1 on usage error
  • Notes:
    • Display the message "Found File/object name"
  • Example:
    • expect /var/log/messages

Service Related FUnctions

update_loop()

  • What:
    • Update the maximum number of loop devices on this system
  • Arguments:
    • number of loop devices
  • Returns:
    • EXIT 1 on usage error
  • Example:
    • update_loop 512

install_service()

  • What:
    • Install a service into the /etc/init.d , etc/rc?.d/ directories
  • Arguments:
    • service_name start_level stop_level
  • Notes:
    • service name is expected to be in the current directory
    • start_level is the numeric start value: ex 80
    • stop_level is the numeric value: ex 30
    • The larger the number the later the task gets started or stopped
  • Returns:
    • EXIT 1 if arguments are missing
  • Example:
    • install_service firewall 80 30

remove_service()

  • What:
    • Remove a service
  • Arguments:
    • service_name
  • Returns:
    • EXIT 1 is arguments are missing
  • Example:
    • remove_service firewall

Ubuntu Package Functions

update_list()

  • What:
    • Update apt/dpkg package list from repositories
  • Arguments:
    • none
  • Example:
    • update_list

have_pkg()

  • What:
    • Do we have a package installed ?
  • Argument:
    • package name
  • Returns:
    • TRUE or FALSE
  • Notes:
    • Package tested with dpkg -s command
    • May miss manually installed packages with dpkg -i
  • Example:
    • if have_pkg apache2
    • then
    • echo we have apache 2 - yahoo...
    • else
    • echo we do not have the package apache2
    • fi

have_package_on_repo()

  • What:
    • Check if a package exists on the repository
  • Arguments:
    • package_name
  • Returns:
    • TRUE if package is installed, otherwise FALSE
  • Example:
    • if have_package_on_repo apache2
    • then
    • update_package apache2
    • else
    • error apache2 is not found on the repositories
    • fi

install_packages()

  • What:
    • Install packages filering list tested against repository
    • Internal function Should only be called from update_packages
  • Arguments:
    • package list
  • Example:
    • install_packages samba cups

check_packages()

  • What:
    • Do we have all of these packages installed ?
  • Arguments:
    • one or more packages
  • Returns:
    • TRUE if all are installed - or FALSE if any are not
  • Notes:
    • displays missing packages
  • Example:
    • if check_packages apache2 samba dnsmasq
    • then
    • echo we have them all
    • else
    • echo we are missing packages
    • fi

update_packages()

  • What:
    • Update/Install packages - if not already installed
  • Arguments:
    • Package List
  • Notes:
    • Installs any missing packages
  • Example:
    • update_packages apache2 samba dnsmasq

add_repo()

  • What:
    • Add ubuntu repository
  • Arguments:
    • REPOSITORY
  • Notes:
    • You must ommit the :ppa
    • Uses the add-apt-repository comment - "ppa:REPOSITORY"
  • Example:
    • add_repo richarvey/nodejs

string processing

string_contains_element()

  • What:
    • Check if a string contains any words in a list - caseless test
  • Arguments:
    • "string to examine" "list of words to test"
  • Returns:
    • TRUE or FALSE
  • Example:
    • if string_contains_element" "the sky is blue" "red yellow blue"
    • then
    • ` echo yup
    • else
    • echo nope
    • fi

escstr()

  • What:
    • Escape a string so it can be used in sed
  • Notes:
    • we escape special meta characters so sed will process them correctly
  • Example:
    • sed -e -i "s/scspcxxx/$(escstr HOSTNAME)/" /etc/hostname

GIT repository functions

need_update()

  • What:
    • Check if a directory contai8ns any files NEWER then a reference file/object
    • object is a file or directory
  • Notes:
    • recursive checks subdirectories
    • ignores any GIT substructure
  • Arguments:
    • directory reference_object
  • Returns:
    • TRUE or FALSE
  • Example:
    • if need_update /share/git/project /share/git/project/timestamed_file
    • then
    • echo files have been updated
    • else
    • echo nothing changed
    • fi

update_git()

  • What:
    • Download/Update local GIT repositories from remote source
  • Arguments:
    • GIT_URL PROJECT ...
  • Notes:
    • We have two modes
    • 1) We have a URL and muiltiple subrepositories
    • we use: git clone URL/repository repository
    • 2) We have a URL and ONE repository
    • we use: git clone URL repository
  • Example:
    • update_git git_url_base project1 project2 ..."

Environment processing functions

edit_environment()

  • What:
    • Edit PATH variable and /etc/environment file adding new search path
  • Notes:
    • *This will remove any occurence first, *
    • Then adds the argument the first setting in PATH
  • Arguments:
    • user_path
  • Example:
    • exit_environment "/usr/local/projects/bin"

update_path()

  • What:
    • Edit PATH enviroment adding new search path
  • Arguments:
    • PATH
  • Notes:
    • Removes any occurence of PATH then adds it first
  • Example:
    • update_path "/usr/local/projects/bin"

Web downloading functions

web_get()

  • What:
    • Get file from web site and place in target folder
  • Arguments:
    • URL FOLDER
  • Notes:
    • * If the file exists then get the file only if it is newer*
  • Returns:
    • FALSE if file is missing or empty, EXIT 1 if argument is missing
  • Example:
    • web_get "http://sourceforge.net/projects/clonezilla/files/latest/download?source=files" "$RAWISO/linux_utils/Clonezilla"

web_get_chown()

  • What:
    • Get file from the web and change ownership
  • Arguments:
    • URL DIR USERID GROUP
    • URL: URL of file
    • DIR: Output directory
  • USERID:
    • username
  • GROUP:
    • * groupname*
  • Returns:
    • FALSE if file is missing or empty, EXIT 1 if argument is missing
  • Example:
    • web_get_chown "$MIRROR/$REL/$f" "$RAWISO/Ubuntu/"

wget_as()

  • What:
    • Get the FILE from the download site and save as ARGUMENT
  • Arguments:
    • URL FILE
  • Returns:
    • FALSE if file is missing or empty, EXIT 1 if argument is missing
  • Notes:
    • * time stamp is NOT perserved*
    • web_get "http://sourceforge.net/projects/clonezilla/files/latest/download?source=files" "$RAWISO/linux_utils/Clonezilla"

File Processing functions

extract()

  • What:
    • extract a tar file for only certain file types
  • Arguments:
    • .tgz .tar.bz2 .tar.gz .tar
  • Returns:
    • EXIT 1 if file is missing
  • FIXME:
    • should really be removed to specific script that needs it

backup()

  • What:
    • Backup a file with .date suffix using date +%d%b%Y-HELPM
  • Arguments:
    • file
  • Returns:
    • TRUE or FALSE on success or fail or missing arguments
  • Example:
    • backup /etc/passwd

sed_file ()

  • What:
    • Edit a file with sed - passing a sed string as an argument
  • Arguments:
    • sed_commend file_name
  • Notes:
    • sed_command is a string passed to sed
  • Warning:
    • meta characters not protected - use escstr function

compare_ge()

  • What:
    • compare numeric values of two arguments
  • Arguments:
    • arg1 arg2
  • Returns:
    • TRUE if arg1 >= arg2
  • Example:
    • if compare_ge 2 1
    • then
    • echo yes
    • fi

compare_le()

  • What:
    • compare numeric values of two arguments
  • Arguments:
    • arg1 arg2
  • Returns:
    • TRUE if arg1 <= arg2
  • Example:
    • if compare_le 2 1
    • then
    • echo no
    • fi

compare_gt()

  • What:
    • compare numeric values of two arguments
  • Arguments:
    • arg1 arg2
  • Returns:
    • TRUE if arg1 > arg2
  • Example:
    • if compare_gt 2 1
    • then
    • echo yes
    • fi

compare_lt()

  • What:
    • compare numeric values of two arguments
  • Arguments:
    • arg1 arg2
  • Returns:
    • TRUE if arg1 < arg2
  • Example:
    • if compare_lt 2 1
    • then
    • echo no
    • fi

compare_eq()

  • What:
    • compare numeric values of two arguments
  • Arguments:
    • arg1 arg2
  • Returns:
    • TRUE if arg1 = arg2
  • Example:
    • if compare_eq 2 1
    • then
    • echo no
    • fi

compare_ne()

  • What:
    • compare numeric values of two arguments
  • Arguments:
    • arg1 arg2
  • Returns:
    • TRUE if arg1 = arg2
  • Example:
    • if compare_ne 2 1
    • then
    • echo yes
    • fi

Email notification functions

notify()

  • What:
    • Email a file to a user
  • Arguments:
    • SUBJECT FILE -u userid
  • Notes:
    • FILE is a file containing the message
  • Example:

SSH Control Master tools

cm_start()

  • What:
    • SSH Control Master tools
  • Arguments:
    • hostname userid
  • Usage:
    • cm_start host user
  • Sets:
    • CM_HOST=$1
    • CM_USER=$2
    • CM_PATH=socket path for COntrol Master Connection
    • CM_PATH_E=Escaped socket path for COntrol Master Connection
  • Notes:
    • Close the control master on exit using a shell trap
    • See cm_stop for an example
    • Based on work done by Richard Hansen in StackOverflow article
  • http:
    • /stackoverflow.com/questions/6447123
    • Look for Richard Hansen
  • Examples:
    • cm_start $PXEHOST $PXEUSER
    • try rsync -e "ssh -S ${CM_PATH_E}" -a "$CM_USER@$CM_HOST":/coregroup1/images/ubuntu-scripts .
    • cm_stop

cm_stop()

  • What:
    • Close the control master on exit using a shell trap
  • See:
    • cm_start
  • Resets:
    • CM_HOST
    • CM_USER
    • CM_PATH
    • CM_PATH_E

User Group Functions

get_group()

  • What:
    • get group name of userid from getent group userid
  • Arguments:
    • userid
  • Returns:
    • GRID=group entry using: getent group
    • NAME=userid

get_groups()

  • What:
    • Echo a list of groups that a user is part of
  • Arguments:
    • userid flag
  • Returns:
    • echos all of the groups a user is part of
  • Assumes:
    • system groups are <= 200 and >= 50000
  • Notes:
    • skips system groups if flag is non empty
  • Returns:
    • GRPS=group entry using: groups userid
    • NAME=userid

User Functions

get_user()

  • What:
    • Get a list of the GCOS entries from getent passwd,shadow and groups
  • Arguments:
    • userid
  • Returns:
    • NAME=userid
    • PUID=uid
    • PGID=gid
    • GRID=getent group, group entry
    • PPASS=encripted password
    • PHOME=home directory
    • PSHELL=shell
    • GRPS=groups user is part of
  • Example:
    • get_user cscf-adm

list_users()

  • What:
    • Echo a list of users - but not system users
  • Arguments:
    • none
  • Notes:
    • echos list
  • Assumes:
    • system groups are <= 200 and >= 50000
  • Uses:
    • get_user
  • Returns:
    • USERS=`egrep "^[A-Za-z0-9-]+:" /etc/passwd | cut -d: -f1 | sort -u`
  • Example:
    • VAR=`list_users`
    • # note the back tics

list_non_user_groups()

  • What:
    • Echo groups that are not userids omitting system groups
  • Arguments:
    • none
  • Returns:
    • GS=`egrep '^[A-Za-z0-9-]+:' /etc/group | cut -d: -f1 | sort -u`
  • Assumes:
    • system groups are <= 200 and >= 50000
  • Example:
    • VAR=`list_non_user_groups`
    • # note the back tics

check_user()

  • What:
    • Does a user exist -limited to non system groups
  • Uses:
    • list_users is the filter of valid users
  • Arguments:
    • userid
  • Returns:
    • TRUE or FALSE
  • Example:
    • if check_users userid
    • then
    • echo userid exists
    • fi

want_user()

  • What:
    • Does a user exist -limited to non system groups
  • Uses:
    • list_users is the filter of valid users
  • Arguments:
    • userid
  • Returns:
    • TRUE if user exists, EXIT 1 if user does NOT exist
  • Example:
    • if check_users userid
    • then
    • echo userid exists
    • fi

echo_encrypted_passwd()

  • What:
    • Echo the encrypted password for a user
    • Or - if the password is NOT set we get the value
    • From a file called accounts in the current directory
  • Arguments:
    • userid
  • Uses:
    • get_user
  • Example:
    • echo_encrypted_password userid
  • Notes:
    • Useful in setting up accounts from a file
    • Accounts file format: userid:encrypted_passwd

backup_passwd()

  • What:
    • Backup password,shadow,group and gshadow files using timestamed backup function
  • Uses:
    • backup
  • Arguments:
    • none
  • Example:
    • backup_passwd

make_admin()

  • What:
    • Add a user to all of the admin groups AND add then to the /etc/sudoers file
  • Returns:
  • Example:
    • make_admin cscf-adm

add_admin_user()

  • What:
    • Add an admin user to the PXEGROUP
  • Arguments:
    • userid home_directory_parent
  • Notes:
    • Similar to make_admin - except adds users to PXEGROUP
    • Adds them to the $ADM_GROUPS
    • Creates groups $PXEGROUPID and $PXEGROUP first if they do not exist
  • Example:
    • add_admin_user csfc-adm /
    • # Creates /cscf-adm userid adds them to PXEGROUP

Samba functions

list_samba_users()

  • What:
    • Echo Samba Users
  • Arguments:
    • none
  • Notes:
    • * Uses the filtered output of pdbedit -L -v*
  • Example:
    • list_samba_users

check_samba_user()

  • What:
    • Check if a samba user exists
  • Arguments:
    • userid
  • Returns:
    • TRUE or FALSE
  • Example:
    • if check_samba_user cscf-adm
    • then
    • echo yse the are
    • else
    • echo no they are not
    • fi

want_samba_user()

  • What:
    • Require that a samba user exists or EXIT 1
  • Returns:
    • TRUE or EXIT1 if user is missing
  • Arguments:
    • want_samba_users cscf-adm
  • Example:
    • if want_samba_users cscf-adm
    • then
    • echo have them added already
    • fi

add_samba_user()

  • What:
    • Add a samba user if not already there
  • Arguments:
    • userid
  • Prompts:
    • passsword - for userid if they do not exist
  • Notes:
    • adds the user to the $PXEGROUP
  • Example:
    • add_samba_user joeuser

add_sshkey()

  • What:
    • Add Public SSH key file to users autorized_keys2 file - used mainly for NFS shared home dircetories ina cluster
  • Arguments:
    • userid home_directory public_key_file
  • Assumes:
    • make_ssh_pub has been called first to create SSH key if none yet exists
  • Returns:
    • EXIT 1 with message if user or public key is missing
  • Notes:
    • make_ssh_pub function will assure they have a pubulic key
  • Example:
    • cscf-adm /cscf-adm /cscf-adm/.ssh/id_dsa.pub

remove_hostkey()

  • Arguments:
    • home_dir hostname
  • Returns:
    • EXIT 1 with message if user or public key is missing
  • Notes:
    • make_ssh_pub function will assure they have a pbulic key

make_sshpub()

  • What:
    • Make a DSA public key for a user - but only if they do not have one yet
  • Arguments:
    • userid
  • Returns:
    • EXIT 1 if userid is missing
  • Example:
    • make_sshpub cscf-adm

update_ssh()

  • What:
    • Create DSA SSH Keys for all non system users - but only if they do not have one
  • Arguments:
    • none
  • Notes:
    • see make_sshpub

make_users()

  • What:
    • Create a script that will recreate all non-system local users and groups for this host
  • Arguments:
    • [-noids] - removes fixed numeric gid and uid values
  • Assumes:
    • local user accounts only - does not list AD users with no local GCOS password entry
  • Uses:
    • list_users, list_non_users_groups
  • FIXME:
    • We still have to fully check that NOIDS works as intended
  • Notes:
    • will backup the passwd,shadow,group and gshadow file
  • Example:
    • make_users >create_users.sh
    • chmod 755 create_users.sh

mk_user_dirs()

  • What:
    • Adds all users, reported by list_users, to given directory
    • This is useful if users have read/write directories in more then one filesystem
  • Arguments:
    • directory
  • Notes:
    • changes user and group permissions of directory to that of the user
  • Example:
    • mk_user_dirs /data

bind_mount()

  • Notes:
    • Helpper for chrooting into a mounted filesystem - binds /prc /sys /dev .. etc into it first
  • Arguments:
    • subdirectory
  • What:
    • Bind the running OS special file systems /proc /sys /dev ... etc
    • into target folder - that must me formatted as a Linux filesystem
  • Example:
    • bind_mount /mnt/sda1

update_scripts()

  • What:
    • Copy the systems ubuntu-scripts folder into a target location
  • Uses:
    • *$PXEUSER, $PXEHOST, $UBUNTU_SCRIPTS_DIR *
  • Arguments:
    • $TARGET
  • Example:
    • update_scripts /ubuntu-scripts

Network Functions

get_nets()

  • What:
    • Get a list of network interfaces - except lo
  • Returns:
    • NETS=list of network interfaces
  • Example:
    • get_nets
    • echo $NETS

get_net()

  • What:
    • gets the settings of the specified nwtrok interface
  • Arguments:
    • interface
  • Returns:
    • NETIF=interface
    • IP=IP Address
    • NETIP=IP Address
    • NETMASK=Netmask
    • NET=$NETIP/$Netmask
    • NETSUB=Subnet - last digit of address
  • Example:
    • get_net em1
    • echo "IP:$IP, NETIP:$NETIP, NETMASK:$NETMASK, NETSUP:$NETSUB, NET:$NET"

random_passwd()

  • What:
    • iDisplay random 12 character password
  • Arguments:
    • none
  • Usage:
    • PASSWD=$( random_passwd )
  • Example:
    • PASSWD=`random_passwd`
    • # note back tics

myuwdir()

  • What:
    • *Using a UWDIR userid lookup email, full name and office *
  • Returns:
    • UWDIR_EMAIL= email address
    • UWDIR_OFFICE= office location
    • UWDIR_FULL= full name
  • Example:
    • myuwdir magore
    • echo "email:$UWDIR_EMAIL, OFFICE:$UWDIR_OFFICE, Full Name: $UWDIR_FULL"

common_host

  • Updated: Tue Nov 11 10:14:09 2014

Common HOST specific variables used for the Image Deployment System

  • common_host - document source
  • Author: Mike Gore
  • Date:
    • 28 April 2014
  • Notes:

  • What:
    • Define local Administative users, names and groups
  • Vars:
    • ADM_USERS="magore cscf-adm cscf-op"
    • ADM_USER_NAMES="'Mike Gore' 'CSCF Admin' 'CSCF OP'"
    • ADM_GROUPS="adm cdrom sudo dip plugdev fuse lpadmin sambashare smbadm"

  • What:
    • Define PXE server Hostname, Samba userid and group information
  • Vars:
    • PXEHOST=$HOSTNAME
    • PXEUSER=cscf-adm
    • PXEGROUP=smbadm
    • PXEGROUPID=444

External Network Interface

Primary Network Interface

  • What:
    • Network Interfaces - can be used to provide NFS,TFTPBOOT,DHCP,DNS
    • External Interface
  • VARS:
    • EXTIF="eth0"
  • What:
    • Private vlan
    • - must not the same as the external interface
    • - can be used for NFS,TFTPBOOT,DHCP,DNS
  • VARS:
    • INTIF="eth1"
  • What:
    • Do we NAT/Forward the INTIF network to the outside ?
  • VARS:
    • INTNAT="TRUE"

Secondary Private Network Interface

Third Private Network Interface

  • What:
    • Do we NAT/Forward the seconday INT2IF network to the outside ?
    • - must not the same as the external interface
    • - can be used for NFS,TFTPBOOT,DHCP,DNS
  • VARS:
  • What:
    • Do we NAT/Forward the seconday INT2IF network to the outside ?
  • Options:
    • TRUE or empty ""
  • VARS:
  • What:
    • Do we NAT/Forward the seconday INT2IF network to the outside ?
    • - must not the same as the external interface
    • - can be used for NFS,TFTPBOOT,DHCP,DNS
  • VARS:
  • What:
    • Do we NAT/Forward the seconday INT2IF network to the outside ?
  • Options:
    • TRUE or empty ""
  • VARS:

Firewall defines

  • Vars:
    • All addresses
    • UNIVERSE="0.0.0.0/0"
  • Vars:
    • UW Addresses spaces
    • UW_129="129.97.0.0/16"
    • UW_172="172.16.0.0/14"
    • UW_10="10.0.0.0/8"

Samba networks will allways include all private and localhost

  • networks on this machine
  • Add othernetworks here
  • Notes:
    • Format 172., 129.97.15.0/24, 129.97.16.0/255.255.255.0, $UW_129 ...
  • Vars:
    • default netwoks
    • SAMBA_DEF_NETS=""
  • Vars:
    • Samba Workgroup
    • SAMBA_WORKGROUP="CS_GENERAL"
  • Vars:
    • Samba Template file
    • SMB_CONF_TEMPLATE="/etc/samba/smb.conf.template"
  • Vars:
    • Samba config file
    • SMB_CONF=/etc/samba/smb.conf

common_vars

  • Updated: Wed Aug 5 11:49:05 2015

Common SHELL variables specific to most systems

  • common_vars - document source
  • Author: Mike Gore
  • Date:
    • 10 Apr 2015
  • Notes:
    • SHELL Variables used for the image deployment system common_shell functions
  • What:
    • Defines common directorys and names for used by image deployment system
    • network settinsg for all networks
    • dnsmasq settings
    • pxe boot directories, and user information
    • raw iso file paths, vertual iso mount directory, deployment images
    • Part of three file group: common_vars common_host common_functions

get_extif()

  • What:
    • Get IP settings for our external networks
  • Uses:
    • get_net
  • Returns:
    • NETIF=$EXTIF
    • EXTIP=$NETIP Address
    • EXTMASK=$NETMASK
    • EXTNET=$NET
    • EXTSUB=$NETSUB
    • EXT_NETWORK=$EXTIP/$EXTMASK

get_intif()

  • What:
    • Get IP settings for our main private network
  • Uses:
    • get_net
  • Returns:
    • NETIF=$INTIF
    • INTIP=$NETIP Address
    • INTMASK=$NETMASK
    • INTNET=$NET
    • INTSUB=$NETSUB
    • INT_NETWORK=$INTIP/$INTMASK
    • Main Internal Private TCP/IP network and IP address

get_int2if()

  • What:
    • Get IP settings for our seconday private network
  • Uses:
    • get_net
  • Returns:
    • NETIF=$INTIF
    • INTIP=$NETIP Address
    • INTMASK=$NETMASK
    • INTNET=$NET
    • INTSUB=$NETSUB
    • INT_NETWORK=$INTIP/$INTMASK
    • Main Internal Private TCP/IP network and IP address

get_int3if()

  • What:
    • Get IP settings for our seconday private network
  • Uses:
    • get_net
  • Returns:
    • NETIF=$INTIF
    • INTIP=$NETIP Address
    • INTMASK=$NETMASK
    • INTNET=$NET
    • INTSUB=$NETSUB
    • INT_NETWORK=$INTIP/$INTMASK
    • Main Internal Private TCP/IP network and IP address

set_samba_nets()

  • What:
    • Setup allowed Samba networks
  • Returns:
    • SAMBA_NETS=all private networks and $SAMBA_DEFS_NETS if set
    • SAMBA_IFS=all defined network interfaces
  • Notes:
  • See:
    • INT_NETWORK,INT2_NETWORK, INTIF,INT2IF

dump_vars()

  • What:
    • Dumps a list of the main configuration variables

NODES

  • Updated: Tue Aug 25 15:43:51 2015

Define hostname and ILOM hostnames for nodes a cluster excluding the head node

  • NODES - document source
  • Author: Mike Gore
  • Date:
    • 7 July 2015
  • Example:
    • . ./NODES
    • By sourcing NODES the values become part of the currently runnning shell script
  • Result:
    • Set the following envioronment variables
    • - NODES - a list of hostnames for nodes in the clutser
    • - ILOM_NODES - a list of ILOM/BMC hostnames for nodes in the clutser
    • - MASTER - head node
    • - PACKAGE_MASTER - typically a node the defines what base packages we want everywhere
Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatext NODES r1 manage 0.7 K 2015-08-26 - 13:55 MikeGore  
Unknown file formatext common_functions r1 manage 27.9 K 2015-08-26 - 13:54 MikeGore  
Unknown file formatext common_host r1 manage 2.9 K 2015-08-26 - 13:55 MikeGore  
Unknown file formatext common_vars r1 manage 2.5 K 2015-08-26 - 13:55 MikeGore  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2015-08-26 - MikeGore
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback