diff options
author | Ludovic Pouzenc <ludovic.pouzenc@mines-albi.fr> | 2017-07-21 17:13:09 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic.pouzenc@mines-albi.fr> | 2017-07-21 17:13:09 +0200 |
commit | e26f916388a1383dfcfc0b178550f84c8cde352f (patch) | |
tree | d768aff8e42a458c5083846ac88b53ff2376c917 /nfs/scripts/funcs.sh | |
parent | afb7ee8cc6232ceda7a5810b9d285ceff857b0b6 (diff) | |
download | eficast-e26f916388a1383dfcfc0b178550f84c8cde352f.tar.gz eficast-e26f916388a1383dfcfc0b178550f84c8cde352f.tar.bz2 eficast-e26f916388a1383dfcfc0b178550f84c8cde352f.zip |
Add post-boot scripting (work in progress)
Diffstat (limited to 'nfs/scripts/funcs.sh')
-rw-r--r-- | nfs/scripts/funcs.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/nfs/scripts/funcs.sh b/nfs/scripts/funcs.sh new file mode 100644 index 0000000..5e27052 --- /dev/null +++ b/nfs/scripts/funcs.sh @@ -0,0 +1,52 @@ +# no args, print colored message, returns 0 if hostname seems valid, returns 1 if hostname is a default one +hostname_test() { + case $hostname in + "(none)"|eficast|"") echo_color white red ">>> " "hostname is not customized : $hostname" ; return 1 ;; + *\&*) echo_color white red ">>> " "hostname should not contain special characters or should not be FQDN : $hostname" ; return 2 ;; + *\(*) echo_color white red ">>> " "hostname should not contain special characters or should not be FQDN : $hostname" ; return 2 ;; + *\{*) echo_color white red ">>> " "hostname should not contain special characters or should not be FQDN : $hostname" ; return 2 ;; + *\;*) echo_color white red ">>> " "hostname should not contain special characters or should not be FQDN : $hostname" ; return 2 ;; + *\<*) echo_color white red ">>> " "hostname should not contain special characters or should not be FQDN : $hostname" ; return 2 ;; + *\`*) echo_color white red ">>> " "hostname should not contain special characters or should not be FQDN : $hostname" ; return 2 ;; + *\ *) echo_color white red ">>> " "hostname should not contain special characters or should not be FQDN : $hostname" ; return 2 ;; + *) echo_color green black ">>> " "hostname is $hostname" ; return 0 ;; + esac +} + +# no args, print colored message, returns 0 if NFS is read-only, returns 1 if NFS is read-write (needed for image capture) +nfswrite_test() { + if ! touch /mnt/nfs/.writetest + then echo_color green black ">>> " "NFS is read-only" + return 0 + else echo_color white blue ">>> " "NFS is read-write" + return 1 + fi +} + +# no args, print colored message, returns 0 if sda is present and is sata, returns >0 if it is not +firstdisk_test() { + diskinfo=$(lsblk --list --output TRAN,MODEL --noheadings --nodeps /dev/sda) + case $diskinfo in + sata*) echo_color green black ">>> " "First disk is SATA and is available ($diskinfo)" + return 0 + ;; + usb*) echo_color white red ">>> " "First disk is USB ($diskinfo)" + return 1 + ;; + *) echo_color white red ">>> " "First disk is unknown ($diskinfo)" + return 2; + ;; + esac +} + +# $1 : scriptname, print colored message, returns 0 script is available, returns 1 if not +scriptavailability_test() { + script=$scriptdir/$1 + if [ -r $script ] + then echo_color green black ">>> " "Script $script is available" + return 0 + else echo_color white blue ">>> " "Script $script is missing or unreadable" + return 1 + fi +} + |