aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-04-23 09:16:41 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2014-04-23 11:34:25 +0200
commit81ae21f658b6ddb4b34e03f44b20a196d8eb18cf (patch)
tree269836717cd3af6f271280f32d74ced3bc40b509
parentab92d94caee54149e2594b732d93960e894dfdaf (diff)
downloadalpine-conf-81ae21f658b6ddb4b34e03f44b20a196d8eb18cf.tar.bz2
alpine-conf-81ae21f658b6ddb4b34e03f44b20a196d8eb18cf.tar.xz
setup-disk: add magic environemnt var ERASE_DISKS as confirmation
Add a magic environment variable ERASE_DISKS as confirmation for erasing disks. This is useful for scripted installs. fixes #2863
-rw-r--r--setup-disk.in28
1 files changed, 16 insertions, 12 deletions
diff --git a/setup-disk.in b/setup-disk.in
index 9e222fb..e06bdea 100644
--- a/setup-disk.in
+++ b/setup-disk.in
@@ -107,7 +107,7 @@ unpack_apkovl() {
n*|N*) return 1;;
esac
fi
- return 0
+ return 0
fi
apk add --quiet openssl
@@ -315,7 +315,7 @@ EOF
for i in $repos; do
repoflags="$repoflags --repository $i"
done
-
+
chroot_caps=$(set_grsec chroot_caps 0)
init_chroot_mounts "$mnt"
apk add --root "$mnt" $apkflags --overlay-from-stdin \
@@ -386,7 +386,7 @@ is_available_disk() {
# check if its a "root" block device and not a partition
[ -e /sys/block/$b ] || return 1
-
+
# check so it does not have mounted partitions
has_mounted_part $dev && return 1
@@ -437,10 +437,14 @@ show_disk_info() {
confirm_erase() {
local answer=
+ local erasedisks="$@"
+ if [ "$ERASE_DISKS" = "$erasedisks" ]; then
+ reeturn 0
+ fi
echo "WARNING: The following disk(s) will be erased:"
show_disk_info $@
echo -n "WARNING: Erase the above disk(s) and continue? [y/N]: "
-
+
read answer
case "$answer" in
y*|Y*) return 0;;
@@ -449,7 +453,7 @@ confirm_erase() {
}
# setup partitions on given disk dev in $1.
-# usage: setup_partitions <diskdev> size1,type1 [size2,type2 ...]
+# usage: setup_partitions <diskdev> size1,type1 [size2,type2 ...]
setup_partitions() {
local diskdev="$1"
shift
@@ -558,7 +562,7 @@ setup_lvm_volume_group() {
if [ -n "$USE_RAID" ]; then
setup_non_boot_raid_dev /dev/md1 $@ || return 1
lvmdev=/dev/md1
- else
+ else
lvmdev=$(find_lvm_partition $1)
fi
@@ -654,7 +658,7 @@ data_only_disk_install_lvm() {
for diskdev in "$@"; do
setup_partitions $diskdev "$size,$part_type" || return 1
done
-
+
setup_lvm_volume_group $vgname $@ || return 1
setup_lvm_swap $vgname
lvcreate --quiet -n ${var_dev##*/} -l 100%FREE $vgname
@@ -699,7 +703,7 @@ data_only_disk_install() {
setup_var $var_dev
}
-# setup
+# setup
setup_root() {
local root_dev="$1" boot_dev="$2"
mkfs.$ROOTFS -q "$root_dev"
@@ -777,7 +781,7 @@ native_disk_install() {
# will find BOOT_DEV for us
setup_boot_dev $@
-
+
if [ "$USE_RAID" ]; then
[ $SWAP_SIZE -gt 0 ] && setup_non_boot_raid_dev /dev/md1 $@
setup_non_boot_raid_dev /dev/md2 $@ || return 1
@@ -812,7 +816,7 @@ You can select between 'sys' or 'data'.
sys:
This mode is a traditional disk install. The following partitions will be
created on the disk: /boot, / (filesystem root) and swap.
-
+
This mode may be used for development boxes, desktops, virtual servers, etc.
data:
@@ -935,7 +939,7 @@ if [ -z "$disks" ]; then
fi
if [ $# -gt 0 ]; then
- # check that they are
+ # check that they are
for i in "$@"; do
j=$(readlink -f "$i" | sed 's:^/dev/::; s:/:!:g')
if ! [ -e "/sys/block/$j/device" ]; then
@@ -965,7 +969,7 @@ if [ -n "$diskdevs" ] && [ -z "$DISK_MODE" ]; then
disk_is_or_disks_are="disks are"
it_them="them"
fi
-
+
while true; do
echo "The following $disk_is_or_disks_are selected:"
show_disk_info $diskdevs