]> git.parisson.com Git - telecaster-cloning.git/commitdiff
update s10, create local
authorroot <root@rescue64.(none)>
Tue, 16 Oct 2012 08:41:06 +0000 (08:41 +0000)
committerroot <root@rescue64.(none)>
Tue, 16 Oct 2012 08:41:06 +0000 (08:41 +0000)
bin/tc_clone_pxe.sh
bin/tc_clone_pxe_local.sh [new file with mode: 0755]
bin/tc_clone_pxe_s10.sh

index 5aad12d6850a88a4da111485cf841405d8d92758..7b5e3412f791670f4183de6bd2393bc7fd8ada31 100755 (executable)
@@ -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 (executable)
index 0000000..cc3af46
--- /dev/null
@@ -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-)"
+
+
index 8cd6253353164572f0429323a594646e7ccacbb5..7b5e3412f791670f4183de6bd2393bc7fd8ada31 100755 (executable)
@@ -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-)"