summaryrefslogtreecommitdiff
path: root/nfs
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2017-10-22 13:31:10 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2017-10-22 13:31:10 +0200
commit8142ffde3037976e152711f902ad9622aa1b7cba (patch)
tree1a113379f90812b13acc411bb1280e13b00a217a /nfs
parentae649a17227f3ed2615f3d8eddc7ae19ccfaa45b (diff)
downloadeficast-8142ffde3037976e152711f902ad9622aa1b7cba.tar.gz
eficast-8142ffde3037976e152711f902ad9622aa1b7cba.tar.bz2
eficast-8142ffde3037976e152711f902ad9622aa1b7cba.zip
hours of polishing tmux, script sequences, hinting. ^C abort in tmux is broken.
Diffstat (limited to 'nfs')
-rwxr-xr-xnfs/nfs-autorun.sh (renamed from nfs/autorun.sh)14
-rw-r--r--nfs/scripts/funcs.sh42
-rw-r--r--nfs/scripts/image_capture_I5456.sh8
-rw-r--r--nfs/scripts/image_deploy.sh2
4 files changed, 34 insertions, 32 deletions
diff --git a/nfs/autorun.sh b/nfs/nfs-autorun.sh
index ad99a8e..b2be8b2 100755
--- a/nfs/autorun.sh
+++ b/nfs/nfs-autorun.sh
@@ -1,20 +1,12 @@
#!/bin/busybox sh
-rest10() {
- # Let the user read machine_info and other usefull informations on console (or skip with Enter)
- sfx_question ; read -t10 -p 'Press Enter or wait 10 sec...'
- # Make some blank lines on console
- echo -e '\n\n\n\n\n'
-}
-
# Define some handy variables
imagedir=/mnt/nfs/images
scriptdir=/mnt/nfs/scripts/
hostname=$(hostname)
# Load helper functions
-source $scriptdir/funcs.sh # Load some autorun.sh specific helper functions
-source /etc/rc.d/funcs # Reload init help functions
+source $scriptdir/funcs.sh # Load some nfs-autorun.sh specific helper functions
# Check all prerequisites and exit if it fail
hostname_test || exit 1
@@ -23,9 +15,9 @@ firstdisk_test || exit 2
# Run the main action script
if nfswrite_test
then # Start deploy script after letting a chance to cancel it
- rest10 ; source $scriptdir/image_deploy.sh
+ pause10s ; source $scriptdir/image_deploy.sh
else scriptavailability_test image_capture_${hostname}.sh || exit 3
# Start capture script if all it needs is available
- rest10 ; source $scriptdir/image_capture.sh
+ pause10s ; source $scriptdir/image_capture.sh
fi
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
}
diff --git a/nfs/scripts/image_capture_I5456.sh b/nfs/scripts/image_capture_I5456.sh
index bc40a51..9895edd 100644
--- a/nfs/scripts/image_capture_I5456.sh
+++ b/nfs/scripts/image_capture_I5456.sh
@@ -4,16 +4,16 @@
# $outdir is the also the current working dir, garanted to be empty and writable
# Many cloning/partitioning tools are available for use, see make-boot-image.sh
-echo_color white blue ">>> " "Capturing /dev/sda boot sectors"
+echo_color white blue ">>> Capturing /dev/sda boot sectors"
dd if=/dev/sda count=2048 2>logs/sda-dd.log | pigz --fast > sda-dd.gz 2>logs/sda-pigz.log
-echo_color white blue ">>> " "Capturing /dev/sda1 NTFS BOOT"
+echo_color white blue ">>> Capturing /dev/sda1 NTFS BOOT"
partclone.ntfs --clone -s /dev/sda1 -L logs/sda1-partclone.log --no_check | pigz --fast >sda1-partclone.gz 2>logs/sda1-pigz.log
-echo_color white blue ">>> " "Capturing /dev/sda2 NTFS WINDOWS"
+echo_color white blue ">>> Capturing /dev/sda2 NTFS WINDOWS"
partclone.ntfs --clone -s /dev/sda2 -L logs/sda2-partclone.log --no_check | pigz --fast >sda2-partclone.gz 2>logs/sda2-pigz.log
-echo_color white blue ">>> " "Capturing /dev/sda3 EXT4 LINUX"
+echo_color white blue ">>> Capturing /dev/sda3 EXT4 LINUX"
partclone.ext4 --clone -s /dev/sda3 -L logs/sda3-partclone.log --no_check | pigz --fast >sda3-partclone.gz 2>logs/sda3-pigz.log
diff --git a/nfs/scripts/image_deploy.sh b/nfs/scripts/image_deploy.sh
index bdc5e9c..4efd715 100644
--- a/nfs/scripts/image_deploy.sh
+++ b/nfs/scripts/image_deploy.sh
@@ -1,4 +1,4 @@
#!/bin/busybox sh
# Should only started from autorun.sh (define some helper functions and variables)
-echo_color white red ">>> " "Image deploy not yet ready"
+echo_color white red ">>> Image deploy not yet ready"