From: Harvie Date: Sun, 17 Oct 2010 21:24:35 +0000 (+0200) Subject: Added script to create archlinux vserver/chroot environment X-Git-Url: http://git.harvie.cz/?a=commitdiff_plain;h=e2c9be169929c1c17de4a5ced61526a3578568a5;p=mirrors%2FPrograms.git Added script to create archlinux vserver/chroot environment --- diff --git a/bash/pacman-doctor/archstrap.sh b/bash/pacman-doctor/archstrap.sh new file mode 100755 index 0000000..047637a --- /dev/null +++ b/bash/pacman-doctor/archstrap.sh @@ -0,0 +1,37 @@ +#!/bin/bash +#Simple script to create ArchLinux system suitable for chroot or virtualserver. +#It will take ~400-500MB but you will probably want to uninstall some pkgs. +#You will be automaticaly chrooted into new system once installation is done... + +pacman='/usr/bin/pacman' +ROOT="$1" +pacman="$pacman --noconfirm --ignore kernel26 --root $ROOT" + +[ -z "$1" ] && echo "Usage: root@localhost# $0 /path/to/empty/installation/directory/" && exit 1 +[ "$UID" != 0 ] && echo "You have to be root!" && exit 7 +[ ! -d "$ROOT" ] && echo "Error: $ROOT is not a directory!" && exit 2 +[ -n "$(ls -A "$ROOT")" ] && echo "Error: $ROOT is not empty!" && exit 3 + +echo -e "Hello. I will install ArchLinux to $ROOT directory.\n" +echo '==> Creating pacman DB...' + mkdir -p "$ROOT/var/lib/pacman/" || exit 4 +echo '==> Synchronizing pacman DB...' + $pacman -Sy || exit 5 +echo '==> Installing packages from base group...' + $pacman -S base || exit 6 +echo '==> Minimal configuration - copying from parent...' + no_blanks() { grep -Ev '^(#|$)'; } + for i in /etc/resolv.conf /etc/pacman.d/mirrorlist; do + echo " -> $i"; + cat "$i" | no_blanks >> "$ROOT$i"; + done; + #Hack for special configurations: + echo " -> /etc/pacman.d/mirrorlist*"; + cat /etc/pacman.d/mirrorlist* | no_blanks >> "$ROOT/etc/pacman.d/mirrorlist"; + +echo '==> Entering chroot...' + chroot $ROOT +echo -e "\nBye bye. You can enter your system again by executing following command as root +chroot '$ROOT'" + +exit 0