mirror of https://github.com/Chizi123/Arch-autobuild-repo.git

Joel Grunbaum
2023-06-17 afd818e12b072908f9a922dea241678a4da9a188
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
 
#Where to download the image from
BOOTSTRAP_SOURCE=mirror.rackspace.com/archlinux/iso/latest/
BOOTSTRAP_FILE=archlinux-bootstrap-*-x86_64.tar.gz
#Directory for the chroot, default is the same folder as this script
CHDIR=$(dirname "$(realpath $0)")/chroot
#Your username, this is for the chroot user. Needs to be a user on your system
#Need to change the username in all the other files
USER=joel
#Locale for chroot as it appears in /etc/locale.gen. This needs to be the same as the host system's locale
LOCALE=en_US.UTF-8 UTF-8
#Git details
GIT_USER=Chizi123
GIT_EMAIL=joelgrun@gmail.com
 
#Download bootstrap image
cd /tmp
echo wget -r --no-parent -A \'$BOOTSTRAP_FILE\' http://$BOOTSTRAP_SOURCE | bash
tar xzf $BOOTSTRAP_SOURCE/$BOOTSTRAP_FILE
mv root.x86_64/ $CHDIR
rm -r $BOOTSTRAP_SOURCE
 
#set up image in directory
cd $CHDIR
sed -i 's/^#Server/Server/' etc/pacman.d/mirrorlist
mkdir home/$USER
echo $USER:x:1000:1000:$USER:/home/$USER:/bin/bash >> etc/passwd
echo $USER::14871:::::: >> etc/shadow
mkdir -p build/repo
ln ../build.sh build/repo/build.sh
echo $LOCALE >> etc/locale.gen
mount --bind $CHDIR $CHDIR
bin/arch-chroot . bash -c "locale-gen;
                           pacman-key --init;
                           pacman-key --populate archlinux;
                           pacman -Syu --noconfirm base-devel vim git;
                           chown $USER:users /home/$USER;
                           su $USER -c \"git config --global credential.helper store;
                                                 git config --global user.name $GIT_USER;
                                            git config --global user.email $GIT_EMAIL\";"
echo "$USER ALL=(ALL) NOPASSWD:ALL" >> etc/sudoers
echo "Please set up the remote git repo for hosting"
echo "Navagate to /build/repo to init the repository"
echo "Press ctrl+d when finished"
bin/arch-chroot . su $USER
umount $CHDIR