Skip to content

Instantly share code, notes, and snippets.

@hizkifw
Last active September 23, 2020 15:40
Show Gist options
  • Save hizkifw/4fea08701b27f08eede9ddb8dd494e4a to your computer and use it in GitHub Desktop.
Save hizkifw/4fea08701b27f08eede9ddb8dd494e4a to your computer and use it in GitHub Desktop.
Auto setup script for fresh Ubuntu installations
#!/bin/bash
USERNAME=hizkifw
# Install packages
apt update
apt upgrade -y
apt install -y axel vim openvpn python3 python3-pip cloudflared cmake build-essential git tmux fail2ban gimp mplayer vlc cmus ffmpeg pv qbittorrent keepassxc chromium-browser xclip
# Install node
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
command -v nvm
nvm install --lts
pip3 install thefuck
fuck --yeah
# Generate SSH key
ssh-keygen -f id_rsa -t rsa -N ''
# .tmux.conf
cd /home/$USERNAME
wget https://gist.githubusercontent.com/HizkiFW/72f9d0506d950f0025ac520448b2a357/raw/faa44cb3148874a1858d51b1aa4c8eb9833f937f/.tmux.conf
# Install vimrc
git clone https://github.com/HizkiFW/dotvim.git
mv dotvim/ .vim/
vim -c ':PlugInstall' -c ':qa'
# Some bash aliases
cat <<EOF | tee /home/$USERNAME/.bash_aliases
alias d='cd ..'
EOF
# DNS settings
# Unlink systemd's resolv.conf and replace with local resolver (cloudflared)
cp /etc/resolv.conf /tmp/resolv.conf
rm /etc/resolv.conf
cat /tmp/resolv.conf | tee /etc/resolv.conf
sed -i 's/53/1/' /etc/resolv.conf
# Useful tools
mkdir -p /home/$USERNAME/bin
# clip-unclip
# stdin -> clipboard -> stdout
cat << EOF | tee /home/$USERNAME/bin/clip
xclip -selection clipboard
EOF
cat <<EOF | tee /home/$USERNAME/bin/unclip
xclip -selection clipboard -o
EOF
# yoink-yeet
# useful for copying files between terminals
cat <<EOF | tee /home/$USERNAME/bin/yoink
#!/bin/bash
realpath "\$@" | tee /tmp/yoink
EOF
cat <<EOF | tee /home/$USERNAME/bin/yeet
#!/bin/bash
if [ -f /tmp/yoink ]; then
if [ \$# -eq 0 ]; then
cp -rv \$(cat /tmp/yoink) .
else
cp -rv \$(cat /tmp/yoink) \$@
fi
else
echo "Source file not found"
fi
EOF
# Update permissions
chmod +x /home/$USERNAME/bin/*
chown -R $USERNAME:$USERNAME /home/$USERNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment