summaryrefslogtreecommitdiff
path: root/static/thesiah-debian.sh
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2024-07-10 11:55:07 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2024-07-10 11:55:07 +0900
commit923d659f52a7a7a7c87b8c1f9a19fd7f4be89392 (patch)
tree8d894acd4700b0ec4c39a2349faa396a77fdb97f /static/thesiah-debian.sh
parent5185c83c708f94d1e378541b48619864233b3982 (diff)
Init
Diffstat (limited to 'static/thesiah-debian.sh')
-rwxr-xr-xstatic/thesiah-debian.sh104
1 files changed, 100 insertions, 4 deletions
diff --git a/static/thesiah-debian.sh b/static/thesiah-debian.sh
index 24be8fe..53f5f71 100755
--- a/static/thesiah-debian.sh
+++ b/static/thesiah-debian.sh
@@ -68,9 +68,9 @@ installationloop() {
total=$(wc -l </tmp/progs.csv)
while IFS=, read -r tag program comment; do
case "$tag" in
- "G") gitcloneinstall "$program" "$comment" ;;
- "P") pipinstall "$program" ;;
- *) installpkg "$program" ;;
+ "G") gitmakeinstall "$program" "$comment" ;;
+ "P") pipinstall "$program" ;;
+ *) installpkg "$program" ;;
esac
done </tmp/progs.csv
}
@@ -86,6 +86,36 @@ putgitrepo() {
sudo -u "$name" cp -rfT "$dir" "$2"
}
+gitmakeinstall() {
+ progname="${1##*/}"
+ progname="${progname%.git}"
+ dir="$repodir/$progname"
+ whiptail --title "SI Installation" \
+ --infobox "Installing \`$progname\` ($n of $total) via \`git\` and \`make\`. $(basename "$1") $2" 8 70
+ sudo -u "$name" git -C "$repodir" clone --depth 1 --single-branch \
+ --no-tags -q "$1" "$dir" ||
+ {
+ cd "$dir" || return 1
+ sudo -u "$name" git pull --force origin master
+ }
+ # Check the repository name and act accordingly for suckless
+ case "$progname" in
+ "suckless")
+ for sub in "${dir}/"*; do
+ cd "$sub" || continue
+ make >/dev/null 2>&1
+ make install >/dev/null 2>&1
+ done
+ ;;
+ *)
+ cd "$dir" || exit 1
+ make >/dev/null 2>&1
+ make install >/dev/null 2>&1
+ ;;
+ esac
+ cd /tmp || return 1
+}
+
pipinstall() {
whiptail --title "SI Installation" \
--infobox "Installing the Python package \`$1\` ($n of $total). $1 $2" 9 70
@@ -102,6 +132,23 @@ vimplugininstall() {
sudo -u "$name" vim -c "PlugInstall|q|q"
}
+lfinstall() {
+ env CGO_ENABLED=0 go install -ldflags="-s -w" github.com/gokcehan/lf@latest
+}
+
+zoxideinstall() {
+ git clone https://github.com/ajeetdsouza/zoxide.git
+ cd zoxide
+ ./install.sh
+ cd /tmp
+}
+
+nviminstall() {
+ latest_version=$(curl -s https://api.github.com/repos/neovim/neovim/releases/latest | grep -o '"tag_name": ".*"' | cut -d'"' -f4)
+ download_url="https://github.com/neovim/neovim/releases/download/$latest_version/nvim.appimage"
+ curl -LO "$download_url"
+}
+
addsudo() {
echo "$name ALL=(ALL:ALL) ALL" >/etc/sudoers.d/00-thesiah-user-can-sudo
echo "$name ALL=(ALL:ALL) NOPASSWD: /usr/bin/shutdown,/usr/bin/reboot,/usr/bin/systemctl suspend,/usr/bin/wifi-menu,/usr/bin/mount,/usr/bin/umount,/usr/bin/apt update,/usr/bin/apt upgrade,/usr/bin/apt upgrade -y,/usr/bin/loadkeys,/usr/bin/apt-get --download-only upgrade" >/etc/sudoers.d/01-thesiah-cmds-without-password
@@ -110,6 +157,44 @@ addsudo() {
echo "kernel.dmesg_restrict = 0" >/etc/sysctl.d/dmesg.conf
}
+checksystem() {
+ if [ "$1" = "ufw" ]; then
+ ufw --force reload >/dev/null 2>&1
+ ufw default deny incoming >/dev/null 2>&1
+ ufw allow 80 >/dev/null 2>&1
+ ufw allow 443 >/dev/null 2>&1
+ ufw allow 25/tcp >/dev/null 2>&1
+ ufw allow 587/tcp >/dev/null 2>&1
+ ufw allow 3478/udp >/dev/null 2>&1
+ ufw allow 5349/tcp >/dev/null 2>&1
+ ufw allow 10000/udp >/dev/null 2>&1
+ ufw allow in ssh >/dev/null 2>&1
+ ufw allow in IMAPS >/dev/null 2>&1
+ ufw allow in POP3 >/dev/null 2>&1
+ ufw allow in SMTP >/dev/null 2>&1
+ ufw allow in 'WWW Full' >/dev/null 2>&1
+ ufw allow in 'Postfix SMTPS' >/dev/null 2>&1
+ ufw allow in 'Mail Submission' >/dev/null 2>&1
+ ufw enable >/dev/null 2>&1 || ufw --force enable >/dev/null 2>&1
+ fi
+ if [ "$1" = "smbd" ]; then
+ ufw --force reload >/dev/null 2>&1
+ ufw allow 137/tcp >/dev/null 2>&1
+ ufw allow 137/udp >/dev/null 2>&1
+ ufw allow 138/tcp >/dev/null 2>&1
+ ufw allow 138/udp >/dev/null 2>&1
+ ufw allow 139/tcp >/dev/null 2>&1
+ ufw allow 445/tcp >/dev/null 2>&1
+ [ -f /etc/samba/smb.conf ] && touch /etc/samba/smb.conf
+ sleep 1
+ printf "$pass1" | smbpasswd -a "$name" >/dev/null 2>&1
+ fi
+ if ! systemctl is-active --quiet "$1"; then
+ systemctl enable "$1"
+ systemctl start "$1"
+ fi
+}
+
finalize() {
whiptail --title "All done!" \
--msgbox "Congrats! Provided there were no hidden errors, the script completed successfully and all the programs and configuration files should be in place.\\n\\nTo run the new graphical environment, log out and log back in as your new user, then run the command \"startx\" to start the graphical environment (it will start automatically in tty1).\\n\\n.t Soomin" 13 80
@@ -122,7 +207,7 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1
fi
-essential_packages="curl ca-certificates build-essential git ntp zsh stow"
+essential_packages="curl ca-certificates build-essential git network-manager ntp zsh stow"
whiptail --title "SI Installation" --infobox "Installing essential packages required to install and configure other programs." 8 70
for package in $essential_packages; do
installpkg $package || error "Failed to install $package"
@@ -140,6 +225,12 @@ adduserandpass || error "Error adding username and/or password."
installationloop
+lfinstall || error "User exited."
+
+zoxideinstall || error "User exited."
+
+nviminstall || error "User exited."
+
putgitrepo "$dotfilesrepo" "/home/$name" "$repobranch"
rm -rf "/home/$name/.git/" "/home/$name/README.md" "/home/$name/LICENSE" "/home/$name/FUNDING.yml"
cd "/home/$name/.dotfiles" && stow --no-folding -S debian && stow --no-folding -S default || exit 1
@@ -178,4 +269,9 @@ EndSection' >/etc/X11/xorg.conf.d/40-libinput.conf
# (like `shutdown` to run without password).
addsudo
+systems="NetworkManager ssh bluetooth ufw"
+for system in $systems; do
+ checksystem $system || error "Failed to start $system"
+done
+
finalize