Commit 86aca48d authored by Natanael Copa's avatar Natanael Copa

setup-disk: add -m option for sepcifying install mode

So we dont need to ask.

Also fix help message.
parent bedcb7f5
......@@ -645,9 +645,25 @@ reset_var() {
umount /var && rm -rf /var && mv /.var /var && rm -rf /var/lost+found
}
# set up /var on given device
setup_var() {
local var_dev="$1"
local varfs=ext4
mkfs.$varfs -q $var_dev >/dev/null || return 1
sed -i -e '/[[:space:]]\/var[[:space:]]/d' /etc/fstab
echo -e "${var_dev}\t/var\t\t${varfs}\tdefaults 1 2" >> /etc/fstab
mv /var /.var
mkdir /var
mount /var
mv /.var/* /var/
rmdir /.var
/etc/init.d/syslog --quiet restart
}
data_only_disk_install() {
local diskdev=
local varfs=ext4
local vgname=vg0
local var_dev=/dev/$vgname/lv_var
local lvm_part_type="8e"
......@@ -668,41 +684,14 @@ data_only_disk_install() {
done
setup_lvm_volume_group $vgname $@ || return 1
setup_lvm_swap $vgname
lvcreate --quiet -n ${var_dev##*/} -l 100%FREE $vgname
mkfs.$varfs -q $var_dev >/dev/null || return 1
sed -i -e '/[[:space:]]\/var[[:space:]]/d' /etc/fstab
echo -e "${var_dev}\t/var\t\t${varfs}\tdefaults 1 2" >> /etc/fstab
mv /var /.var
mkdir /var
mount /var
mv /.var/* /var/
rmdir /.var
setup_var $var_dev
if [ -n "$USE_RAID" ]; then
mdadm --detail --scan > /etc/mdadm.conf
rc-update --quiet add mdadm-raid boot
fi
/etc/init.d/syslog --quiet restart
}
usage() {
cat <<__EOF__
usage: setup-disk [-hr] [-k kernelflavor] [-o apkovl] [MOUNTPOINT]
Install alpine on harddisk.
options:
-h Show this help
-o Restore system from given apkovl file
-k Use kernelflavor instead of $KERNEL_FLAVOR
-r Enable software raid1 with single disk
__EOF__
exit 1
}
diskselect_help() {
......@@ -745,16 +734,45 @@ ask_disk() {
done
}
usage() {
cat <<__EOF__
usage: setup-disk [-hqr] [-k kernelflavor] [-m MODE] [-o apkovl] [-s SWAPSIZE]
[MOUNTPOINT | DISKDEV...]
Install alpine on harddisk.
If MOUNTPOINT is specified, then do a traditional disk install with MOUNTPOINT
as root.
If DISKDEV is specified, then use the specified disk(s) without asking. If
multiple disks are specified then set them up in a RAID array. If there are
mode than 2 disks, then use raid level 5 instead of raid level 1.
options:
-h Show this help
-m Use disk for MODE without asking, where MODE is either 'data' or 'root'
-o Restore system from given apkovl file
-k Use kernelflavor instead of $KERNEL_FLAVOR
-q Exit quietly if no disks are found
-r Enable software raid1 with single disk
-s Use SWAPSIZE MB instead of $SWAP_SIZE MB for swap (Use 0 to disable swap)
-v Be more verbose about what is happening
__EOF__
exit 1
}
KERNEL_FLAVOR=grsec
case "$(uname -r)" in
*-vs[0-9]*) KERNEL_FLAVOR=vserver;;
*-pae) KERNEL_FLAVOR=pae;;
esac
DISK_MODE=
SWAP_SIZE=$(find_swap_size)
# Parse args
while getopts "hk:Lo:qrs:v" opt; do
while getopts "hk:Lm:o:qrs:v" opt; do
case $opt in
m) DISK_MODE="$OPTARG";;
k) KERNEL_FLAVOR="$OPTARG";;
L) USE_LVM=1;;
o) APKOVL="$OPTARG";;
......@@ -810,8 +828,7 @@ else
fi
fi
diskmode=
if [ -n "$diskdevs" ]; then
if [ -n "$diskdevs" ] && [ -z "$DISK_MODE" ]; then
answer=
while true; do
echo "The following disks are selected:"
......@@ -823,7 +840,7 @@ if [ -n "$diskdevs" ]; then
root|data) break;;
esac
done
diskmode="$answer"
DISK_MODE="$answer"
fi
set -- $diskdevs
......@@ -834,8 +851,9 @@ fi
dmesg -n1
# native disk install
case "$diskmode" in
case "$DISK_MODE" in
root) native_disk_install $diskdevs;;
data) data_only_disk_install $diskdevs;;
*) echo "Not a valid install mode: $DISK_MODE" >&2; exit 1;;
esac
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