merged scripts
This commit is contained in:
commit
4b957e5039
4 changed files with 59 additions and 107 deletions
89
installer.sh
89
installer.sh
|
@ -2,19 +2,19 @@
|
|||
|
||||
dotfiles="https://git.amolinae.com/amolinae06/dotfiles.git"
|
||||
software="https://git.amolinae.com/amolinae06/installer/raw/branch/main/software.csv"
|
||||
postinstall="https://git.amolinae.com/amolinae06/installer/raw/branch/main/postinstall.sh"
|
||||
devware="https://git.amolinae.com/amolinae06/installer/raw/branch/main/devware.csv"
|
||||
|
||||
apk_install(){
|
||||
echo "installing $1"; apk add "$1" >/dev/null 2>&1
|
||||
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"; su - "$user" -c "cd ~/.local/src && git clone \"$1\"" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
deploy_dotfiles(){
|
||||
printf "Deploying dotfiles...\n"
|
||||
su - $user -c "git clone $dotfiles && cd dotfiles && rm -rf .git .gitmodules README.md && cp -r .cache .config .local .zprofile /home/$user/ && cd && rm -rf dotfiles"
|
||||
echo "cloning from $1"; cd $HOME/.local/src && git clone \"$1\" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
read_software(){
|
||||
|
@ -24,6 +24,7 @@ read_software(){
|
|||
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
|
||||
|
@ -35,85 +36,81 @@ read_software(){
|
|||
setup_greetd(){
|
||||
printf "Setting up greetd\n"
|
||||
|
||||
# Check if greetd directory exists, if not, create it.
|
||||
[ -d "/etc/greetd" ] || mkdir "/etc/greetd"
|
||||
|
||||
cat <<EOF > /etc/greetd/config.toml
|
||||
doas cat <<EOF > /etc/greetd/config.toml
|
||||
[terminal]
|
||||
vt = 7
|
||||
|
||||
[default_session]
|
||||
command = "tuigreet -t -r --cmd /home/$user/.local/bin/dwllaunch"
|
||||
command = "agreety -t -r --cmd /home/$USER/.local/bin/dwllaunch"
|
||||
user = "greetd"
|
||||
EOF
|
||||
|
||||
rc-update add greetd default
|
||||
doas rc-update add greetd default
|
||||
printf "Finished setting up greetd.\n"
|
||||
}
|
||||
|
||||
setup_shell(){
|
||||
sed -i "/^$user:/s#:[^:]*\$#:/bin/zsh#" /etc/passwd
|
||||
mkdir -p "/home/$user/.cache/zsh"
|
||||
touch "/home/$user/.cache/zsh/history"
|
||||
chown -R "$user":"$user" "/home/$user/.cache/"
|
||||
echo "changed "$user"'s shell to zsh"
|
||||
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"
|
||||
rc-update add bluetooth default
|
||||
doas rc-update add bluetooth default
|
||||
printf "Done.\n"
|
||||
}
|
||||
|
||||
setup_home(){
|
||||
su - $user -c "xdg-user-dirs-update && mkdir ~/Documents/Miscellaneous"
|
||||
doas apk add git
|
||||
printf "Deploying dotfiles...\n"
|
||||
git clone --recursive $dotfiles
|
||||
cd dotfiles
|
||||
rm -rf .git .gitmodules
|
||||
cp -r .cache .config .local .zprofile $HOME
|
||||
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"
|
||||
apk_install curl
|
||||
cd "/home/$user/Documents/Miscellaneous"
|
||||
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
|
||||
mount -o bind /dev alpchroot/dev
|
||||
mount -t proc none alpchroot/proc
|
||||
mount -o bind /sys alpchroot/sys
|
||||
cp -L /etc/resolv.conf alpchroot/etc/
|
||||
chown -R "$user":"$user" alpchroot/ >/dev/null 2>&1
|
||||
doas cp -L /etc/resolv.conf alpchroot/etc/
|
||||
doas chown -R $USER:$USER alpchroot/ >/dev/null 2>&1
|
||||
mkdir -p alpchroot/etc/apk
|
||||
cp /etc/apk/repositories alpchroot/etc/apk/repositories
|
||||
apk del curl
|
||||
doas cp /etc/apk/repositories alpchroot/etc/apk/repositories
|
||||
doas apk del curl
|
||||
printf "Finished setting up chroot!\n"
|
||||
}
|
||||
|
||||
post_install(){
|
||||
printf "Postinstall\n"
|
||||
([ -f "$postinstall" ] && cp "$postinstall" /tmp/postinstall.sh) || wget -qO- "$1" > /tmp/postinstall.sh
|
||||
su - "$user" -c "zsh -lc 'sh /tmp/postinstall.sh \"$@\" '"
|
||||
compile() {
|
||||
cd "$HOME/.local/src/$1/"
|
||||
bwroot make clean install
|
||||
}
|
||||
|
||||
check_root(){
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "ERROR: you must run this script as root."; exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_user(){
|
||||
printf "Please enter the name of your user: "
|
||||
read -r user
|
||||
}
|
||||
|
||||
check_root
|
||||
compile "dwl"
|
||||
echo "Welcome to the installer"
|
||||
apk_install git
|
||||
get_user
|
||||
read_software "$software"
|
||||
setup_home
|
||||
deploy_dotfiles
|
||||
setup_greetd
|
||||
setup_shell
|
||||
setup_bluetooth
|
||||
setup_chroot
|
||||
post_install "$user"
|
||||
read_software "$devware"
|
||||
compile dwl
|
||||
compile slstatus
|
||||
compile hellwal
|
||||
compile ctpv
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue