rootfsinstall.sh: added or updated the following options:
-s: assume partitions are already done and proceed from scripts (for development) -g [size] : grow system partition to fit storage size (to be used with -I) -p [user:]password : set given password for specified user (if none, set for root user)
This commit is contained in:
parent
2722423acb
commit
086d58b0f2
@ -25,7 +25,7 @@ function usage() {
|
||||
echo " Use @ROOT@ as reference to rootfs path and @BOOT@ as reference to bootfs path"
|
||||
echo "-c command : command to run through chroot in rootfs (may be specified multiple times)"
|
||||
echo "-fs fstype : filesystem type for system partition (default: ext4)"
|
||||
echo "-g : grow system partition to fit storage size (to be used with -I)"
|
||||
echo "-g [size] : grow system partition to fit storage size (to be used with -I)"
|
||||
echo "-h hostname : set given hostname"
|
||||
echo "-k kernel : extract and use specified kernel file from ROOTFS/boot/ for boot"
|
||||
echo "-k2 kernel : extract and use specified second kernel file from ROOTFS/boot/ for boot"
|
||||
@ -33,8 +33,9 @@ function usage() {
|
||||
echo "-I : treat input as an image file"
|
||||
echo "-l : force local installation only; don't perform installation from network"
|
||||
echo "-L : rootfs volume label (default: 'openmamba')"
|
||||
echo "-p password : set given password for root user"
|
||||
echo "-p [user:]password : set given password for specified user (if none, set for root user)"
|
||||
echo "-r mode : set given default video mode where applicable (e.g. -r 1920x1080-32@60)"
|
||||
echo "-s : assume partitions are already done and proceed from scripts (for development)"
|
||||
echo "-y : assume yes to all questions (script mode)"
|
||||
echo
|
||||
echo "Example 1: $0 /dev/sdb /tmp/openmamba-rootfs-light.arm.tar.xz"
|
||||
@ -101,7 +102,14 @@ while [ "$1" ]; do
|
||||
USEKERNEL2=$2
|
||||
shift
|
||||
;;
|
||||
-g) GROWIMAGE=1 ;;
|
||||
-g) GROWIMAGE=1
|
||||
if [ "${2:0:1}" != "-" ]; then
|
||||
GROWIMAGESIZE=$2
|
||||
shift;
|
||||
else
|
||||
GROWIMAGESIZE=100%
|
||||
fi
|
||||
;;
|
||||
-h) [ "$2" ] || {
|
||||
echo "Error: -h option requires a hostname as argument; aborting."
|
||||
exit 1
|
||||
@ -126,10 +134,14 @@ while [ "$1" ]; do
|
||||
shift
|
||||
;;
|
||||
-p) [ "$2" ] || {
|
||||
echo "Error: -p option requires a password as argument; aborting."
|
||||
echo "Error: -p option requires a root password or 'user:password' as argument; aborting."
|
||||
exit 1
|
||||
}
|
||||
ROOTPASSWORD=$2
|
||||
if [ "${2/:*}" != "${2}" ]; then
|
||||
SETUSERPASSWORD="$2"
|
||||
else
|
||||
SETUSERPASSWORD="root:$2"
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
-r) [ "$2" ] || {
|
||||
@ -139,6 +151,8 @@ while [ "$1" ]; do
|
||||
VIDEOMODE=$2
|
||||
shift
|
||||
;;
|
||||
-s) FROMSCRIPTS=1
|
||||
;;
|
||||
-*) echo "Error: invalid option $1; aborting."
|
||||
exit 1
|
||||
;;
|
||||
@ -248,7 +262,7 @@ echo
|
||||
[ "$ans" = "y" -o "$ans" = "Y" ] || exit 0
|
||||
}
|
||||
|
||||
if [ ! "$IMAGEMODE" ]; then
|
||||
if [ ! "$IMAGEMODE" -a ! "$FROMSCRIPTS" ]; then
|
||||
sudo parted -s ${DRIVE} mktable msdos
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "ERROR: parted exited with error $? while creating partition table on ${DRIVE}; aborting."
|
||||
@ -302,7 +316,7 @@ if [ ! "$IMAGEMODE" ]; then
|
||||
exit 1
|
||||
}
|
||||
|
||||
else
|
||||
elif [ ! "$FROMSCRIPTS" ]; then
|
||||
# Image mode
|
||||
if [ "${ROOTFSARCHIVE: -4}" == ".zip" ]; then
|
||||
7z e -so ${ROOTFSARCHIVE} | dd of=${DRIVE} bs=4M conv=fsync status=progress
|
||||
@ -311,14 +325,17 @@ else
|
||||
else
|
||||
dd if=${ROOTFSARCHIVE} of=${DRIVE} bs=4M conv=fsync status=progress
|
||||
fi
|
||||
if [ "${GROWIMAGE}" ]; then
|
||||
# Grow system partition to 100%
|
||||
SAVE_BOOT_PARTUUID=`blkid -s PARTUUID -o value ${PARTITION1}`
|
||||
SAVE_ROOT_PARTUUID=`blkid -s PARTUUID -o value ${PARTITION2}`
|
||||
parted ${DRIVE} resizepart 2 100%
|
||||
e2fsck -f ${PARTITION2}
|
||||
resize2fs ${PARTITION2}
|
||||
fi
|
||||
fi
|
||||
|
||||
sync
|
||||
|
||||
if [ "${GROWIMAGE}" ]; then
|
||||
# Grow system partition to 100%
|
||||
SAVE_BOOT_PARTUUID=`blkid -s PARTUUID -o value ${PARTITION1}`
|
||||
SAVE_ROOT_PARTUUID=`blkid -s PARTUUID -o value ${PARTITION2}`
|
||||
parted ${DRIVE} resizepart 2 ${GROWIMAGESIZE}
|
||||
e2fsck -f ${PARTITION2}
|
||||
resize2fs ${PARTITION2}
|
||||
fi
|
||||
|
||||
[ "$BOOTFSTYPE" ] && BOOTMP=`mktemp -d -t rootfsinstall.XXXXXXXX`
|
||||
@ -386,16 +403,27 @@ for f in qemu-${TARGET_ARCH}.static qemu-${TARGET_ARCH}-static; do
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$ROOTPASSWORD" ]; then
|
||||
echo "$ROOTPASSWORD" | chroot $ROOTMP passwd root --stdin || {
|
||||
echo "ERROR: unable to set password for root; aborting."
|
||||
if [ "${SAVE_ROOT_PARTUUID}" -a "${GROWIMAGE}" ]; then
|
||||
# Update PARTUUID after growing root filesystem (Raspbian)
|
||||
NEW_BOOT_PARTUUID=`blkid -s PARTUUID -o value ${PARTITION1}`
|
||||
NEW_ROOT_PARTUUID=`blkid -s PARTUUID -o value ${PARTITION2}`
|
||||
sed -i "s|PARTUUID=${SAVE_ROOT_PARTUUID}|PARTUUID=${NEW_ROOT_PARTUUID}|" ${ROOTMP}/etc/fstab
|
||||
sed -i "s|PARTUUID=${SAVE_BOOT_PARTUUID}|PARTUUID=${NEW_BOOT_PARTUUID}|" ${ROOTMP}/etc/fstab
|
||||
if [ "$TARGETDEVICE" = "rpi" ]; then
|
||||
sed -i "s|PARTUUID=${SAVE_ROOT_PARTUUID}|PARTUUID=${NEW_ROOT_PARTUUID}|" ${BOOTMP}/cmdline.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$SETUSERPASSWORD" ]; then
|
||||
echo "$SETUSERPASSWORD" | chroot $ROOTMP chpasswd || {
|
||||
echo "ERROR: unable to set user password; aborting."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
if [ "$SETHOSTNAME" ]; then
|
||||
echo "$SETHOSTNAME" > $ROOTMP/etc/hostname
|
||||
sed -i "s|HOSTNAME=.*|HOSTNAME=$SETHOSTNAME|" $ROOTMP/etc/sysconfig/network
|
||||
[ -e $ROOTMP/etc/sysconfig/network ] && sed -i "s|HOSTNAME=.*|HOSTNAME=$SETHOSTNAME|" $ROOTMP/etc/sysconfig/network
|
||||
sed -i "s|\(127\.0\.0\.1\W*\)\(.*\)|\1 $SETHOSTNAME.localdomain $SETHOSTNAME localhost.localdomain localhost|" $ROOTMP/etc/hosts
|
||||
fi
|
||||
|
||||
@ -617,16 +645,6 @@ for c in `seq 1 ${#CHROOTCOMMANDS[*]}`; do
|
||||
}
|
||||
done
|
||||
|
||||
if [ "${IMAGEMODE}" -a "${SAVE_ROOT_PARTUUID}" -a "${GROWIMAGE}" ]; then
|
||||
# Update PARTUUID after growing root filesystem (Raspbian)
|
||||
NEW_BOOT_PARTUUID=`blkid -s PARTUUID -o value ${PARTITION1}`
|
||||
NEW_ROOT_PARTUUID=`blkid -s PARTUUID -o value ${PARTITION2}`
|
||||
sed -i "s|PARTUUID=${SAVE_ROOT_PARTUUID}|PARTUUID=${NEW_ROOT_PARTUUID}|" ${ROOTMP}/etc/fstab
|
||||
sed -i "s|PARTUUID=${SAVE_BOOT_PARTUUID}|PARTUUID=${NEW_BOOT_PARTUUID}|" ${ROOTMP}/etc/fstab
|
||||
if [ "$TARGETDEVICE" = "rpi" ]; then
|
||||
sed -i "s|PARTUUID=${SAVE_ROOT_PARTUUID}|PARTUUID=${NEW_ROOT_PARTUUID}|" ${BOOTMP}/cmdline.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
# Kill any daemon process run in chroot
|
||||
FOUND=0
|
||||
|
Loading…
Reference in New Issue
Block a user