ungleich-tools/install-any-linux.sh

57 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/sh
# 2021-07-09
# Objective: install any Linux automatically to a disk
# Made by ungleich
# Made for bare metal
# Requirements:
# The OS image needs to be in tar format and needs to contain grub
2021-07-09 17:42:57 +00:00
set -e
2021-07-09 17:42:57 +00:00
if [ $# -lt 2 ]; then
echo "$0 os-image.tar [usb|disk] [target-usb-disk]"
echo "os-image.tar contains the OS"
echo "usb mode: create a bootable usb stick including this script to auto install to disk"
echo "disk mode: actually install os-image.tar to the first disk"
2021-07-09 17:42:57 +00:00
echo ""
echo "In usb mode, specify the usb disk to install to"
exit 1
fi
2021-07-09 17:42:57 +00:00
IMAGE=$1; shift
mode=$1; shift
# isohybrid
2021-07-09 17:42:57 +00:00
setup_usb() {
rootfs_tmpdir=$(mktemp -d)
sudo sfdisk "$DISK" <<EOF
label: dos
,,L
EOF
sudo mkfs.ext4 -F ${DISK}1
sudo mount ${DISK}1 $rootfs_tmpdir
sudo tar xf $IMAGE -C $rootfs_tmpdir
for dir in dev proc sys; do
sudo mount --bind /${dir} ${rootfs_tmpdir}/${dir}
done
...
}
setup_disk()
{
}
case "$mode" in
usb)
if [ $# -ne 1 ]; then echo "Specify usb disk to install to"; exit 1; fi
DISK=$1; shift