128 lines
3.5 KiB
Bash
128 lines
3.5 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(){
|
|
doas apk add "$1" >/dev/null 2>&1; echo "installing $1"
|
|
}
|
|
|
|
bwapk_install (){
|
|
doas chroot $HOME/Documents/Miscellaneous/alpchroot/ apk add "$1" >/dev/null 2>&1; echo "installing $1 on chroot environment"
|
|
}
|
|
|
|
git_install(){
|
|
cd $HOME/.local/src/; git clone "$1" >/dev/null 2>&1; echo "cloning from $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" ] || doas mkdir "/etc/greetd"
|
|
|
|
cat <<EOF | doas tee /etc/greetd/config.toml > /dev/null
|
|
[terminal]
|
|
vt = 7
|
|
|
|
[default_session]
|
|
command = "agreety --cmd $HOME/.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(){
|
|
xdg-user-dirs-update
|
|
doas apk add git
|
|
printf "Deploying dotfiles...\n"
|
|
git clone --recursive $dotfiles >/dev/null 2>&1
|
|
cd dotfiles
|
|
rm -rf .git .gitmodules
|
|
cp -r .config .zprofile $HOME
|
|
cp -r .local/* $HOME/.local/
|
|
cd $HOME
|
|
rm -rf dotfiles/
|
|
mkdir $HOME/Documents/Miscellaneous
|
|
export PATH="$PATH:$(find ~/.local/bin -type d | paste -sd ':' -)"
|
|
sed -i "s|/home/amolinae|/home/$USER|g" $HOME/.local/bin/bwroot
|
|
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"
|
|
doas setup-wayland-base
|
|
setup_greetd
|
|
setup_shell
|
|
setup_bluetooth
|
|
setup_home
|
|
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
|