summaryrefslogtreecommitdiff
path: root/nfs/scripts/funcs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nfs/scripts/funcs.sh')
-rw-r--r--nfs/scripts/funcs.sh42
1 files changed, 26 insertions, 16 deletions
diff --git a/nfs/scripts/funcs.sh b/nfs/scripts/funcs.sh
index 5e27052..a69fb75 100644
--- a/nfs/scripts/funcs.sh
+++ b/nfs/scripts/funcs.sh
@@ -1,24 +1,34 @@
+# no args, let the user read useful informations on console (or skip with Enter)
+pause10s() {
+ sfx_question # sfx_* comes from /etc/rc.d/funcs helpers
+ read -t10 -p 'Press Enter or wait 10 sec...'
+ # Make some blank lines on console
+ echo -e '\n\n\n\n\n'
+}
+
# no args, print colored message, returns 0 if hostname seems valid, returns 1 if hostname is a default one
hostname_test() {
+ BADNAME='echo_color white red ">>> hostname should not contain special characters or should not be FQDN : $hostname"'
+ # This test is for security concern, hostname will be used as shell arg
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 ;;
+ "(none)"|eficast|"") echo_color white red ">>> hostname is not customized : $hostname" ; return 1 ;;
+ *\&*) $BADNAME; return 2 ;;
+ *\(*) $BADNAME; return 2 ;;
+ *\{*) $BADNAME; return 2 ;;
+ *\;*) $BADNAME; return 2 ;;
+ *\<*) $BADNAME; return 2 ;;
+ *\`*) $BADNAME; return 2 ;;
+ *\ *) $BADNAME; 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"
+ then echo_color green black ">>> NFS is read-only"
return 0
- else echo_color white blue ">>> " "NFS is read-write"
+ else echo_color white blue ">>> NFS is read-write"
return 1
fi
}
@@ -27,13 +37,13 @@ nfswrite_test() {
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)"
+ 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)"
+ usb*) echo_color white red ">>> First disk is USB ($diskinfo)"
return 1
;;
- *) echo_color white red ">>> " "First disk is unknown ($diskinfo)"
+ *) echo_color white red ">>> First disk is unknown ($diskinfo)"
return 2;
;;
esac
@@ -43,9 +53,9 @@ firstdisk_test() {
scriptavailability_test() {
script=$scriptdir/$1
if [ -r $script ]
- then echo_color green black ">>> " "Script $script is available"
+ then echo_color green black ">>> Script $script is available"
return 0
- else echo_color white blue ">>> " "Script $script is missing or unreadable"
+ else echo_color white blue ">>> Script $script is missing or unreadable"
return 1
fi
}