Added script to create archlinux vserver/chroot environment
authorHarvie <tomas@mudrunka.cz>
Sun, 17 Oct 2010 21:24:35 +0000 (23:24 +0200)
committerHarvie <tomas@mudrunka.cz>
Sun, 17 Oct 2010 21:24:35 +0000 (23:24 +0200)
bash/pacman-doctor/archstrap.sh [new file with mode: 0755]

diff --git a/bash/pacman-doctor/archstrap.sh b/bash/pacman-doctor/archstrap.sh
new file mode 100755 (executable)
index 0000000..047637a
--- /dev/null
@@ -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
This page took 0.13529 seconds and 4 git commands to generate.