installer/installer.sh
2025-06-07 03:07:15 +00:00

128 lines
3.4 KiB
Bash

#!/bin/sh
dotfiles="https://git.amolinae.com/amolinae06/dotfiles.git"
software="https://git.amolinae.com/amolinae06/installer/raw/branch/main/software.csv"
devware="https://git.amolinae.com/amolinae06/installer/raw/branch/main/devware.csv"
update_alpine(){
printf "Updating alpine indexes.\n"
doas apk update && doas apk upgrade
printf "Updated successfully.\n"
}
apk_install(){
echo "installing $1"; doas apk add "$1" >/dev/null 2>&1
}
bwapk_install (){
echo "installing $1 on chroot environment"
doas bwroot apk add "$1" >/dev/null 2>&1
}
git_install(){
echo "cloning from $1"; cd $HOME/.local/src && git clone \"$1\" >/dev/null 2>&1
}
read_software(){
[ -d "$HOME/.local/src/" ] || mkdir -p "$HOME/.local/src/"
([ -f "$1" ] && cp "$1" /tmp/temp.csv) || wget -qO- "$1" > /tmp/temp.csv
tail -n +2 "/tmp/temp.csv" | sed -E ':a; s/("[^"]*),([^"]*")/\1\2/; ta' | while IFS=',' read -r NAME DESCRIPTION GIT GIT_URL; do
case "$GIT" in
"N") apk_install $NAME ;;
"Y") git_install "$GIT_URL" ;;
"D") bwapk_install $NAME ;;
*) echo "ERROR: failed to determine $NAME."; exit 1 ;;
esac
done
rm "/tmp/temp.csv"
printf "Successfully installed all software!\n"
}
setup_greetd(){
printf "Setting up greetd\n"
[ -d "/etc/greetd" ] || mkdir "/etc/greetd"
doas cat <<EOF > /etc/greetd/config.toml
[terminal]
vt = 7
[default_session]
command = "agreety --cmd /home/$USER/.local/bin/dwllaunch"
user = "greetd"
EOF
doas rc-update add greetd default
printf "Finished setting up greetd.\n"
}
setup_shell(){
doas sed -i "/^$USER:/s#:[^:]*\$#:/bin/zsh#" /etc/passwd
mkdir -p $HOME/.cache/zsh
touch $HOME/.cache/zsh/history
echo "changed $USER's shell to zsh"
}
setup_bluetooth(){
printf "Setting up bluetooth\n"
doas rc-update add bluetooth default
printf "Done.\n"
}
setup_home(){
doas apk add git
printf "Deploying dotfiles...\n"
git clone --recursive $dotfiles
cd dotfiles
rm -rf .git .gitmodules
cp -r .cache .config .zprofile $HOME
cp -r .local/* $HOME/.local/
cd $HOME
rm -rf dotfiles/
xdg-user-dirs-update
mkdir $HOME/Documents/Miscellaneous
export PATH="$PATH:$(find ~/.local/bin -type d | paste -sd ':' -)"
doas apk del git
}
setup_chroot(){
printf "Setting up chroot\n"
doas apk add curl
cd $HOME/Documents/Miscellaneous
mkdir alpchroot
curl -LO https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/apk-tools-static-2.14.4-r1.apk
tar -xzf apk-tools-static-*.apk
./sbin/apk.static -X https://dl-cdn.alpinelinux.org/alpine/v3.20/main -U --allow-untrusted -p alpchroot/ --initdb add alpine-base
doas cp -L /etc/resolv.conf alpchroot/etc/
doas chown -R $USER:$USER alpchroot/ >/dev/null 2>&1
mkdir -p alpchroot/etc/apk
doas cp /etc/apk/repositories alpchroot/etc/apk/repositories
doas apk del curl
rm -rf sbin/ .PKGINFO .SIGN.RSA.alpine-devel@lists.alpinelinux.org-6165ee59.rsa.pub apk-tools-static-2.14.4-r1.apk
printf "Finished setting up chroot!\n"
}
compile() {
cd "$HOME/.local/src/$1/"
bwroot make clean install
}
echo "Welcome to the installer"
update_alpine
doas apk add git
read_software "$software"
setup-wayland-base
setup_home
setup_greetd
setup_shell
setup_bluetooth
setup_chroot
read_software "$devware"
compile dwl
compile slstatus
compile hellwal
compile ctpv
doas apk del git
printf "Installation finished, before you reboot please install packages you need (e.g nvidia/amd drivers)\n"; exit 0