summaryrefslogtreecommitdiff
path: root/setup-disk.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-11-11 16:47:09 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2022-11-11 16:50:46 +0100
commitd91782eafb8122fbecd73e77ad945fa5930b7bd8 (patch)
treeeb1d8e50bb94762471a5745e448478db8d897258 /setup-disk.in
parentbc7aeab868bf4d94dde2ff5d6eb97daede5975b9 (diff)
downloadalpine-conf-d91782eafb8122fbecd73e77ad945fa5930b7bd8.zip
setup-disk: add -w option for writing selected diskmode
Use an option to setup-disk to write the selected diskmode instead of using an undocumented /tmp/alpine-install-diskmode.out Adjust setup-alpine to use this, and make sure that we write the diskmode when installing to a mounted root. fixes https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10444
Diffstat (limited to 'setup-disk.in')
-rw-r--r--setup-disk.in18
1 files changed, 13 insertions, 5 deletions
diff --git a/setup-disk.in b/setup-disk.in
index d2d4417..b9d725e 100644
--- a/setup-disk.in
+++ b/setup-disk.in
@@ -1422,7 +1422,7 @@ ask_disk() {
usage() {
cat <<-__EOF__
usage: setup-disk [-hLqrve] [-k kernelflavor] [-m MODE] [-o apkovl] [-s SWAPSIZE]
- [MOUNTPOINT | DISKDEV...]
+ [-w FILE] [MOUNTPOINT | DISKDEV...]
Install alpine on harddisk.
@@ -1444,6 +1444,7 @@ usage() {
-r Enable software raid1 with single disk
-s Use SWAPSIZE MB instead of autodetecting swap size (Use 0 to disable swap)
-v Be more verbose about what is happening
+ -w Write selected install mode to FILE
If BOOTLOADER is specified, the specified bootloader will be used.
If no bootloader is specified, the default bootloader is syslinux(extlinux)
@@ -1468,6 +1469,12 @@ usage() {
exit $1
}
+write_disk_mode() {
+ if [ -n "$WRITE_DISK_MODE_FILE" ]; then
+ echo "$DISK_MODE" > "$WRITE_DISK_MODE_FILE"
+ fi
+}
+
kver=$(uname -r)
case $kver in
*-rc[0-9]*) KERNEL_FLAVOR=lts;;
@@ -1485,7 +1492,7 @@ USE_CRYPT=
DISK_MODE=
USE_LVM=
# Parse args
-while getopts "hek:Lm:o:qrs:v" opt; do
+while getopts "hek:Lm:o:qrs:vw:" opt; do
case $opt in
e) USE_CRYPT="_crypt";;
h) usage 0;;
@@ -1497,6 +1504,7 @@ while getopts "hek:Lm:o:qrs:v" opt; do
r) USE_RAID=1;;
s) SWAP_SIZE="$OPTARG";;
v) VERBOSE=1;;
+ w) WRITE_DISK_MODE_FILE="$OPTARG";;
'?') usage "1" >&2;;
esac
done
@@ -1535,6 +1543,7 @@ if [ -d "$1" ]; then
if [ -z "$USE_EFI" ] && [ "$ARCH" = "x86_64" -o "$ARCH" = x86 ]; then
echo "You might need fix the MBR to be able to boot" >&2
fi
+ write_disk_mode
exit 0
fi
@@ -1652,6 +1661,8 @@ if [ -n "$USE_LVM" ] && ! grep -w -q device-mapper /proc/misc; then
modprobe dm-mod
fi
+write_disk_mode
+
# native disk install
case "$DISK_MODE" in
sys) native_disk_install$USE_LVM $diskdevs;;
@@ -1660,6 +1671,3 @@ none) exit 0;;
*) die "Not a valid install mode: $DISK_MODE" ;;
esac
-RC=$?
-echo "$DISK_MODE" > /tmp/alpine-install-diskmode.out
-exit $RC