diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..12a5515 --- /dev/null +++ b/start.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +# this script will +# - disable root ssh +# - disable password ssh +# - create a new user with sudo +# - give them ssh from root (OR override with creds in current dir) +# - install: +# - go +# - zsh +# - ohmyzsh (+theme +config +plugins) +# - nvim (+nvchad +my nvchad config) + +read -p "Enter a username: " user +read -p "Enter a password: " pw + +# disable root and password ssh +echo "Configuring SSH..." +sed -i "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config +sed -i "s/PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config +systemctl restart ssh +# remove root password +echo "Removing root password..." +passwd -dl root > /dev/null + +# if user doesn't exist, make them and make their .ssh folder +id -u marcy > /dev/null +if [ $? -eq 1 ]; then + echo "Adding user $user..." + useradd -s /bin/bash -d /home/$user/ -m -G sudo $user + echo $user:$pw | chpasswd + mkdir /home/$user/.ssh +else + echo "User $user already exists! Continuing..." +fi + +echo "Installing SSH keys..." +# get authorized_keys from root OR prompt user to paste it in +if [ -f /root/.ssh/authorized_keys ]; then + # install root authorized keys + echo "Installing authorized_keys from root..." + cp /root/.ssh/authorized_keys /home/$user/.ssh/authorized_keys +else + # install ssh creds from input + echo "No authorized_keys found in root. Enter your public key, followed by an exclamation point (!):" + read -d '!' authkeys + touch /home/$user/.ssh/authorized_keys + echo "$authkeys" > /home/$user/.ssh/authorized_keys +fi + +# get id_rsa from root OR prompt user to paste private key in +if [ -f /root/.ssh/id_rsa ]; then + # install current dir ssh creds + echo "Installing id_rsa from root..." + cp /root/.ssh/id_rsa /home/$user/.ssh/id_rsa +else + # install ssh creds from input + echo "No id_rsa found in root. Enter your id_rsa key, followed by an exclamation point (!):" + read -d '!' idrsa + touch /home/$user/.ssh/id_rsa + echo "$idrsa" > /home/$user/.ssh/id_rsa +fi + +# give ssh creds correct perms + ownership +chmod 0700 /home/$user/.ssh +chmod 0600 /home/$user/.ssh/authorized_keys +chmod 0600 /home/$user/.ssh/id_rsa +chown $user /home/$user/.ssh +chown $user /home/$user/.ssh/authorized_keys +chown $user /home/$user/.ssh/id_rsa + +# install packages + update apt +echo "Updating and installing packages..." +# apt update -y && apt upgrade -y +pacman -Syu +pacman -S zsh gcc zip unzip ripgrep fd-find git -y + +# make zsh default shell +chsh -s $(which zsh) $user + +### run all subsequent commands as $user +# for some reason this specific command breaks if its in the block after 'su #user <> ~/.zsh/headline.zsh-theme +echo "Installing zsh config..." +curl -fsSL "https://gist.githubusercontent.com/mnrva-dev/8c82409e041c59145d27d02939d50d19/raw/a01cfb09fe31a36b56ecbf1211862a29e1db276d/gistfile1.txt" >> ~/.zshrc +echo "Installing zsh plugins..." +git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions +git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting +git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete + +# install nvim + nvchad + configure nvchad +echo "Installing nVim..." +wget https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz +tar xzvf nvim-linux64.tar.gz + +echo "Configuring NVChad..." +git clone https://github.com/NvChad/starter ~/.config/nvim +rm -rf ~/.config/nvim/.git +rm -rf ~/.config/nvim/lua/custom +git clone git@github.com:gabehf/nvchad-custom.git ~/.config/nvim/lua/custom +EOF + +echo "Done!" diff --git a/update-go.sh b/update-go.sh new file mode 100755 index 0000000..17d0c49 --- /dev/null +++ b/update-go.sh @@ -0,0 +1,18 @@ +#!/bin/bash +if [ "$EUID" -ne 0 ]; then + echo "please run as root!" + exit 1 +fi +if [ -z "$1" ]; then + echo "specify a go version to update to" + exit 1 +fi +echo "Downloading new Go version..." +wget -P /home/marcy/ "https://go.dev/dl/go$1.linux-amd64.tar.gz" +echo "Removing current Go installation..." +rm -rf /usr/local/go +echo "Installing new Go version..." +tar -C /usr/local -xzf "/home/marcy/go$1.linux-amd64.tar.gz" +echo "Cleaning up..." +rm "/home/marcy/go$1.linux-amd64.tar.gz" +echo "Done!"