local-server/install-on-metal.sh

38 lines
584 B
Bash
Raw Normal View History

2018-07-03 07:35:52 +00:00
#! /bin/sh
if [ $# -ne 2 ]; then
2018-11-13 03:44:15 +00:00
echo "USAGE: $0 <device> <base url>"
2018-07-03 07:35:52 +00:00
fi
dev=$1
2018-11-13 03:44:15 +00:00
base_url=$2
2018-07-03 07:35:52 +00:00
: ${MP:=/mnt}
set -ex
2018-11-13 03:44:15 +00:00
mkdir -p $MP
2018-07-03 07:35:52 +00:00
[[ $dev =~ nvme ]] &&
devp=${dev}p ||
devp=${dev}
2018-11-13 03:44:15 +00:00
if vgdisplay storage; then
# the system is already installed, just upgrade
mount -t vfat ${devp}1 $MP
curl ${base_url}/boot.tar |tar xv -C $MP
umount $MP
else
2018-07-03 07:35:52 +00:00
sgdisk --clear $dev
2018-11-13 03:44:15 +00:00
curl ${base_url}/boot.img.lz4 |lz4cat >$dev
sgdisk --move-second-header --new=3:0:0 $dev
2018-07-03 07:35:52 +00:00
pvcreate ${devp}3
vgcreate storage ${devp}3
2018-11-13 03:44:15 +00:00
fi
2018-07-03 07:35:52 +00:00
while umount $MP; do true; done