From 28bb55ab0fefcda941a3780845895b4907600c5a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 16 Oct 2012 08:41:06 +0000 Subject: [PATCH] update s10, create local --- bin/tc_clone_pxe.sh | 52 ++++++++++++++++++++------- bin/tc_clone_pxe_local.sh | 74 +++++++++++++++++++++++++++++++++++++++ bin/tc_clone_pxe_s10.sh | 47 ++++++++++++++++++++----- 3 files changed, 151 insertions(+), 22 deletions(-) create mode 100755 bin/tc_clone_pxe_local.sh diff --git a/bin/tc_clone_pxe.sh b/bin/tc_clone_pxe.sh index 5aad12d..7b5e341 100755 --- a/bin/tc_clone_pxe.sh +++ b/bin/tc_clone_pxe.sh @@ -2,37 +2,63 @@ set -e -MASTER=192.168.0.64 +MASTER=192.168.0.62 MASTERPATH=/mnt/custom NAME=$1 CLONE=/mnt/$NAME +FS_TYPE="ext4" + +ROOT_PART="sda1" +HOME_PART="sda2" +VAR_PART="sda5" +SWAP_PART="sda6" + + if [ ! -d $CLONE ]; then mkdir $CLONE fi -# CLONING -mount /dev/sda1 $CLONE -#df +mount /dev/$ROOT_PART $CLONE echo "rsyncing root..." rsync -a --delete --one-file-system $MASTER:$MASTERPATH/ $CLONE/ echo "rsyncing home..." -mount /dev/sda2 $CLONE/home -#df -rsync -a --exclude=/home/telecaster/archives/ --exclude=/home/telecaster/trash/ --exclude=/home/telecaster/test/ $MASTER:$MASTERPATH/home/ $CLONE/home/ +mount /dev/$HOME_PART $CLONE/home +rsync -a --delete --one-file-system --exclude=telecaster/archives/ --exclude=telecaster/trash/ --exclude=telecaster/test/ $MASTER:$MASTERPATH/home/ $CLONE/home/ umount $CLONE/home echo "rsyncing var..." -mount /dev/sda5 $CLONE/var -#df -rsync -a --delete $MASTER:$MASTERPATH/var/ $CLONE/var/ +mount /dev/$VAR_PART $CLONE/var +rsync -a --delete --one-file-system $MASTER:$MASTERPATH/var/ $CLONE/var/ + # CHROOT mount -t proc none $CLONE/proc mount -o bind /dev $CLONE/dev mount -o bind /sys $CLONE/sys +get_uuid () { +disks=/dev/disk/by-uuid +for id in `ls $disks`; do + part=`readlink -f $disks/$id` + if [ $part == /dev/$1 ]; then + echo $id + fi +done +} + +uuid=`get_uuid $ROOT_PART` +echo "UUID=$uuid / $FS_TYPE defaults,errors=remount-ro 0 1" > $CLONE/etc/fstab +uuid=`get_uuid $HOME_PART` +echo "UUID=$uuid /home $FS_TYPE defaults,errors=remount-ro 0 2" >> $CLONE/etc/fstab +uuid=`get_uuid $VAR_PART` +echo "UUID=$uuid /var $FS_TYPE defaults,errors=remount-ro 0 2" >> $CLONE/etc/fstab +uuid=`get_uuid $SWAP_PART` +echo "UUID=$uuid none swap sw 0 0" >> $CLONE/etc/fstab + +echo $NAME > $CLONE/etc/hostname + chroot $CLONE grub-install /dev/sda chroot $CLONE update-grub @@ -41,8 +67,8 @@ umount $CLONE/dev umount $CLONE/proc umount $CLONE/var -umount $CLONE -#df +umount $CLONE/ + +echo "Hello world, I'm a NEW TC-202 clone ! B-)" -echo "Hello world, I'm an NEW TC clone ! :)" diff --git a/bin/tc_clone_pxe_local.sh b/bin/tc_clone_pxe_local.sh new file mode 100755 index 0000000..cc3af46 --- /dev/null +++ b/bin/tc_clone_pxe_local.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -e + +MASTER=127.0.0.1 +MASTERPATH=/mnt/custom +NAME=$1 +CLONE=/mnt/$NAME + +FS_TYPE="ext4" + +ROOT_PART="sdb1" +HOME_PART="sdb2" +VAR_PART="sdb5" +SWAP_PART="sdb6" + + +if [ ! -d $CLONE ]; then + mkdir $CLONE +fi + +mount /dev/$ROOT_PART $CLONE +echo "rsyncing root..." +rsync -a --delete --one-file-system $MASTER:$MASTERPATH/ $CLONE/ + +echo "rsyncing home..." +mount /dev/$HOME_PART $CLONE/home +rsync -a --delete --one-file-system --exclude=telecaster/archives/ --exclude=telecaster/trash/ --exclude=telecaster/test/ $MASTER:$MASTERPATH/home/ $CLONE/home/ +umount $CLONE/home + +echo "rsyncing var..." +mount /dev/$VAR_PART $CLONE/var +rsync -a --delete --one-file-system $MASTER:$MASTERPATH/var/ $CLONE/var/ + + +# CHROOT +mount -t proc none $CLONE/proc +mount -o bind /dev $CLONE/dev +mount -o bind /sys $CLONE/sys + +get_uuid () { +disks=/dev/disk/by-uuid +for id in `ls $disks`; do + part=`readlink -f $disks/$id` + if [ $part == /dev/$1 ]; then + echo $id + fi +done +} + +uuid=`get_uuid $ROOT_PART` +echo "UUID=$uuid / $FS_TYPE defaults,errors=remount-ro 0 1" > $CLONE/etc/fstab +uuid=`get_uuid $HOME_PART` +echo "UUID=$uuid /home $FS_TYPE defaults,errors=remount-ro 0 2" >> $CLONE/etc/fstab +uuid=`get_uuid $VAR_PART` +echo "UUID=$uuid /var $FS_TYPE defaults,errors=remount-ro 0 2" >> $CLONE/etc/fstab +uuid=`get_uuid $SWAP_PART` +echo "UUID=$uuid none swap sw 0 0" >> $CLONE/etc/fstab + +echo $NAME > $CLONE/etc/hostname + +chroot $CLONE grub-install /dev/sda +chroot $CLONE update-grub + +umount $CLONE/sys +umount $CLONE/dev +umount $CLONE/proc + +umount $CLONE/var +umount $CLONE/ + +echo "Hello world, I'm a NEW TC-202 clone ! B-)" + + diff --git a/bin/tc_clone_pxe_s10.sh b/bin/tc_clone_pxe_s10.sh index 8cd6253..7b5e341 100755 --- a/bin/tc_clone_pxe_s10.sh +++ b/bin/tc_clone_pxe_s10.sh @@ -7,29 +7,58 @@ MASTERPATH=/mnt/custom NAME=$1 CLONE=/mnt/$NAME +FS_TYPE="ext4" + +ROOT_PART="sda1" +HOME_PART="sda2" +VAR_PART="sda5" +SWAP_PART="sda6" + + if [ ! -d $CLONE ]; then mkdir $CLONE fi -mount /dev/sda1 $CLONE +mount /dev/$ROOT_PART $CLONE echo "rsyncing root..." rsync -a --delete --one-file-system $MASTER:$MASTERPATH/ $CLONE/ echo "rsyncing home..." -mount /dev/sda3 $CLONE/home -rsync -a --delete --exclude=telecaster/archives/ --exclude=telecaster/trash/ --exclude=telecaster/test/ $MASTER:$MASTERPATH/home/ $CLONE/home/ +mount /dev/$HOME_PART $CLONE/home +rsync -a --delete --one-file-system --exclude=telecaster/archives/ --exclude=telecaster/trash/ --exclude=telecaster/test/ $MASTER:$MASTERPATH/home/ $CLONE/home/ umount $CLONE/home echo "rsyncing var..." -rsync -a --delete $MASTER:$MASTERPATH/var/ $CLONE/var/ +mount /dev/$VAR_PART $CLONE/var +rsync -a --delete --one-file-system $MASTER:$MASTERPATH/var/ $CLONE/var/ + # CHROOT mount -t proc none $CLONE/proc mount -o bind /dev $CLONE/dev mount -o bind /sys $CLONE/sys -chroot $CLONE ls -tl /dev/disk/by-uuid >> /etc/fstab -chroot $CLONE vi /etc/fstab +get_uuid () { +disks=/dev/disk/by-uuid +for id in `ls $disks`; do + part=`readlink -f $disks/$id` + if [ $part == /dev/$1 ]; then + echo $id + fi +done +} + +uuid=`get_uuid $ROOT_PART` +echo "UUID=$uuid / $FS_TYPE defaults,errors=remount-ro 0 1" > $CLONE/etc/fstab +uuid=`get_uuid $HOME_PART` +echo "UUID=$uuid /home $FS_TYPE defaults,errors=remount-ro 0 2" >> $CLONE/etc/fstab +uuid=`get_uuid $VAR_PART` +echo "UUID=$uuid /var $FS_TYPE defaults,errors=remount-ro 0 2" >> $CLONE/etc/fstab +uuid=`get_uuid $SWAP_PART` +echo "UUID=$uuid none swap sw 0 0" >> $CLONE/etc/fstab + +echo $NAME > $CLONE/etc/hostname + chroot $CLONE grub-install /dev/sda chroot $CLONE update-grub @@ -37,9 +66,9 @@ umount $CLONE/sys umount $CLONE/dev umount $CLONE/proc -#umount $CLONE/var -umount $CLONE +umount $CLONE/var +umount $CLONE/ -echo "Hello world, I'm a NEW TC (s10) clone ! :)\nDon't forget to update /etc/fstab in the chroot !" +echo "Hello world, I'm a NEW TC-202 clone ! B-)" -- 2.39.5