experimental-vms/mumble-vm-install.sh

222 lines
11 KiB
Bash
Raw Normal View History

#!/bin/sh
# Copyright (C) 2023 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# You should have received a copy of the GNU General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
report()
{
ret=$?
message="$@"
if [ ${ret} -eq 0 ] ; then
echo "[ OK ] ${message}"
else
echo "[ !! ] ${message}"
exit ${ret}
fi
}
environment_checks()
{
[ "$(id -u)" = "0" ] ; report "Running as root"
# Try to detect the installer
_mount="none / overlay"
_mount="${_mount} rw,relatime"
_mount="${_mount},lowerdir=/real-root"
_mount="${_mount},upperdir=/rw-root/upper"
_mount="${_mount},workdir=/rw-root/work"
_mount="${_mount} 0 0"
grep "${_mount}" "/proc/mounts" 2>&1 > /dev/null ; report "Mount check"
[ "${HOSTNAME}" = "gnu" ] ; report "Hostname check"
}
# FB31DBA3AB8DB76A4157329F7651568F80374459:
# uid [ultimate] Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
# uid [ultimate] Denis 'GNUtoo' Carikli <GNUtoo@riseup.net>
# uid [ultimate] Denis 'GNUtoo' Carikli <GNUtoo@makefreedom.org>
# uid [ultimate] Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
import_gpg_key()
{
cat <<EOF > FB31DBA3AB8DB76A4157329F7651568F80374459.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFksJcEBEADYjwYOrJmv5TX7NPItWRT7W+XNMe53NXoSZa9bEiHnTv8PoQaw
ldPpHn3TTtN1Iq4QgvNVzr0uoxPAdxFUkcvF3bFH7u/aQoXoBXxl/HH3DAoR+HIa
0XE1vPGEzUTybR2CmH3vMkfWsErEJuPxRPSTV0qouRGUU21FTuBy8x/HLyoO9L2M
YZX98Y3hWHP4V6P/tSsGaNg73l4oIbVv1SLJdASP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yoMLcnvdcoKUa+/ikC6CkyZGxwAH1JGcEVjzD+
4xG8l8/ubA3DSguKNpI1dGzVxpWgJnJzMCXBcwxp5c+kKH94QbKAUVt+16dUaY9k
0hhucHQnbTHS3w9jY7rZ6sAZHufb9LQMMWunerecL6WvAR+XUydMd1rJS93j4y1W
fNHj/507Jk+Ogk89eojQYjZNHCF+Zhyk6IRyI84=
=4ncY
-----END PGP PUBLIC KEY BLOCK-----
EOF
guix shell gnupg -- \
gpg --import FB31DBA3AB8DB76A4157329F7651568F80374459.asc && \
rm -f FB31DBA3AB8DB76A4157329F7651568F80374459.asc
}
environment_checks
tmpdir="$(mktemp -d)"
cd "${tmpdir}"
guix pull ; report "Guix pull"
hash guix ; report "hash guix"
import_gpg_key ; report "Import GPG key"
guix shell -C --network git nss-certs -- \
git clone https://git.a-lec.org/GNUtoo/guix-mumble-vm.git -b guix-installer ; \
report "Cloning machine configuration git"
cd "guix-mumble-vm" ; report "cd guix-mumble-vm"
guix shell git gnupg -- \
git verify-commit HEAD ; report "check git signature"
guix shell -C --nesting autoconf automake bash coreutils grep sed -- \
./autogen.sh ; report "./autogen.sh"
guix shell -C --nesting bash coreutils gawk grep sed -- \
./configure ; report "./configure"
# TODO: use guix init or temporary storage instead to reduce the
# memory consumption. Right now we tested this script with 16GiB of
# RAM which is probably too big for many potential users. Requiring
# 4GiB would be more reasonable.
guix shell -C --nesting automake coreutils gawk grep make sed -- \
make ; report "make"
guix shell -C ddrescue -- ddrescue mumble-vm.img /dev/vda && sync ; \
report "ddrescue mumble-vm.img /dev/vda"
printf "Installation done: %s\n" \
"you can remove the install media and reboot to the new VM"