From a8ebf867c72212fd629f4dac97f6ab0fd6e8f1db Mon Sep 17 00:00:00 2001 From: Erich L Foster Date: Fri, 3 May 2024 12:45:07 +0200 Subject: [PATCH] The major install shakeup --- docker/tvnamer/Dockerfile | 38 ++++ docker/tvnamer/init | 37 ++++ install.sh | 442 ++------------------------------------ my-home/dot-aliases | 1 + scripts/devcontainer.sh | 32 +++ scripts/mac.sh | 24 +++ scripts/main.sh | 344 +++++++++++++++++++++++++++++ scripts/nas.sh | 64 ++++++ scripts/phone.sh | 38 ++++ scripts/utils.sh | 131 +++++++++++ 10 files changed, 732 insertions(+), 419 deletions(-) create mode 100644 docker/tvnamer/Dockerfile create mode 100755 docker/tvnamer/init create mode 100755 scripts/devcontainer.sh create mode 100755 scripts/mac.sh create mode 100755 scripts/main.sh create mode 100755 scripts/nas.sh create mode 100755 scripts/phone.sh create mode 100644 scripts/utils.sh diff --git a/docker/tvnamer/Dockerfile b/docker/tvnamer/Dockerfile new file mode 100644 index 0000000..7d16577 --- /dev/null +++ b/docker/tvnamer/Dockerfile @@ -0,0 +1,38 @@ +FROM debian:sid-slim + +ENV LC_ALL=C.UTF-8 \ + LANG=C.UTF-8 \ + LANGUAGE=en_US:en + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN set -x && \ + KEPT_PACKAGES=() && \ + # Packages kept in the image + KEPT_PACKAGES+=(bash) && \ + KEPT_PACKAGES+=(ca-certificates) && \ + KEPT_PACKAGES+=(locales) && \ + KEPT_PACKAGES+=(locales-all) && \ + KEPT_PACKAGES+=(python3) && \ + KEPT_PACKAGES+=(python-is-python3) && \ + KEPT_PACKAGES+=(python3-pip) && \ + KEPT_PACKAGES+=(python3-pyxattr) && \ + KEPT_PACKAGES+=(adduser) && \ + # Install packages + apt-get update -y && \ + apt-get install -y --no-install-recommends \ + ${KEPT_PACKAGES[@]} \ + && \ + # Create /config directory + mkdir -p /config && \ + # Clean-up + apt-get autoremove -y && \ + apt-get clean -y && \ + rm -rf /var/lib/apt/lists/* /tmp/* +RUN rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED && \ + pip3 install --no-cache tvnamer + +# # Copy init script, set workdir, set configdir & entrypoint +COPY init /init +WORKDIR /workdir +ENTRYPOINT ["/init"] diff --git a/docker/tvnamer/init b/docker/tvnamer/init new file mode 100755 index 0000000..b12f1c9 --- /dev/null +++ b/docker/tvnamer/init @@ -0,0 +1,37 @@ +#!/bin/bash + +# Create dockeruser homedir +mkdir -p /home/dockeruser + +# Set UID/PID of user that youtube-dl will be run as +TVNAMERPGID=${PGID:-1000} +TVNAMERPUID=${PUID:-1000} + +# Check to see if group/user already exist, if so, delete +EXISTINGGROUPNAME=$(getent group "$TVNAMERPGID" | cut -d ':' -f 1) +EXISTINGUSERNAME=$(getent passwd "$TVNAMERPUID" | cut -d ':' -f 1) +if [[ -n "$EXISTINGGROUPNAME" ]]; then + groupdel -f "$EXISTINGGROUPNAME" +fi +if [[ -n "$EXISTINGUSERNAME" ]]; then + userdel -f "$EXISTINGUSERNAME" +fi + +# Create user/group +addgroup --quiet --gid "$TVNAMERPGID" dockeruser +chown -R "$TVNAMERPUID":"$TVNAMERPGID" /home/dockeruser +adduser --quiet --system --disabled-password --uid "$TVNAMERPUID" --gid "$TVNAMERPGID" --home /home/dockeruser dockeruser +HOME=/home/dockeruser +export HOME + +# Set UMASK if required +if [[ -n "$UMASK" ]]; then + umask "$UMASK" +fi + +# Run tvnamer with remainder of command line arguments +if [ -f /config/tvnamerconfig.json ]; then + setpriv --reuid dockeruser --regid dockeruser --keep-groups tvnamer -c /config/tvnamerconfig.json "$@" +else + setpriv --reuid dockeruser --regid dockeruser --keep-groups tvnamer "$@" +fi diff --git a/install.sh b/install.sh index 0e40094..1ec8c0c 100755 --- a/install.sh +++ b/install.sh @@ -1,425 +1,29 @@ #!/bin/bash -set -e - -THIS=$0 - -sudo apt-get install -y dialog git stow - -# get the version of ubuntu -codename=`lsb_release -a 2>/dev/null | grep Codename | awk -F ' ' '{print $2}'` -release=`lsb_release -a 2>/dev/null | grep Release | awk -F ' ' '{print $2}'` - -DOTFILES_DIR=$(pwd) -echo "$DOTFILES_DIR" -############################# grab dotfiles #################################### -# dotfiles already exist since I am running this script! -# git clone git@github.com:erichlf/dotfiles.git -git submodule update --init --recursive - -cmd=( \ - dialog \ - --clear \ - --cancel-label "Exit" \ - --backtitle "system setup" \ - --menu "Welcome to Erich's system setup.\nWhat would you like to do?" \ - 14 50 16 \ -) - -options=(1 "Fresh system setup" - 2 "Create symbolic links" - 2 "Install base system" - 4 "Install TU Delft tools" - 5 "Latitude 7440 Hacks" - 6 "Install LaTeX" - 7 "Remove crapware" - 8 "Update system" - 9 "sudo rules") +set -e -if [ $CI ]; then - choices=1 +# get the kernel string +os = $(uname -o) + +if [[ "$os" == "Linux" ]]; then + kernel = $(uname -r) + case "$kernel" in + *"generic"* ) + if [[ $DEV_WORKSPACE ~= "" ]]; then + ./scripts/devcontainer.sh + else + ./scripts/main.sh + fi + ;; + *"qnap"* ) + ./scripts/nas.sh + ;; + esac +elif [[ "$os" == "Android" ]]; then + ./scripts/phone.sh +elif [[ "$os" == "Darwin" ]]; then + ./scripts/mac.sh else - choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) + echo "Unknown system. KTHNXBYE" fi -function run_me() { - bash $THIS -} - -function ask(){ - read -p "$1 [$2] " answer - answer="${answer:-$2}" - case "$answer" in - y|Y ) return 0;; - n|N ) return 1;; - * ) ask "$1" "$2";; - esac -} - -function no_ppa_exists(){ - ppa_added=`grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/* | grep -v list.save | grep -v deb-src | grep deb | grep $1 | wc -l` - [ $ppa_added == 0 ]; -} - -function add_ppa(){ - sudo add-apt-repository ppa:$1 -y - apt_update - - return 0 -} - -function apt_update(){ - sudo apt-get update 1>/dev/null -} - -function apt_install(){ - sudo apt-get install -y $@ - - return 0 -} - -function pip3_install(){ - sudo -H pip3 install $@ - - return 0 -} - -function snap_install(){ - sudo snap install $@ - - return 0 -} - -function sudo_rule(){ - echo "$USER ALL = NOPASSWD: $@" | sudo tee -a /etc/sudoers - - return 0 -} - -#create my links -function sym_links(){ - mkdir -p $HOME/.config - stow -v --dotfiles --adopt --dir $DOTFILES_DIR --target $HOME --restow my-home - stow -v --adopt --dir $DOTFILES_DIR/private/ --target $HOME/.ssh --restow .ssh - stow -v --adopt --dir $DOTFILES_DIR --target $HOME/.config/ --restow config - # if the adopt made a local change then undo that - git checkout HEAD -- config my-home private - - return 0 -} - -############################# my base system ################################### -#bikeshed contains utilities such as purge-old-kernels -function base_sys(){ - sudo add-apt-repository -y universe - - echo "Setting up shell..." - if no_ppa_exists linuxuprising - then - add_ppa linuxuprising/guake - fi - - apt_install \ - btop \ - cifs-utils \ - curl \ - dconf-cli \ - dconf-editor \ - fzf \ - gnome-tweaks \ - guake \ - iftop \ - nfs-common \ - tmux \ - wget \ - zsh - - guake --restore-preferences $DOTFILES_DIR/guake.conf - - sudo chsh -s $(which zsh) $(whoami) - - # memory for cd - curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash - - # zsh plugin manager - [ ! -d $HOME/.zgenom ] && git clone https://github.com/jandamm/zgenom.git ${HOME}/.zgenom - - # tool to figure out why my last command didn't work - snap_install thefuck --beta --classic - - curl -sSL https://get.rvm.io | bash - - # install fonts - curl -fsSL https://raw.githubusercontent.com/getnf/getnf/main/install.sh | bash - $HOME/.local/bin/getnf -i DejaVuSansMono,DroidSansMono,Hack,Recursive,RobotoMono - - # setup starship - curl -sS https://starship.rs/install.sh -o starship.sh - chmod +x starship.sh - mkdir -p $HOME/.local/bin - ./starship.sh --bin-dir $HOME/.local/bin/ -y - rm -f starship.sh - - echo "Setting up networking..." - apt_install \ - network-manager-openvpn \ - network-manager-openvpn-gnome \ - network-manager-vpnc \ - openssh-server - - echo "Installing developer tools..." - if [ ! -d "$HOME/workspace" ]; then - mkdir "$HOME/workspace" - fi - - apt_install \ - build-essential \ - clang \ - clang-format \ - clang-tools \ - cmake \ - g++ \ - gcc \ - git-completion \ - global \ - libtool-bin \ - meld \ - python3-dev \ - python3-ipython \ - python3-matplotlib \ - python3-numpy \ - python3-pip \ - python3-scipy \ - python3-setuptools - - echo "Installing python linters..." - pip3_install \ - autoflake \ - black \ - flake8 \ - isort \ - pep257 \ - pylint \ - wheel \ - yapf - - if no_ppa_exists ppa-verse - then - add_ppa ppa-verse/neovim - fi - - echo "Installing VIM..." - apt_install \ - git-lfs \ - golang-go \ - neovim \ - nodejs \ - python3-git \ - python3-venv \ - python3-yaml \ - xclip - - # treesitter for vim - npm install -g neovim tree-sitter - snap_install --edge chafa # needed by telescope-media-files - - # install lunarvim - curl -sSL https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh | LV_BRANCH='release-1.3/neovim-0.9' bash -s -- -y - - # install lazygit - LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | \grep -Po '"tag_name": "v\K[^"]*') - cd /tmp - curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" - tar xf lazygit.tar.gz lazygit - install lazygit $HOME/.local/bin - cd - - - sudo update-alternatives --config editor - - echo "Setting up docker..." - apt_install \ - ca-certificates \ - containerd \ - gnupg - - apt_update - apt_install \ - docker-compose \ - docker.io \ - - sudo usermod -a -G docker $USER - sudo systemctl daemon-reload - sudo systemctl restart docker - - newgrp docker - - echo "Installing vscode..." - npm install -g @devcontainers/cli - - apt_install \ - apt-transport-https \ - software-properties-common - wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" - apt_install code - - # install vs code and git-credential-manager for using devcontainer and development - wget "https://github.com/git-ecosystem/git-credential-manager/releases/download/v2.3.2/gcm-linux_amd64.2.3.2.deb" -O /tmp/gcmcore.deb - sudo dpkg -i /tmp/gcmcore.deb - git-credential-manager configure - - echo "net.core.rmem_max=26214400" | sudo tee /etc/sysctl.d/10-udp-buffer-sizes.conf - echo "net.core.rmem_default=26214400" | sudo tee -a /etc/sysctl.d/10-udp-buffer-sizes.conf - - echo "Installing extras..." - apt_update - apt_install chrome-gnome-shell - - cd /tmp - wget -c https://downloads.vivaldi.com/stable/vivaldi-stable_6.6.3271.45-1_amd64.deb - sudo dpkg -i vivaldi-stable*.deb - cd $DOTFILES_DIR - - curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg - echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/amd64 stable main' | sudo tee /etc/apt/sources.list.d/1password.list - sudo mkdir -p /etc/debsig/policies/AC2D62742012EA22/ - curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol | sudo tee /etc/debsig/policies/AC2D62742012EA22/1password.pol - sudo mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22 - curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg - - apt_update - apt_install 1password - - # add 1password support to vivaldi - sudo mkdir -p /etc/1password - echo "vivaldi-bin" | sudo tee /etc/1password/custom_allowed_browsers - sudo chown root:root /etc/1password/custom_allowed_browsers - sudo chmod 755 /etc/1password/custom_allowed_browsers - - # install signal desktop - snap_install signal-desktop - - return 0 -} - -function tudelft(){ - snap_install teams-for-linux - - wget -O- https://app.eduvpn.org/linux/v4/deb/app+linux@eduvpn.org.asc | gpg --dearmor | sudo tee /usr/share/keyrings/eduvpn-v4.gpg >/dev/null - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/eduvpn-v4.gpg] https://app.eduvpn.org/linux/v4/deb/ jammy main" | sudo tee /etc/apt/sources.list.d/eduvpn-v4.list - apt_update - apt_install eduvpn-client - - return 0 -} - -# install latex -function LaTeX(){ - cd /tmp - wget https://github.com/scottkosty/install-tl-ubuntu/raw/master/install-tl-ubuntu - sudo chmod +x install-tl-ubuntu - sudo ./install-tl-ubuntu - - PATH=/usr/local/texlive/20*/bin/x86_64-linux:$PATH - tlmgr install arara - - cd $DOTFILES_DIR - - return 0 -} - -########################## Computer Specific #################################### -function latitude_7440(){ - # install driver for fingerprint scanner, enable it, and enroll left and right - # index fingers - wget "http://dell.archive.canonical.com/updates/pool/public/libf/libfprint-2-tod1-broadcom/libfprint-2-tod1-broadcom_5.12.018-0ubuntu1~22.04.01_amd64.deb" -O /tmp/broadcom-fingerprint.deb - sudo install libfprint-2-tod1 fprintd libpam-frintd - sudo dpkg -i /tmp/broadcom-fingerprint.deb - sudo fprintd-enroll -f left-index-finger - sudo fprintd-enroll -f right-index-finger - sudo pam-auth-update --enable fprintd - - # fix keyboard function keys - sudo apt-get reinstall -y libgdk-pixbuf2.0-0 - echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode - echo "options hid_apple fnmode=0" | sudo tee -a /etc/modprobe.d/hid_apple.conf - sudo update-initramfs -u -} - -######################## remove things I never use ############################# -function crapware(){ - echo "Removing crapware..." - pkgs="thunderbird transmission-gtk" - for pkg in $(echo $pkgs); do - echo "Removing $pkgsToRemove" - sudo apt-get --yes --purge remove $pkg || true - done - - return 0 -} - -########################## update and upgrade ################################## -function update_sys(){ - echo "Updating system..." - apt_update - sudo apt-get -y upgrade - - return 0 -} - -############################## annoyances ###################################### -function sudo_rules(){ - echo "Setting sudo rules..." - sudo_rule /sbin/shutdown - sudo_rule /sbin/reboot - - return 0 -} - -for choice in $choices -do - case $choice in - 1) - sym_links - base_sys - crapware - update_sys - sudo apt-get -y autoremove - sudo_rules - [ $CI ] && exit - run_me - ;; - 2) - sym_links - run_me - ;; - 3) - base_sys - run_me - ;; - 4) - tudelft - run_me - ;; - 5) - latitude_7440 - run_me - ;; - 6) - LaTeX - run_me - ;; - 7) - crapware - run_me - ;; - 8) - update_sys - run_me - ;; - 9) - sudo_rules - run_me - ;; - esac -done diff --git a/my-home/dot-aliases b/my-home/dot-aliases index a895f88..7d3540d 100644 --- a/my-home/dot-aliases +++ b/my-home/dot-aliases @@ -6,3 +6,4 @@ alias ll='ls -lh' alias la='ls -a' alias lla='ls -lah' alias grep='grep --color=always' +alias bat='batcat' diff --git a/scripts/devcontainer.sh b/scripts/devcontainer.sh new file mode 100755 index 0000000..8268fb7 --- /dev/null +++ b/scripts/devcontainer.sh @@ -0,0 +1,32 @@ +#!/bin/bash +SYSTEM="DEVCONTAINER" +DOTFILES_DIR=$HOME/dotfiles + +source utils.sh + +print_details + +# change to zsh as default shell +sudo chsh -s /usr/bin/zsh + +cd $DOTFILES_DIR + +# ensure that submodules are downloaded +git submodule init +git submodule update + +# create links to dotfiles +sym_links + +# get the newest neovim +sudo add-apt-repository ppa:ppa-verse/neovim -y +sudo apt-get update +sudo apt-get install -y neovim + +lunarvim_install + +zsh_extras + +starship_install + +lazygit_install diff --git a/scripts/mac.sh b/scripts/mac.sh new file mode 100755 index 0000000..4993010 --- /dev/null +++ b/scripts/mac.sh @@ -0,0 +1,24 @@ +#!/bin/bash +SYSTEM="MAC" +DOTFILES_DIR=$(pwd) + +source details.sh + +print_details "$SYSTEM" + +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + +brew install neovim fzf starship stow gpg + +chsh -s /bin/zsh + +git submodule init +git submodule update + +sym_links + +zsh_extras + +lazygit_install + +lunarvim_install diff --git a/scripts/main.sh b/scripts/main.sh new file mode 100755 index 0000000..9eb39de --- /dev/null +++ b/scripts/main.sh @@ -0,0 +1,344 @@ +#!/bin/bash +SYSTEM="MAIN" +DOTFILES_DIR=$(pwd) + +source utils.sh + +print_details + +set -e + +THIS=$0 + +sudo apt-get install -y dialog git stow + +# get the version of ubuntu +codename=`lsb_release -a 2>/dev/null | grep Codename | awk -F ' ' '{print $2}'` +release=`lsb_release -a 2>/dev/null | grep Release | awk -F ' ' '{print $2}'` + +############################# grab dotfiles #################################### +# dotfiles already exist since I am running this script! +# git clone git@github.com:erichlf/dotfiles.git +git submodule update --init --recursive + +cmd=( \ + dialog \ + --clear \ + --cancel-label "Exit" \ + --backtitle "system setup" \ + --menu "Welcome to Erich's system setup.\nWhat would you like to do?" \ + 14 50 16 \ +) + +options=(1 "Fresh system setup" + 2 "Create symbolic links" + 2 "Install base system" + 4 "Install TU Delft tools" + 5 "Latitude 7440 Hacks" + 6 "Install LaTeX" + 7 "Remove crapware" + 8 "Update system" + 9 "sudo rules") + +if [ $CI ]; then + choices=1 +else + choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) +fi + +function run_me() { + bash $THIS +} + +############################# my base system ################################### +#bikeshed contains utilities such as purge-old-kernels +function base_sys(){ + sudo add-apt-repository -y universe + + echo "Setting up shell..." + if no_ppa_exists linuxuprising + then + add_ppa linuxuprising/guake + fi + + apt_install \ + btop \ + cifs-utils \ + curl \ + dconf-cli \ + dconf-editor \ + fzf \ + gnome-tweaks \ + guake \ + iftop \ + nfs-common \ + tmux \ + wget \ + zsh + + guake --restore-preferences $DOTFILES_DIR/guake.conf + + sudo chsh -s $(which zsh) $(whoami) + + curl -sSL https://get.rvm.io | bash + + zsh_extras + + starship_install + + lazygit_install + + echo "Setting up networking..." + apt_install \ + network-manager-openvpn \ + network-manager-openvpn-gnome \ + network-manager-vpnc \ + openssh-server + + echo "Installing developer tools..." + if [ ! -d "$HOME/workspace" ]; then + mkdir "$HOME/workspace" + fi + + apt_install \ + build-essential \ + clang \ + clang-format \ + clang-tools \ + cmake \ + g++ \ + gcc \ + git-completion \ + global \ + libtool-bin \ + meld \ + python3-dev \ + python3-ipython \ + python3-matplotlib \ + python3-numpy \ + python3-pip \ + python3-scipy \ + python3-setuptools + + echo "Installing python linters..." + pip3_install \ + autoflake \ + black \ + flake8 \ + isort \ + pep257 \ + pylint \ + wheel \ + yapf + + if no_ppa_exists ppa-verse + then + add_ppa ppa-verse/neovim + fi + + echo "Installing VIM..." + apt_install \ + git-lfs \ + golang-go \ + neovim \ + nodejs \ + python3-git \ + python3-venv \ + python3-yaml \ + xclip + + # treesitter for vim + npm install -g neovim tree-sitter + snap_install --edge chafa # needed by telescope-media-files + + lunarvim_install + + sudo update-alternatives --config editor + + echo "Setting up docker..." + apt_install \ + ca-certificates \ + containerd \ + gnupg + + apt_update + apt_install \ + docker-compose \ + docker.io \ + + sudo usermod -a -G docker $USER + sudo systemctl daemon-reload + sudo systemctl restart docker + + newgrp docker + + echo "Installing vscode..." + npm install -g @devcontainers/cli + + apt_install \ + apt-transport-https \ + software-properties-common + wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" + apt_install code + + # install vs code and git-credential-manager for using devcontainer and development + wget "https://github.com/git-ecosystem/git-credential-manager/releases/download/v2.3.2/gcm-linux_amd64.2.3.2.deb" -O /tmp/gcmcore.deb + sudo dpkg -i /tmp/gcmcore.deb + git-credential-manager configure + + echo "net.core.rmem_max=26214400" | sudo tee /etc/sysctl.d/10-udp-buffer-sizes.conf + echo "net.core.rmem_default=26214400" | sudo tee -a /etc/sysctl.d/10-udp-buffer-sizes.conf + + echo "Installing extras..." + apt_update + apt_install chrome-gnome-shell + + cd /tmp + wget -c https://downloads.vivaldi.com/stable/vivaldi-stable_6.6.3271.45-1_amd64.deb + sudo dpkg -i vivaldi-stable*.deb + cd $DOTFILES_DIR + + curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg + echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/amd64 stable main' | sudo tee /etc/apt/sources.list.d/1password.list + sudo mkdir -p /etc/debsig/policies/AC2D62742012EA22/ + curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol | sudo tee /etc/debsig/policies/AC2D62742012EA22/1password.pol + sudo mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22 + curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg + + apt_update + apt_install 1password + + # add 1password support to vivaldi + sudo mkdir -p /etc/1password + echo "vivaldi-bin" | sudo tee /etc/1password/custom_allowed_browsers + sudo chown root:root /etc/1password/custom_allowed_browsers + sudo chmod 755 /etc/1password/custom_allowed_browsers + + # install signal desktop + snap_install signal-desktop + + return 0 +} + +function tudelft(){ + snap_install teams-for-linux + + wget -O- https://app.eduvpn.org/linux/v4/deb/app+linux@eduvpn.org.asc | gpg --dearmor | sudo tee /usr/share/keyrings/eduvpn-v4.gpg >/dev/null + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/eduvpn-v4.gpg] https://app.eduvpn.org/linux/v4/deb/ jammy main" | sudo tee /etc/apt/sources.list.d/eduvpn-v4.list + apt_update + apt_install eduvpn-client + + return 0 +} + +# install latex +function LaTeX(){ + cd /tmp + wget https://github.com/scottkosty/install-tl-ubuntu/raw/master/install-tl-ubuntu + sudo chmod +x install-tl-ubuntu + sudo ./install-tl-ubuntu + + PATH=/usr/local/texlive/20*/bin/x86_64-linux:$PATH + tlmgr install arara + + cd $DOTFILES_DIR + + return 0 +} + +########################## Computer Specific #################################### +function latitude_7440(){ + # install driver for fingerprint scanner, enable it, and enroll left and right + # index fingers + wget "http://dell.archive.canonical.com/updates/pool/public/libf/libfprint-2-tod1-broadcom/libfprint-2-tod1-broadcom_5.12.018-0ubuntu1~22.04.01_amd64.deb" -O /tmp/broadcom-fingerprint.deb + sudo install libfprint-2-tod1 fprintd libpam-frintd + sudo dpkg -i /tmp/broadcom-fingerprint.deb + sudo fprintd-enroll -f left-index-finger + sudo fprintd-enroll -f right-index-finger + sudo pam-auth-update --enable fprintd + + # fix keyboard function keys + sudo apt-get reinstall -y libgdk-pixbuf2.0-0 + echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode + echo "options hid_apple fnmode=0" | sudo tee -a /etc/modprobe.d/hid_apple.conf + sudo update-initramfs -u +} + +######################## remove things I never use ############################# +function crapware(){ + echo "Removing crapware..." + pkgs="thunderbird transmission-gtk" + for pkg in $(echo $pkgs); do + echo "Removing $pkgsToRemove" + sudo apt-get --yes --purge remove $pkg || true + done + + return 0 +} + +########################## update and upgrade ################################## +function update_sys(){ + echo "Updating system..." + apt_update + sudo apt-get -y upgrade + + return 0 +} + +############################## annoyances ###################################### +function sudo_rules(){ + echo "Setting sudo rules..." + sudo_rule /sbin/shutdown + sudo_rule /sbin/reboot + + return 0 +} + +for choice in $choices +do + case $choice in + 1) + sym_links + base_sys + crapware + update_sys + sudo apt-get -y autoremove + sudo_rules + [ $CI ] && exit + run_me + ;; + 2) + sym_links + run_me + ;; + 3) + base_sys + run_me + ;; + 4) + tudelft + run_me + ;; + 5) + latitude_7440 + run_me + ;; + 6) + LaTeX + run_me + ;; + 7) + crapware + run_me + ;; + 8) + update_sys + run_me + ;; + 9) + sudo_rules + run_me + ;; + esac +done diff --git a/scripts/nas.sh b/scripts/nas.sh new file mode 100755 index 0000000..a81441a --- /dev/null +++ b/scripts/nas.sh @@ -0,0 +1,64 @@ +#!/bin/bash +SYSTEM="NAS" +DOTFILES_DIR=$(pwd) + +source utils.sh + +print_details + +function stow(){ + for f in $1/*; do + ln -sf $f $2/$(echo $(basename $f) | sed -r 's/dot-/./') + done + + return 0 +} + +# redefine symlinks to use the nas stow +function sym_links(){ + mkdir -p $HOME/.config + stow $DOTFILES_DIR/my-home $HOME/ + stow $DOTFILES_DIR/private/.ssh $HOME/.ssh + stow $DOTFILES_DIR/config $HOME/.config +} + +sudo busybox --install /opt/bin/ + +sudo opkg install \ + autoconf \ + findutils \ + gawk \ + gcc \ + git \ + git-http \ + go \ + grep \ + htop \ + make \ + neovim \ + python3 \ + python3-pip \ + rename \ + tmux \ + tree \ + vim-full \ + zsh + +# the /tmp on my nas only has 64mb of space +mkdir -p /share/Public/tmp +sudo mount /share/Public/tmp /tmp + +git submodule init +git submodule update + +sym_links + +zsh_extras + +fzf_install + +starship_install + +lunarvim_install + +sudo umount /share/Public/tmp && sudo rm -rf /share/Public/tmp diff --git a/scripts/phone.sh b/scripts/phone.sh new file mode 100755 index 0000000..4ec67ad --- /dev/null +++ b/scripts/phone.sh @@ -0,0 +1,38 @@ +#!/bin/bash +SYSTEM="NAS" +DOTFILES_DIR=$(pwd) + +source utils.sh + +print_details + +pkg install -y \ + fzf \ + getconf \ + openssh \ + python-pip \ + rsync \ + stow \ + termux-api \ + termux-tools \ + neovim \ + which make \ + zsh + +pip install pygments + +chsh -s zsh + +git submodule init +git submodule update + +sym_links + +zsh_extras + +starship_install + +lunarvim_install + +yes | pkg remove nano + diff --git a/scripts/utils.sh b/scripts/utils.sh new file mode 100644 index 0000000..0e5b11c --- /dev/null +++ b/scripts/utils.sh @@ -0,0 +1,131 @@ +OS=$(uname -o) +KERNEL=$(uname -s) +KERNEL_VERSION=$(uname -v) +HOST_NAME=$(uname -n) + +# print the current system details +# this expects DOTFILES_DIR and SYSTEM to be defined +function print_details(){ + echo \ +" +SYSTEAM: $SYSTEM +OS: $OS +KERNEL: $KERNEL +KERNEL_VERSION: $KERNEL_VERSION +HOST_NAME: $HOST +DOTFILES_DIR: $DOTFILES_DIR +" +} + +# function to create my links +# This expects the variable $DOTFILES_DIR to exist +function sym_links(){ + mkdir -p $HOME/.config + stow -v --dotfiles --adopt --dir $DOTFILES_DIR --target $HOME --restow my-home + stow -v --adopt --dir $DOTFILES_DIR/private/ --target $HOME/.ssh --restow .ssh + stow -v --adopt --dir $DOTFILES_DIR --target $HOME/.config/ --restow config + # if the adopt made a local change then undo that + git checkout HEAD -- config my-home private + + return 0 +} + +function ask(){ + read -p "$1 [$2] " answer + answer="${answer:-$2}" + case "$answer" in + y|Y ) return 0;; + n|N ) return 1;; + * ) ask "$1" "$2";; + esac +} + +############################### Ubuntu specifics ######################################### +function no_ppa_exists(){ + ppa_added=`grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/* | grep -v list.save | grep -v deb-src | grep deb | grep $1 | wc -l` + [ $ppa_added == 0 ]; +} + +function add_ppa(){ + sudo add-apt-repository ppa:$1 -y + apt_update + + return 0 +} + +function apt_update(){ + sudo apt-get update 1>/dev/null +} + +function apt_install(){ + sudo apt-get install -y $@ + + return 0 +} + +function pip3_install(){ + sudo -H pip3 install $@ + + return 0 +} + +function snap_install(){ + sudo snap install $@ + + return 0 +} + +function sudo_rule(){ + echo "$USER ALL = NOPASSWD: $@" | sudo tee -a /etc/sudoers + + return 0 +} + +############################ manual install items ######################################## + +function fzf_install(){ + # setup fzf + mkdir -p $HOME/.local/bin + git clone --depth 1 https://github.com/junegunn/fzf.git $HOME/.fzf + ./$HOME/.fzf/install --bin + cp $HOME/fzf/bin* $HOME/.local/bin/ +} + +function lazygit_install(){ + # install lazygit + LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | \grep -Po '"tag_name": "v\K[^"]*') + cd /tmp + curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" + tar xf lazygit.tar.gz lazygit + install lazygit $HOME/.local/bin + cd - +} + +function lunarvim_install(){ + # install lunarvim + curl -sSL https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh | LV_BRANCH='release-1.3/neovim-0.9' bash -s -- -y +} + +# setup starship +function starship_install(){ + curl -sS https://starship.rs/install.sh -o starship.sh + chmod +x starship.sh + ./starship.sh -y --bin-dir $HOME/.local/bin + rm -f starship.sh +} + +function zsh_extras(){ + # install zgenom + [ ! -d $HOME/.zgenom ] && git clone https://github.com/jandamm/zgenom.git ${HOME}/.zgenom + + # install zoxide + curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash + + # install fonts + mkdir -p $HOME/.local/bin + curl -fsSL https://raw.githubusercontent.com/getnf/getnf/main/install.sh | bash + $HOME/.local/bin/getnf -i DejaVuSansMono,DroidSansMono,Hack,Recursive,RobotoMono + + # install lunar vim + curl -sSL https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh | LV_BRANCH='release-1.3/neovim-0.9' bash -s -- -y +}