Commit 81ae21f6 authored by Natanael Copa's avatar Natanael Copa

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
parent ab92d94c
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment