#!/usr/bin/env bash # will be rewritten some day help () { echo "dchr-bs " 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 -C "$2/" || exit 3 mv "$2/root.$1"/* "$2" || exit 4 rmdir "$2/root.$1" 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 '-- \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' } [[ "$1" != "archlinux" || "$1" == "--help" || "$1" == "" || "$2" == "" || "$3" == "" ]] && help && exit 0 bs_archlinux "$2" $(readlink -f "$3")