Last active
June 26, 2023 06:22
-
-
Save MvRens/c1d6fc7f81f109847c0cb79841d11113 to your computer and use it in GitHub Desktop.
Debian server basic setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Make sure you review the contents of this file and all linked URLs before executing! | |
# | |
# To run: | |
# bash <(wget -qO - https://gist.githubusercontent.com/MvRens/c1d6fc7f81f109847c0cb79841d11113/raw/serversetup.sh) | |
# | |
# To skip certain steps: | |
# bash <(wget -qO - https://gist.githubusercontent.com/MvRens/c1d6fc7f81f109847c0cb79841d11113/raw/serversetup.sh) -s noupdate | |
# bash <(wget -qO - https://gist.githubusercontent.com/MvRens/c1d6fc7f81f109847c0cb79841d11113/raw/serversetup.sh) -s noupdate noinstall | |
# | |
# Parameters: | |
# noupdate Skip apt update and upgrade | |
# noinstall Skip installing utilitites | |
# noconfigtmux Skip configuring TMux and adding it to .bashrc | |
# noconfignano Skip configuring Nano | |
# noconfigvim Skip configuring Vim | |
# | |
if [ "$EUID" = 0 ]; then | |
echo "Please do not run this script as root. It will call sudo when appropriate." | |
exit 1 | |
fi | |
options=$* | |
start_step() { | |
if [[ $options == *"no$1"* ]]; then | |
echo -e "\033[1;31mSkipped: $2\033[0m" | |
return 1 | |
else | |
echo -e "\033[1;34m$2...\033[0m" | |
return 0 | |
fi | |
} | |
info() { | |
echo -e "\033[1;37m$1\033[0m" | |
} | |
warning() { | |
echo -e "\033[1;31m$1\033[0m" | |
} | |
if start_step "update" "Updating system"; then | |
sudo apt update | |
sudo apt upgrade -y | |
fi | |
if start_step "install" "Installing utilities (TMux, HTop and Vim Full)"; then | |
sudo apt install -y tmux htop vim | |
fi | |
if start_step "configtmux" "Configuring TMux"; then | |
if [ -f ~/.tmux.conf ]; then | |
warning "~/.tmux.conf already exists, not overwriting" | |
info "To overwrite: wget https://gist.github.com/MvRens/f1e809773b8fa160d86afe015fb78735/raw/.tmux.conf -qO ~/.tmux.conf" | |
else | |
wget https://gist.github.com/MvRens/f1e809773b8fa160d86afe015fb78735/raw/.tmux.conf -qO ~/.tmux.conf | |
fi | |
if grep -q "# Auto-attach tmux" ~/.bashrc; then | |
warning "~/.bashrc already contains tmux auto-attach, keeping existing" | |
else | |
wget https://gist.githubusercontent.com/MvRens/713f431f198cf144a89f9f697a5380e3/raw/.bashrc -qO ->> ~/.bashrc | |
fi | |
echo "DIR 01;36" > ~/.dircolor | |
# TODO change cwd color in .bashrc from 34 (dark blue) to 36 (cyan) | |
fi | |
if start_step "confignano" "Configuring Nano"; then | |
sudo sed -i -e 's/# set tabsize 8/set tabsize 4/g' /etc/nanorc | |
fi | |
if start_step "configvim" "Configuring Vim"; then | |
if [ -f ~/.vimrc ]; then | |
warning "~/.vimrc already exists, not overwriting" | |
info "To overwrite: wget https://gist.githubusercontent.com/MvRens/b75223a23e657700dd4f59ab765d4faa/raw/.vimrc -qO ~/.vimrc" | |
else | |
wget https://gist.githubusercontent.com/MvRens/b75223a23e657700dd4f59ab765d4faa/raw/.vimrc -qO ~/.vimrc | |
fi | |
VIMUSRSHARE=$(find /usr/share/vim/ -maxdepth 1 ! -path /usr/share/vim/ -type d -name 'vim*') | |
sudo wget https://raw.githubusercontent.com/MvRens/molokai/master/colors/molokai.vim -qO $VIMUSRSHARE/colors/molokai.vim | |
sudo ln -s ~/.vimrc /root/.vimrc | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment