2024-04-09 12:28:04 +03:00
|
|
|
#!/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'
|
2024-04-09 12:44:57 +03:00
|
|
|
tar xzf ./rootfs.tar.gz -C "$2/" || exit 3
|
|
|
|
mv "$2/root.$1"/* "$2" || exit 4
|
|
|
|
rmdir "$2/root.$1"
|
2024-04-09 12:28:04 +03:00
|
|
|
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"
|
|
|
|
|
2024-04-09 12:44:57 +03:00
|
|
|
echo -e '-- \e[1;32mOK\e[0m -- archlinux bootstrapped'
|
2024-04-09 12:28:04 +03:00
|
|
|
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'
|
|
|
|
}
|
2024-04-09 12:44:57 +03:00
|
|
|
|
|
|
|
[[ "$1" != "archlinux" || "$1" == "--help" || "$1" == "" || "$2" == "" || "$3" == "" ]] && help && exit 0
|
|
|
|
|
|
|
|
bs_archlinux "$2" $(readlink -f "$3")
|