From 5692fcf15d24ba2ec066413276d0dd4d8e5e3e76 Mon Sep 17 00:00:00 2001 From: lemniskett Date: Wed, 28 Oct 2020 10:02:56 +0700 Subject: [PATCH] Proper chroot setup. --- archbox.bash | 7 ++----- chroot_setup.bash | 26 ++++++++++++++++++++++++++ install.sh | 2 ++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100755 chroot_setup.bash diff --git a/archbox.bash b/archbox.bash index 4e72fb5..654d1e9 100755 --- a/archbox.bash +++ b/archbox.bash @@ -70,11 +70,8 @@ case $1 in mkdir -p $CHROOT/lib/modules mount -R /lib/modules $CHROOT/lib/modules mount -R /boot $CHROOT/boot - ;; - --setup) - asroot - cp /usr/local/share/archbox/chroot_setup.bash $CHROOT/chroot_setup - chroot $CHROOT /bin/bash -c "sh /chroot_setup" + cp /usr/local/share/archbox/chroot_setup.bash $CHROOT/chroot_setup + chroot $CHROOT /bin/bash -c "sh /chroot_setup" ;; --enter) copyresolv diff --git a/chroot_setup.bash b/chroot_setup.bash new file mode 100755 index 0000000..c9ce39c --- /dev/null +++ b/chroot_setup.bash @@ -0,0 +1,26 @@ +#!/bin/bash + +err(){ + echo "$(tput bold)$(tput setaf 1)==> $@ $(tput sgr0)" + exit 1 +} + +msg(){ + echo "$(tput bold)$(tput setaf 2)==> $@ $(tput sgr0)" +} + +msg "Initializing pacman keyrings..." +pacman-key --init +pacman-key --populate archlinux +msg "Installing essential packages..." +pacman -Syu base base-devel xorg --noconfirm +msg "Creating user account..." +echo "Enter the name of the user account, you may want it to be the same as the host os so it will share the same home directory" +read CHROOT_USER +useradd -m $CHROOT_USER +gpasswd -a $CHROOT_USER wheel +echo "Enter root password" +passwd +echo "Enter $CHROOT_USER password" +passwd $CHROOT_USER +sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers diff --git a/install.sh b/install.sh index ff149e4..450213f 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,9 @@ #!/bin/sh +mkdir -p /usr/local/share/archbox/bin cp -v ./archbox.bash /usr/local/bin/archbox cp -v ./archbox.conf /etc/archbox.conf cp -v ./archboxenter.bash /usr/local/share/archbox/bin/archboxenter cp -v ./copyresolv.bash /usr/local/share/archbox/bin/copyresolv cp -v ./archboxcommand.bash /usr/local/share/archbox/bin/archboxcommand +cp -v ./chroot_setup.bash /usr/local/share/archbox/chroot_setup.bash