From c4421199faa1b50450b6f0de80a25dece1397cc4 Mon Sep 17 00:00:00 2001 From: Adam Engebretson Date: Tue, 29 Aug 2017 16:32:10 -0500 Subject: [PATCH 1/4] Adding -H|--set-hostname flag --- rpi-clone | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rpi-clone b/rpi-clone index 6d99aa2..96fcb71 100755 --- a/rpi-clone +++ b/rpi-clone @@ -1,6 +1,8 @@ #!/bin/bash -VERSION=1.7.1 +VERSION=1.7.2 +# Version 1.7.2 2017/08/29 +# * Adding option to set hostname on clone # Version 1.7.1 2017/08/19 # * Bugfix: did not set SRC_ROOT when using -s option # Version 1.7 2017/08/19 @@ -81,13 +83,14 @@ fi usage() { echo "" - echo "usage: $PGM sdN {-v|--verbose} {-f|--force-initialize} {-s|--src-disk sdS} {-c|--cross-filesystems} {-x}" + echo "usage: $PGM sdN {-v|--verbose} {-f|--force-initialize} {-s|--src-disk sdS} {-c|--cross-filesystems} {-H|--set-hostname hostname} {-x}" echo " -v - list all files as they are copied." echo " -f - force initialize the destination partitions" echo " -s sdS - specify sdS is the booted source disk to clone from." echo " Use this if the boot source auto detect from /etc/mtab fails." echo " Use with caution, be sure sdS is really the booted disk." echo " -c - cross filesystem boundaries (include mounted drives)" + echo " -H - set hostname of cloned pi echo " -x - use set -x for very verbose bash shell script debugging" echo "" echo " Example: $PGM sda" @@ -160,6 +163,11 @@ do SRC_ROOT=${SRC_DISK}2 fi ;; + -H|--set-hostname) + shift + NEW_HOSTNAME=$1 + SET_HOSTNAME=on + ;; -x) set -x ;; @@ -548,6 +556,11 @@ echo "$DATE $HOSTNAME $PGM : clone to $DST_DISK ($DST_ROOT_VOL_NAME)" \ >> $CLONE_LOG echo "$DATE $HOSTNAME $PGM : clone to $DST_DISK ($DST_ROOT_VOL_NAME)" \ >> $CLONE/$CLONE_LOG + +if [ "$SET_HOSTNAME" = "on" ] +then + echo $NEW_HOSTNAME > $CLONE/etc/hostname +fi STOP_TIME=`date '+%H:%M:%S'` -- 2.39.5 From 83f2196478364e579661ec07677b7364a768ec74 Mon Sep 17 00:00:00 2001 From: Adam Engebretson Date: Tue, 29 Aug 2017 16:32:42 -0500 Subject: [PATCH 2/4] Fix echo typo --- rpi-clone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpi-clone b/rpi-clone index 96fcb71..9c776e7 100755 --- a/rpi-clone +++ b/rpi-clone @@ -90,7 +90,7 @@ usage() echo " Use this if the boot source auto detect from /etc/mtab fails." echo " Use with caution, be sure sdS is really the booted disk." echo " -c - cross filesystem boundaries (include mounted drives)" - echo " -H - set hostname of cloned pi + echo " -H - set hostname of cloned pi" echo " -x - use set -x for very verbose bash shell script debugging" echo "" echo " Example: $PGM sda" -- 2.39.5 From cff7ce606e82fe630f8445abd024181e62f07829 Mon Sep 17 00:00:00 2001 From: Adam Engebretson Date: Mon, 4 Sep 2017 11:35:35 -0500 Subject: [PATCH 3/4] Updating /etc/hosts as well --- rpi-clone | 1 + 1 file changed, 1 insertion(+) diff --git a/rpi-clone b/rpi-clone index 9c776e7..3fd6465 100755 --- a/rpi-clone +++ b/rpi-clone @@ -560,6 +560,7 @@ echo "$DATE $HOSTNAME $PGM : clone to $DST_DISK ($DST_ROOT_VOL_NAME)" \ if [ "$SET_HOSTNAME" = "on" ] then echo $NEW_HOSTNAME > $CLONE/etc/hostname + sed -i "s/$HOSTNAME/$NEW_HOSTNAME/" $CLONE/etc/hostname fi -- 2.39.5 From a1d34dbdb83660ed1e64e556fd2b0f53ee0c5911 Mon Sep 17 00:00:00 2001 From: Adam Engebretson Date: Mon, 4 Sep 2017 11:36:01 -0500 Subject: [PATCH 4/4] Derpin --- rpi-clone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpi-clone b/rpi-clone index 3fd6465..71a140d 100755 --- a/rpi-clone +++ b/rpi-clone @@ -560,7 +560,7 @@ echo "$DATE $HOSTNAME $PGM : clone to $DST_DISK ($DST_ROOT_VOL_NAME)" \ if [ "$SET_HOSTNAME" = "on" ] then echo $NEW_HOSTNAME > $CLONE/etc/hostname - sed -i "s/$HOSTNAME/$NEW_HOSTNAME/" $CLONE/etc/hostname + sed -i "s/$HOSTNAME/$NEW_HOSTNAME/" $CLONE/etc/hosts fi -- 2.39.5