]> git.parisson.com Git - clone-me.git/commitdiff
init
authorGuillaume Pellerin <yomguy@parisson.com>
Wed, 20 Nov 2013 14:26:59 +0000 (15:26 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Wed, 20 Nov 2013 14:26:59 +0000 (15:26 +0100)
fix_fstab.sh [new file with mode: 0755]
tc_clone.sh [new file with mode: 0755]
tc_clone_pxe.sh [new file with mode: 0755]
tc_clone_pxe_local.sh [new file with mode: 0755]
tc_clone_pxe_s10.sh [new file with mode: 0755]
tc_clone_update_pxe.sh [new file with mode: 0755]
tc_clone_update_pxe_s10.sh [new file with mode: 0755]
tc_mount_master.sh [new file with mode: 0755]
tc_umount_master.sh [new file with mode: 0755]

diff --git a/fix_fstab.sh b/fix_fstab.sh
new file mode 100755 (executable)
index 0000000..ea337d6
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -e
+
+MASTER=192.168.0.64
+MASTERPATH=/mnt/custom
+NAME=$1
+CLONE=/mnt/$NAME
+
+if [ ! -d $CLONE ]; then
+ mkdir $CLONE
+fi
+
+echo "Please enter the type of all system partitions (i.e. xfs, ext4 or other):"
+FS_TYPE="ext4"
+
+echo "Please enter the ROOT partition name (i.e. sda1 or other):"
+ROOT_PART="sda1"
+
+echo "Please enter the HOME partition name (i.e. sda2 or other):"
+HOME_PART="sda2"
+
+echo "Please enter the VAR partition name (i.e. sda5 or other, or the same as the ROOT one if included):"
+VAR_PART="sda5"
+
+echo "Please enter the SWAP partition name (i.e. sda6 or other):"
+SWAP_PART="sda7"
+
+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
+if [ ! $VAR_PART == $ROOT_PART ]; then
+ uuid=`get_uuid $VAR_PART`
+ echo "UUID=$uuid    /var    $FS_TYPE    defaults,errors=remount-ro    0       2" >> $CLONE/etc/fstab
+fi
+uuid=`get_uuid $SWAP_PART`
+echo "UUID=$uuid    none    swap    sw    0       0" >> $CLONE/etc/fstab
+
+
+echo "Hello world, I'm an NEW TC clone ! :)"
+
diff --git a/tc_clone.sh b/tc_clone.sh
new file mode 100755 (executable)
index 0000000..9b99a2a
--- /dev/null
@@ -0,0 +1,101 @@
+#!/bin/bash
+
+set -e
+
+MASTER=192.168.0.64
+MASTERPATH=/mnt/custom
+
+if [ ! -d $CLONE ]; then
+ mkdir $CLONE
+fi
+
+echo "Please enter the target system name:"
+read NAME
+
+echo "Please enter the type of all system partitions (i.e. xfs, ext4 or other):"
+read FS_TYPE
+
+echo "Please enter the ROOT partition name (i.e. sda1 or other):"
+read ROOT_PART
+
+echo "Please enter the HOME partition name (i.e. sda2 or other):"
+read HOME_PART
+
+echo "Please enter the VAR partition name (i.e. sda5 or other):"
+read VAR_PART
+
+echo "Please enter the SWAP partition name (i.e. sda6 or other):"
+read SWAP_PART
+
+CLONE=/mnt/$NAME
+
+# CLONING
+mount /dev/$ROOT_PART $CLONE
+echo "rsyncing root..."
+rsync -a --delete --one-file-system $MASTER:$MASTERPATH/ $CLONE/
+
+echo "rsyncing home..."
+DEST=$CLONE/home
+if [ ! -d $DEST ]; then
+ mkdir $DEST
+fi
+mount /dev/$HOME_PART $DEST
+rsync -a --exclude=$MASTER:/home/telecaster/archives/ --exclude=$MASTER:/home/telecaster/trash/ \
+     --exclude=$MASTER:/home/telecaster/test/ $MASTER:$MASTERPATH/home/ $CLONE/home/
+umount $CLONE/home
+
+echo "rsyncing var..."
+DEST=$CLONE/var
+if [ ! -d $DEST ]; then
+ mkdir $DEST
+fi
+if [ ! $VAR_PART == $ROOT_PART ]; then
+ mount /dev/$VAR_PART $CLONE/var
+fi
+rsync -a --delete $MASTER:$MASTERPATH/var/ $CLONE/var/
+
+
+# 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
+if [ ! $VAR_PART == $ROOT_PART ]; then
+ uuid=`get_uuid $VAR_PART`
+ echo "UUID=$uuid    /var    $FS_TYPE    defaults,errors=remount-ro    0       2" >> $CLONE/etc/fstab
+fi
+uuid=`get_uuid $SWAP_PART`
+echo "UUID=$uuid    none    swap    sw    0       0" >> $CLONE/etc/fstab
+
+echo $NAME > $CLONE/etc/hostname
+
+# CHROOT
+mount -t proc none $CLONE/proc
+mount -o bind /dev $CLONE/dev
+mount -o bind /sys $CLONE/sys
+
+# GRUB
+chroot $CLONE grub-install /dev/sda
+chroot $CLONE update-grub
+
+# UMOUNT
+umount $CLONE/sys
+umount $CLONE/dev
+umount $CLONE/proc
+
+umount $CLONE/var
+umount $CLONE
+
+echo "Hello world, I'm an NEW TC clone ! :)"
+
+
diff --git a/tc_clone_pxe.sh b/tc_clone_pxe.sh
new file mode 100755 (executable)
index 0000000..7b5e341
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+set -e
+
+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
+
+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/tc_clone_pxe_local.sh b/tc_clone_pxe_local.sh
new file mode 100755 (executable)
index 0000000..0b72b87
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+set -e
+
+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 $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/ $MASTERPATH/home/ $CLONE/home/
+umount $CLONE/home
+
+echo "rsyncing var..."
+mount /dev/$VAR_PART $CLONE/var
+rsync -a --delete --one-file-system $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/sdb
+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/tc_clone_pxe_s10.sh b/tc_clone_pxe_s10.sh
new file mode 100755 (executable)
index 0000000..7b5e341
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+set -e
+
+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
+
+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/tc_clone_update_pxe.sh b/tc_clone_update_pxe.sh
new file mode 100755 (executable)
index 0000000..036339b
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+set -e
+
+MASTER=192.168.0.64
+MASTERPATH=/mnt/custom
+NAME=$1
+CLONE=/mnt/$NAME
+
+if [ ! -d $CLONE ]; then
+ mkdir $CLONE
+fi
+
+# CLONING
+mount /dev/sda1 $CLONE
+echo "rsyncing root..."
+rsync -a --delete --one-file-system --exclude=/etc/fstab --exclude=/etc/hostname --exclude=/etc/hosts $MASTER:$MASTERPATH/ $CLONE/
+
+echo "rsyncing home..."
+mount /dev/sda2 $CLONE/home
+rsync -a --delete --exclude=telecaster/archives --exclude=telecaster/trash --exclude=telecaster/bin --exclude=home/telecaster/test --exclude=networkmanagement $MASTER:$MASTERPATH/home/ $CLONE/home/
+umount $CLONE/home
+
+echo "rsyncing var..."
+mount /dev/sda5 $CLONE/var
+rsync -a --delete $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 grub-install /dev/sda
+chroot $CLONE update-grub
+
+umount $CLONE/sys
+umount $CLONE/dev
+umount $CLONE/proc
+
+umount $CLONE/var
+umount $CLONE
+
+echo "OK, I'm an updated TC clone!"
+
diff --git a/tc_clone_update_pxe_s10.sh b/tc_clone_update_pxe_s10.sh
new file mode 100755 (executable)
index 0000000..8a96158
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+set -e
+
+MASTER=192.168.0.62
+MASTERPATH=/mnt/custom
+NAME=$1
+CLONE=/mnt/$NAME
+
+if [ ! -d $CLONE ]; then
+ mkdir $CLONE
+fi
+
+mount /dev/sda1 $CLONE
+echo "rsyncing root..."
+rsync -a --delete --one-file-system --exclude=/etc/fstab --exclude=/etc/hostname --exclude=/etc/hosts $MASTER:$MASTERPATH/ $CLONE/
+
+echo "rsyncing home..."
+mount /dev/sda3 $CLONE/home
+rsync -a --exclude=telecaster/archives --exclude=telecaster/trash --exclude=telecaster/bin --exclude=telecaster/test $MASTER:$MASTERPATH/home/ $CLONE/home/
+umount $CLONE/home
+
+echo "rsyncing var..."
+rsync -a --delete $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 grub-install /dev/sda
+chroot $CLONE update-grub
+
+umount $CLONE/sys
+umount $CLONE/dev
+umount $CLONE/proc
+
+#umount $CLONE/var
+umount $CLONE
+
+echo "OK, I'm an updated TC (s10) clone!"
+
+
diff --git a/tc_mount_master.sh b/tc_mount_master.sh
new file mode 100755 (executable)
index 0000000..10385d7
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+CLONE=/mnt/custom
+
+mount /dev/sda1 $CLONE
+mount /dev/sda2 $CLONE/home
+mount /dev/sda5 $CLONE/var
+
+df
+
+echo "OK, I'm the Master of the TC clones!"
+
diff --git a/tc_umount_master.sh b/tc_umount_master.sh
new file mode 100755 (executable)
index 0000000..a102386
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+set -e
+
+CLONE=/mnt/custom
+
+umount $CLONE/var
+umount $CLONE/home
+umount $CLONE
+
+df
+
+