add chroot software installation

This commit is contained in:
amolinae06 2025-05-18 14:33:56 -06:00
parent 98c8ac0ddf
commit 51038c8d41

View file

@ -8,6 +8,10 @@ apk_install(){
echo "installing $1"; apk add "$1" >/dev/null 2>&1 echo "installing $1"; apk add "$1" >/dev/null 2>&1
} }
bwroot_apk_install(){
echo "installing $1 on chroot"; su - "$user" -c "zsh -lc \"bwroot apk add $1 >/dev/null 2>&1\""
}
git_install(){ git_install(){
echo "cloning from $1"; su - "$user" -c "cd ~/.local/src && git clone \"$1\"" >/dev/null 2>&1 echo "cloning from $1"; su - "$user" -c "cd ~/.local/src && git clone \"$1\"" >/dev/null 2>&1
} }
@ -18,10 +22,11 @@ deploy_dotfiles(){
} }
read_software(){ read_software(){
tail -n +2 "$software" | sed -E ':a; s/("[^"]*),([^"]*")/\1\2/; ta' | while IFS=',' read -r NAME DESCRIPTION GIT GIT_URL; do tail -n +2 "$1" | sed -E ':a; s/("[^"]*),([^"]*")/\1\2/; ta' | while IFS=',' read -r NAME DESCRIPTION GIT GIT_URL; do
case "$GIT" in case "$GIT" in
"N") apk_install $NAME ;; "N") apk_install $NAME ;;
"Y") git_install "$GIT_URL" ;; "Y") git_install "$GIT_URL" ;;
"D") bwroot_apk_install $NAME ;;
*) echo "ERROR: failed to determine $NAME."; exit 1 ;; *) echo "ERROR: failed to determine $NAME."; exit 1 ;;
esac esac
done done
@ -49,6 +54,7 @@ EOF
setup_shell(){ setup_shell(){
sed -i "/^$user:/s#:[^:]*\$#:/bin/zsh#" /etc/passwd sed -i "/^$user:/s#:[^:]*\$#:/bin/zsh#" /etc/passwd
mkdir -p "/home/$user/.cache/zsh"
echo "changed "$user"'s shell to zsh" echo "changed "$user"'s shell to zsh"
} }
@ -63,7 +69,7 @@ setup_home(){
} }
setup_chroot(){ setup_chroot(){
printf "Setting up chroot" printf "Setting up chroot\n"
apk_install curl apk_install curl
cd "/home/$user/Documents/Miscellaneous" cd "/home/$user/Documents/Miscellaneous"
mkdir alpchroot mkdir alpchroot
@ -74,7 +80,7 @@ setup_chroot(){
mount -t proc none alpchroot/proc mount -t proc none alpchroot/proc
mount -o bind /sys alpchroot/sys mount -o bind /sys alpchroot/sys
cp -L /etc/resolv.conf alpchroot/etc/ cp -L /etc/resolv.conf alpchroot/etc/
chown -R "$user":"$user" alpchroot/ chown -R "$user":"$user" alpchroot/ >/dev/null 2>&1
mkdir -p alpchroot/etc/apk mkdir -p alpchroot/etc/apk
echo "https://dl-cdn.alpinelinux.org/alpine/latest-stable/main" > alpchroot/etc/apk/repositories echo "https://dl-cdn.alpinelinux.org/alpine/latest-stable/main" > alpchroot/etc/apk/repositories
apk del curl apk del curl
@ -95,10 +101,11 @@ check_root
echo "Welcome to the installer" echo "Welcome to the installer"
apk_install git apk_install git
get_user get_user
read_software read_software "$software"
setup_home setup_home
deploy_dotfiles deploy_dotfiles
setup_greetd setup_greetd
setup_shell setup_shell
setup_bluetooth setup_bluetooth
setup_chroot setup_chroot
read_software "$devsoftware"