1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
From 81ae21f658b6ddb4b34e03f44b20a196d8eb18cf Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 23 Apr 2014 09:16:41 +0200
Subject: 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
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
--
cgit v0.10.1
|