Commit c28a889b authored by Marco Marinello's avatar Marco Marinello

Allow user to check configuration before start cloning

Signed-off-by: Marco Marinello's avatarMarco Marinello <me@marcomarinello.it>
parent 56fab59f
......@@ -8,7 +8,7 @@
# Last modified 07 May 2019 --> added various stuff for experimental autojoin to a domain
# Last modified 21 June 2019 --> added various stuff for experimental join to a cluster
# Last modified 01 July 2019 --> added ssh to script and changed disk detection method
#
#
# PRT 1 ---------------------------
service ssh start
......@@ -41,7 +41,7 @@ getDisk(){
else
diskVar="$(echo $myDevice | tr -d [:blank:])"
fi
# SSD of HP g450 laptops
if [ $diskVar == "nvme0n1" ];then
rootPartition="p$rootPartition"
......@@ -56,6 +56,19 @@ mountPoint="/mnt"
computerList="/home/partimag/computerList.txt"
macAddress=$(getNetStuff 2)
if [ "$1" = "check" ]; then
myLine=$(grep $macAddress $computerList | tail -1)
hostname=$(echo $myLine | awk '{print $1}')
img=$(echo $myLine | awk '{print $3}')
join=$(echo $myLine | awk '{print $4}')
cluster=$(echo $myLine | awk '{print $5}')
if ! dialog --title "FUSS FUCC" --yesno "Hostname: $hostname \nMAC: $macAddress \nImage: $img \nJoin: $join \nCluster: $cluster \nContinue?" 13 70; then
grep -v $macAddress $computerList > ${computerList}.new
cp ${computerList}.new ${computerList}
rm ${computerList}.new
fi
fi
if ! grep $macAddress $computerList; then
dialog --title "FUSS FUCC" --msgbox "Hi,\nunfortunatley, there is no valid configuration to setup this computer. Please go through the next few steps to configure how to install this PC.\nPlease make sure that the file /home/clonezilla/computerList.txt is owned and writable by clonezilla, otherwise we'll not be able to save the informations you're going to enter." 13 70
hostname=$(dialog --title "FUSS FUCC" --inputbox "Please, pick an HOSTNAME for this PC" --output-fd 1 10 70)
......@@ -89,16 +102,16 @@ mount $rootDisk$rootPartition $mountPoint
currentName="$(cat $mountPoint/etc/hostname)"
newName="$(grep "$macAddress" $computerList | awk '{print $1}')"
echo "SETTING HOSTNAME"
echo "SETTING HOSTNAME"
for i in hostname hosts mailname
do
if [ -e $mountPoint/etc/$i ]; then
sed -ie "s/$currentName/$newName/g" $mountPoint/etc/$i
else
echo "The file $i is not present on this system"
fi
fi
done
......@@ -106,7 +119,7 @@ done
# ### Here I insert the part for the joining preparation of the machine
# Verify whether the machine has to be joined to the domain or not.
# If so the .ssh keys are needed and also a script .....
# If so the .ssh keys are needed and also a script .....
joinVar="$(cat $computerList | grep "$macAddress" | awk '{print $4}')"
......@@ -136,5 +149,3 @@ fi
reboot
# BEGIN ANSIBLE MANAGED (default)
DEFAULT menu.c32
MENU MASTER PASSWD myPassword
# END ANSIBLE MANAGED (default)
#timeout 15
label Clonezilla-unattended
MENU LABEL Clonezilla Automatico (Ramdisk)
# Please remove the ssh key from .ssh/authorized_keys of the clonezilla
......@@ -11,6 +7,14 @@ MENU LABEL Clonezilla Automatico (Ramdisk)
KERNEL clonezilla/live/vmlinuz
APPEND initrd=clonezilla/live/initrd.img boot=live username=clonezilla union=overlay config components quiet noswap edd=on nomodeset nodmraid locales= keyboard-layouts=NONE ocs_live_batch=no net.ifnames=0 nosplash noprompt keyboard-layouts=it locales=it_IT.UTF-8 ocs_prerun1="sshfs clonezilla@proxy:/srv/clonezilla /home/partimag -o IdentityFile=/home/clonezilla/.ssh/id_rsa -o StrictHostKeyChecking=no" ocs_prerun2="screen -S XY '/home/partimag/script' " fetch=tftp://proxy/clonezilla/live/filesystem.squashfs
label Clonezilla-confirm
MENU LABEL Clonezilla Automatico con conferma (Ramdisk)
# Please remove the ssh key from .ssh/authorized_keys of the clonezilla
# user instead of using this line!
# MENU PASSWD myPassword
KERNEL clonezilla/live/vmlinuz
APPEND initrd=clonezilla/live/initrd.img boot=live username=clonezilla union=overlay config components quiet noswap edd=on nomodeset nodmraid locales= keyboard-layouts=NONE ocs_live_batch=no net.ifnames=0 nosplash noprompt keyboard-layouts=it locales=it_IT.UTF-8 ocs_prerun1="sshfs clonezilla@proxy:/srv/clonezilla /home/partimag -o IdentityFile=/home/clonezilla/.ssh/id_rsa -o StrictHostKeyChecking=no" ocs_prerun2="screen -S XY '/home/partimag/script check' " fetch=tftp://proxy/clonezilla/live/filesystem.squashfs
label Clonezilla-Manuale
MENU LABEL Clonezilla Manuale (Ramdisk)
# Please remove the ssh key from .ssh/authorized_keys of the clonezilla
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment