Added script to create archlinux vserver/chroot environment
[mirrors/Programs.git] / bash / pacman-doctor / archstrap.sh
1 #!/bin/bash
2 #Simple script to create ArchLinux system suitable for chroot or virtualserver.
3 #It will take ~400-500MB but you will probably want to uninstall some pkgs.
4 #You will be automaticaly chrooted into new system once installation is done...
5
6 pacman='/usr/bin/pacman'
7 ROOT="$1"
8 pacman="$pacman --noconfirm --ignore kernel26 --root $ROOT"
9
10 [ -z "$1" ] && echo "Usage: root@localhost# $0 /path/to/empty/installation/directory/" && exit 1
11 [ "$UID" != 0 ] && echo "You have to be root!" && exit 7
12 [ ! -d "$ROOT" ] && echo "Error: $ROOT is not a directory!" && exit 2
13 [ -n "$(ls -A "$ROOT")" ] && echo "Error: $ROOT is not empty!" && exit 3
14
15 echo -e "Hello. I will install ArchLinux to $ROOT directory.\n"
16 echo '==> Creating pacman DB...'
17 mkdir -p "$ROOT/var/lib/pacman/" || exit 4
18 echo '==> Synchronizing pacman DB...'
19 $pacman -Sy || exit 5
20 echo '==> Installing packages from base group...'
21 $pacman -S base || exit 6
22 echo '==> Minimal configuration - copying from parent...'
23 no_blanks() { grep -Ev '^(#|$)'; }
24 for i in /etc/resolv.conf /etc/pacman.d/mirrorlist; do
25 echo " -> $i";
26 cat "$i" | no_blanks >> "$ROOT$i";
27 done;
28 #Hack for special configurations:
29 echo " -> /etc/pacman.d/mirrorlist*";
30 cat /etc/pacman.d/mirrorlist* | no_blanks >> "$ROOT/etc/pacman.d/mirrorlist";
31
32 echo '==> Entering chroot...'
33 chroot $ROOT
34 echo -e "\nBye bye. You can enter your system again by executing following command as root
35 chroot '$ROOT'"
36
37 exit 0
This page took 0.267645 seconds and 4 git commands to generate.