From 90f8321e47d8758dce325ee77a111274a2303b4e Mon Sep 17 00:00:00 2001 From: AlexvZyl Date: Mon, 3 Jun 2024 17:05:34 +0200 Subject: [PATCH] Ref: Update scritps Ref: Update scritps Squash Tweak script Squash --- .scripts/install/bootstrap.sh | 36 +++++++++---- .scripts/install/display.sh | 24 --------- .scripts/install/hardware.sh | 35 ------------- .scripts/install/install.sh | 14 ----- .scripts/install/links.sh | 9 ---- .scripts/install/minimal_workspace.sh | 75 --------------------------- .scripts/install/misc.sh | 8 --- .scripts/install/security.sh | 34 ------------ 8 files changed, 25 insertions(+), 210 deletions(-) delete mode 100755 .scripts/install/display.sh delete mode 100755 .scripts/install/hardware.sh delete mode 100755 .scripts/install/install.sh delete mode 100755 .scripts/install/links.sh delete mode 100755 .scripts/install/minimal_workspace.sh delete mode 100755 .scripts/install/security.sh diff --git a/.scripts/install/bootstrap.sh b/.scripts/install/bootstrap.sh index 0ffb6ee5..ba165bff 100755 --- a/.scripts/install/bootstrap.sh +++ b/.scripts/install/bootstrap.sh @@ -1,25 +1,31 @@ #!/bin/bash -if [ -z ${SUDO_USER} ] +# TODO(alex): Which of these can be done with Nix? + +# Get user. +if [ -z "${SUDO_USER}" ] then export USER_HOME="$HOME" else export USER_HOME="/home/${SUDO_USER}" fi -# Clone. -sudo pacman -S git +# Clone and build +nix-env --install git + mkdir ~/.dotfiles -git --git-dir=$USER_HOME/.dotfiles/ --work-tree=$USER_HOME clone --bare https://github.com/AlexvZyl/.dotfiles $USER_HOME/.dotfiles/ -git --git-dir=$USER_HOME/.dotfiles/ --work-tree=$USER_HOME checkout -f -source $USER_HOME/.profile +git --git-dir="$USER_HOME/.dotfiles/" --work-tree="$USER_HOME" clone --bare https://github.com/AlexvZyl/.dotfiles "$USER_HOME/.dotfiles/" +git --git-dir="$USER_HOME/.dotfiles/" --work-tree="$USER_HOME" checkout -f -# Needed for install. -$USER_HOME/.scripts/install/links.sh +source "$USER_HOME/.profile" +nix-build -# Setup git. +# Setup GitHub. gh auth login +gh extension install dlvhdr/gh-dash config config --local status.showUntrackedFiles no +git config --global user.email "alexandervanzyl@protonmail.com" +git config --global user.name "AlexvZyl" # Get modules. config submodule update --init --force --remote .password-store/ @@ -28,5 +34,13 @@ config submodule update --init --force --remote .modules/user.js/ config submodule update --init --force --remote .config/nvim/ config submodule update --init --force --remote .tmux/plugins/tpm -# Run main install script. -$USER_HOME/.scripts/install/install.sh +# Setup ssh. +sudo rm -rdf "$USER_HOME/.ssh" +sudo ln -f -s -d "$USER_HOME/.private/.ssh/" "$USER_HOME/" +chmod +x 600 ~/.ssh/ + +# Tmux +"$USER_HOME/.tmux/plugins/tpm/bin/install_plugins" + +config config pull.rebase=true +config config remote.origin.url=git@github.com:AlexvZyl/.dotfiles.git diff --git a/.scripts/install/display.sh b/.scripts/install/display.sh deleted file mode 100755 index dac303ef..00000000 --- a/.scripts/install/display.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -source "$(dirname $0)/../utils.sh" - -# SDDM Login Manager -sudo systemctl disable display-manager -sudo systemctl enable sddm - -# Nordic -# sudo cp $USER_HOME/.wallpapers/National_Park_Nord.png /usr/share/sddm/themes/sugar-candy/Backgrounds/Mountain.jpg - -# Tokyonight -sudo cp $USER_HOME/.wallpapers/Tokyonight_Street_2.png /usr/share/sddm/themes/sugar-candy/Backgrounds/Mountain.jpg - -# Setup lock screen. -# Should this script run every time the screens change? Yeah. - -# Nordic -# betterlockscreen -u $USER_HOME/.wallpapers/National_Park_Nord.png --display 1 -# betterlockscreen -u $USER_HOME/.wallpapers/National_Park_Nord.png --blur 0.5 --display 1 - -# Tokyonight -betterlockscreen -u $USER_HOME/.wallpapers/tokyo-night-space_upscaled.png --display 1 & -betterlockscreen -u $USER_HOME/.wallpapers/tokyo-night-space_upscaled.png --blur 0.5 --display 1 & diff --git a/.scripts/install/hardware.sh b/.scripts/install/hardware.sh deleted file mode 100755 index 3aab3121..00000000 --- a/.scripts/install/hardware.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -source "$(dirname $0)/../utils.sh" - -# Make the function keys on the keyboard default over media keys. -# (This is currently specific to my keychron keyboard) -FILE=/etc/modprobe.d/hid_apple.conf -sudo touch $FILE -sudo sh -c "echo 'options hid_apple fnmode=2' >> $FILE" - -# Bluetooth. -systemctl enable bluetooth.service -systemctl restart bluetooth.service -sudo sed -i 's/#AutoEnable=false/AutoEnable=true/g' /etc/bluetooth/main.conf # Enable on startup. - -# Sound stuff. -# Prevent the crackling sound. -sudo sed -i 's/load-module module-udev-detect/load-module module-udev-detect tsched=0/g' /etc/pulse/default.pa - -# Power management. -systemctl enable tlp.service -systemctl mask systemd-rfkill.service -systemctl mask systemd-rfkill.socket -systemctl start tlp.service -sudo tlp start - -# Setup optimus manager. -if $NVIDIA_GPU; then - sudo sed -i 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm/custom.conf - sudo touch /etc/optimus-manager/optimus-manager.conf - sudo sh -c "echo '[optimus]' >> /etc/optimus-manager/optimus-manager.conf" - sudo sh -c "echo 'startup_mode=nvidia' >> /etc/optimus-manager/optimus-manager.conf" - systemctl enable optimus-manager - systemctl start optimus-manager & -fi diff --git a/.scripts/install/install.sh b/.scripts/install/install.sh deleted file mode 100755 index e9efc9a4..00000000 --- a/.scripts/install/install.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -source "$(dirname "$0")/../utils.sh" - -"$USER_HOME/.scripts/install/dual-boot.sh" -"$USER_HOME/.scripts/install/links.sh" -"$USER_HOME/.scripts/install/display.sh" -"$USER_HOME/.scripts/install/hardware.sh" -"$USER_HOME/.scripts/install/misc.sh" - -"$USER_HOME/.tmux/plugins/tpm/tpm" -"$USER_HOME/.tmux/plugins/tpm/bin/install_plugins" - -"$USER_HOME/.scripts/install/security.sh" diff --git a/.scripts/install/links.sh b/.scripts/install/links.sh deleted file mode 100755 index 5355b425..00000000 --- a/.scripts/install/links.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -source "$(dirname $0)/../utils.sh" - -sudo rm -rdf "$USER_HOME/.ssh" -sudo ln -f -s -d "$USER_HOME/.private/.ssh/" "$USER_HOME/" - -sudo rm /etc/nixos/configuration.nix -sudo ln -f -s "$USER_HOME/.config/nixos/configuration.nix" "/etc/nixos/configuration.nix" diff --git a/.scripts/install/minimal_workspace.sh b/.scripts/install/minimal_workspace.sh deleted file mode 100755 index acd52b17..00000000 --- a/.scripts/install/minimal_workspace.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash - -# Install dependencies. -if command -v pacman &>/dev/null; then - sudo pacman -Syyu - sudo pacman -S git neovim fish tmux trash -elif command -v apt &>/dev/null; then - sudo apt update - sudo apt upgrade - sudo apt install git neovim fish tmux -elif command brew -v &>/dev/null; then - brwe update - brew install neovim fish git tmux -else - echo "This script only supports Debian, Arch and MacOS." - exit 0 -fi - -# Paths. -WORK_TREE="$HOME" -NVIM_DIR="$WORK_TREE/.config/nvim" -GIT_DIR="$WORK_TREE/.workspace" -SPARSE_FILE="$GIT_DIR/info/sparse-checkout" - -# $1 Directory to backup. -function backup() { - BACKUP="$1.backup" - if [ -d $BACKUP ]; then - echo "\"$BACKUP\" is not empty, maybe a backup has already been made? The script is stopping, as I do not want to accidentally overwrite your configs. Please rename or delete this directory." - exit 0 - fi - if [ -d $1 ]; then - echo "Creating a backup of \"$1\" at \"$BACKUP\"." - mv "$1" "$BACKUP" - fi -} - -# Create backups. -if [ "$1" == "force" ]; then - echo "Forcing! Could override configs!" -else - backup "$NVIM_DIR" - backup "$WORK_TREE/.config/kitty" - backup "$WORK_TREE/.config/fish" - backup "$WORK_TREE/.config/tmux" - backup "$WORK_TREE/.tmux" - backup "$WORK_TREE/.scripts" -fi - -# Init repo. -mkdir -p "$GIT_DIR" -cd "$GIT_DIR" || exit -git init --bare -git remote add -f origin https://github.com/AlexvZyl/.dotfiles - -# Prepare partial clone. -git config core.sparseCheckout true -touch "$SPARSE_FILE" -echo ".config/nvim/*" >> "$SPARSE_FILE" -echo ".config/fish/*" >> "$SPARSE_FILE" -echo ".config/kitty/*" >> "$SPARSE_FILE" -echo ".config/tmux/*" >> "$SPARSE_FILE" -echo ".tmux/*" >> "$SPARSE_FILE" -echo ".scripts/" >> "$SPARSE_FILE" -echo ".profile" >> "$SPARSE_FILE" -echo ".gitignore" >> "$SPARSE_FILE" - -# Clone. -git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout main -git --work-tree=$WORK_TREE --git-dir=$GIT_DIR pull origin main -git --work-tree=$WORK_TREE --git-dir=$GIT_DIR submodule update --recursive --remote - -# Setup fish. -"$WORK_TREE/.scripts/install/shell.sh" -fish diff --git a/.scripts/install/misc.sh b/.scripts/install/misc.sh index 57bf777d..09abd223 100755 --- a/.scripts/install/misc.sh +++ b/.scripts/install/misc.sh @@ -3,15 +3,7 @@ source "$(dirname $0)/../utils.sh" # Cron. -crontab $USER_HOME/.config/cron/crontab -sudo systemctl enable cronie - -# Enable SysRq keys. -sudo touch /etc/sysctl.d/99-sysctl.conf -sudo sh -c "echo 'kernel.sysrq=1' >> /etc/sysctl.d/99-sysctl.conf" # Add bnaries to sudoers. sudo sh -c "echo '$USER ALL = NOPASSWD: /usr/bin/s-tui, /usr/bin/pacman, /usr/bin/fail2ban-client' >> /etc/sudoers" -# Github -gh extension install dlvhdr/gh-dash diff --git a/.scripts/install/security.sh b/.scripts/install/security.sh deleted file mode 100755 index f76bba4f..00000000 --- a/.scripts/install/security.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# ufw -( - sudo systemctl enable ufw.service - sudo systemctl start ufw.service - sudo ufw enable -) & - -# fail2ban -( - sudo systemctl enable fail2ban.service - sudo systemctl start fail2ban.service - sudo fail2ban-client start - sudo fail2ban-client add sshd -) & - -# clamav -( - sudo systemctl enable clamav-freshclam.service - sudo systemctl start clamav-freshclam.service -) & - -# Tor. -( - sudo systemctl enable tor.service - sudo systemctl start tor.service -) & - -# Proxy. -( - sudo systemctl enable privoxy.service - sudo systemctl start privoxy.service -) &