dchr/bootstrap.sh

45 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# will be rewritten some day
help () {
echo "dchr-bs <distro> <arch> <chroot-dir>"
echo "-- supported distros:"
echo " archlinux"
#echo " voidlinux"
echo "https://dchr.dc09.ru"
}
bs_archlinux () {
url="https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-$1.tar.gz"
echo '-- Downloading'
if which wget 2>/dev/null
then
wget -O ./rootfs.tar.gz "$url" || exit 2
elif which curl 2>/dev/null
then
curl -o ./rootfs.tar.gz "$url" || exit 2
else
echo -e "-- \e[1;31mError\e[0m -- install either curl or wget"
exit 1
fi
echo '-- Extracting'
tar xzf ./rootfs.tar.gz "root.x86_64/*" -C "$2" || exit 3
echo '-- Removing rootfs archive'
rm ./rootfs.tar.gz
echo '-- Setting up'
sed -i '/evowise/s/^#//' "$2/etc/pacman.d/mirrorlist"
sed -i '/CheckSpace/s/^/#/' "$2/etc/pacman.conf"
cp /etc/hosts "$2/etc/hosts"
cp /etc/resolv.conf "$2/etc/resolv.conf"
echo '-- \e[1;32mOK\e[0m -- archlinux bootstrapped'
echo '-- Use dchr-run to enter the chroot and execute the following commands:'
# some day i will rewrite this script and it will do it automatically
echo '# pacman-key --init'
echo '# pacman-key --populate archlinux'
echo '# pacman -Syu'
}