Skip to content

Commit f431909

Browse files
Do not hardcode /mnt/clone in rpi-clone-setup
Instead, pass the mount location through an environment variable.
1 parent 07f536e commit f431909

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

rpi-clone

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ then
8585
apt-get install -y --no-install-recommends $need_packages
8686
fi
8787

88-
clone=/mnt/clone
89-
clone_src=/mnt/clone-src
90-
clone_log=/var/log/$PGM.log
88+
export clone=/mnt/clone
89+
export clone_src=/mnt/clone-src
90+
export clone_log=/var/log/$PGM.log
9191

9292
HOSTNAME=`hostname`
9393

rpi-clone-setup

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
# eg: sudo rpi-clone-setup bozo
55
#
66
# This script is automatically run by rpi-clone (when it is given -s options)
7-
# to setup an alternate hostname. A cloned file system mounted on /mnt/clone
8-
# is expected unless testing with the -t option.
7+
# to setup an alternate hostname. It expects $clone to be set in the
8+
# environment containing the path to a mounted cloned file system unless
9+
# testing with the -t option.
910
#
1011
# Or, this script can be run by hand at the end of a clone when rpi-clone
11-
# pauses with the cloned file systems still mounted on /mnt/clone.
12+
# pauses with the cloned file systems still mounted (make sure to set
13+
# the $clone env variable properly, then).
1214
#
1315
# Or, run this script by hand with -t to process files in test directories
1416
# under /tmp/clone-test. Run -t and look at the files to see if the files
@@ -27,7 +29,7 @@
2729

2830
file_list="etc/hostname etc/hosts"
2931

30-
clone=/mnt/clone
32+
# $clone is set by caller
3133
clone_test=/tmp/clone-test
3234

3335
PGM=`basename $0`
@@ -81,9 +83,15 @@ fi
8183

8284
echo -e "\t$newhost\t- target hostname"
8385

84-
if ((!testing)) && [ ! -d /mnt/clone/etc ]
86+
if ((!testing)) && [ -z "$clone" ]
8587
then
86-
echo "A destination clone file system is not mounted on /mnt/clone"
88+
echo "No clone mountpoint was passed in the \$clone variable"
89+
echo "Aborting!"
90+
exit 0
91+
fi
92+
if ((!testing)) && [ ! -d "$clone/etc" ]
93+
then
94+
echo "A destination clone file system is not mounted on $clone"
8795
echo "Aborting!"
8896
exit 0
8997
fi

0 commit comments

Comments
 (0)