summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic.pouzenc@mines-albi.fr>2017-10-27 17:00:11 +0200
committerLudovic Pouzenc <ludovic.pouzenc@mines-albi.fr>2017-10-27 17:00:11 +0200
commit6f39be0aae716a86b410556630ac48ed4da4c6f5 (patch)
treeffc58082a84e332ce0aa3ee2c6299a4b221eed4d
parent211e646859ee028a0a66b67c96057a2f1a6a82ba (diff)
downloadeficast-6f39be0aae716a86b410556630ac48ed4da4c6f5.tar.gz
eficast-6f39be0aae716a86b410556630ac48ed4da4c6f5.tar.bz2
eficast-6f39be0aae716a86b410556630ac48ed4da4c6f5.zip
capture and deploy script updates (not finished yet)
-rw-r--r--nfs/scripts/image_capture.sh6
-rw-r--r--nfs/scripts/image_capture_I4920.sh15
-rw-r--r--nfs/scripts/image_deploy.sh33
-rw-r--r--nfs/scripts/image_deploy_I4920.sh19
-rw-r--r--nfs/scripts/image_deploy_I5456.sh22
5 files changed, 93 insertions, 2 deletions
diff --git a/nfs/scripts/image_capture.sh b/nfs/scripts/image_capture.sh
index 53c75ad..47aad9c 100644
--- a/nfs/scripts/image_capture.sh
+++ b/nfs/scripts/image_capture.sh
@@ -14,7 +14,11 @@ cd "$outdir"
mkdir logs
date >logs/date.log
-# Start the capture using the customized script (image_capture_<hostname>.sh)
+# Print all variables and start the capture using the customized script (image_capture_<hostname>.sh)
+setterm -bold on
+env
+setterm -bold off
+echo_color green black "$scriptdir/image_capture_${hostname}.sh script will run on tty1 now"
source $scriptdir/image_capture_${hostname}.sh
date >>logs/date.log
diff --git a/nfs/scripts/image_capture_I4920.sh b/nfs/scripts/image_capture_I4920.sh
new file mode 100644
index 0000000..8f70b26
--- /dev/null
+++ b/nfs/scripts/image_capture_I4920.sh
@@ -0,0 +1,15 @@
+#!/bin/busybox sh
+# Should only started from image_capture.sh, it defines some helper functions and variables)
+# echo_color() <text-color> <background-color> [prefix text] <message>
+# $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"
+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"
+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"
+partclone.ntfs --clone -s /dev/sda2 -L logs/sda2-partclone.log --no_check | pigz --fast >sda2-partclone.gz 2>logs/sda2-pigz.log
+
diff --git a/nfs/scripts/image_deploy.sh b/nfs/scripts/image_deploy.sh
index 4efd715..e23fd70 100644
--- a/nfs/scripts/image_deploy.sh
+++ b/nfs/scripts/image_deploy.sh
@@ -1,4 +1,35 @@
#!/bin/busybox sh
# Should only started from autorun.sh (define some helper functions and variables)
-echo_color white red ">>> Image deploy not yet ready"
+# Prepare deploy
+year=$(date +%Y)
+monthday=$(date +%m-%d)
+
+# define what master image should be used for the current client machine
+#TODO : have a better place for that (CMDB...)
+case "$hostname" in
+ I5480) mastername=pctp-master ;;
+ *) mastername=I4920 ;;
+# *) echo_color white red ">>> " "No master for $hostname (see image_deploy.sh)" ; exit 1 ;;
+esac
+
+# Determine which image take
+#TODO : have a better place for that (CMDB...)
+ls -ld "$imagedir/$year/$mastername/"
+
+indir=$(find "$imagedir/$year/$mastername/" -maxdepth 1 -type d -regex '.*/\d\d-\d\d' | sort -rn | head -n1)
+# Put a bad value to help the user to see where the image should be available
+indir=${indir:-$imagedir/$year/$mastername/XX-XX}
+
+# Check and print if the deploy script is defined for the current master machine
+scriptavailability_test image_deploy_${mastername}.sh || exit $?
+diravailability_test $indir || exit $?
+
+# Print all variables and start the deploy using the customized script (image_deploy_<hostname>.sh)
+setterm -bold on
+env
+setterm -bold off
+echo_color green black "$scriptdir/image_deploy_${mastername}.sh script will run on tty1 now"
+
+source $scriptdir/image_deploy_${mastername}.sh
+
diff --git a/nfs/scripts/image_deploy_I4920.sh b/nfs/scripts/image_deploy_I4920.sh
new file mode 100644
index 0000000..1cd3220
--- /dev/null
+++ b/nfs/scripts/image_deploy_I4920.sh
@@ -0,0 +1,19 @@
+#!/bin/busybox sh
+# Should only started from image_capture.sh, it defines some helper functions and variables)
+# echo_color() <text-color> <background-color> [prefix text] <message>
+# $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 ">>> " "Restoring /dev/sda boot sectors"
+pigz -dc "$indir/sda-dd.gz" | dd of=/dev/sda count=2048
+
+echo_color white blue ">>> " "Detecting new partitions"
+echo -e "w\nq\n" | fdisk /dev/sda
+
+echo_color white blue ">>> " "Restoring /dev/sda1 NTFS BOOT"
+pigz -dc "$indir/sda1-partclone.gz" | partclone.restore -o /dev/sda1
+
+echo_color white blue ">>> " "Restoring /dev/sda2 NTFS WINDOWS"
+pigz -dc "$indir/sda2-partclone.gz" | partclone.restore -o /dev/sda2
+
+
diff --git a/nfs/scripts/image_deploy_I5456.sh b/nfs/scripts/image_deploy_I5456.sh
new file mode 100644
index 0000000..b151af9
--- /dev/null
+++ b/nfs/scripts/image_deploy_I5456.sh
@@ -0,0 +1,22 @@
+#!/bin/busybox sh
+# Should only started from image_capture.sh, it defines some helper functions and variables)
+# echo_color() <text-color> <background-color> [prefix text] <message>
+# $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 ">>> " "Restoring /dev/sda boot sectors"
+pigz -dc "$indir/sda-dd.gz" | dd of=/dev/sda count=2048
+
+echo_color white blue ">>> " "Detecting new partitions"
+echo -e "w\nq\n" | fdisk /dev/sda
+
+echo_color white blue ">>> " "Restoring /dev/sda1 NTFS BOOT"
+pigz -dc "$indir/sda1-partclone.gz" | partclone.restore -o /dev/sda1
+
+echo_color white blue ">>> " "Restoring /dev/sda2 NTFS WINDOWS"
+pigz -dc "$indir/sda2-partclone.gz" | partclone.restore -o /dev/sda2
+
+echo_color white blue ">>> " "Restoring /dev/sda3 EXT4 LINUX"
+pigz -dc "$indir/sda3-partclone.gz" | partclone.restore -o /dev/sda3
+
+