Created
December 13, 2021 17:05
-
-
Save MrMoshkovitz/1b1c25758307e0ff8a31d79cd90f5963 to your computer and use it in GitHub Desktop.
Virtual Machine Initilizing
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 -v | |
# set -x | |
# trap 'read -p "run: $BASH_COMMAND"' DEBUG | |
# Update SSH Port to 2220 | |
# ============================= | |
sudo echo 'Port 2220' >> /etc/ssh/sshd_config; sudo systemctl restart sshd | |
# Python3.8 Install | |
# ============================= | |
sudo apt update -y && sudo apt dist-upgrade -y | |
sudo apt install -y unzip curl | |
sudo apt install -y python3.8 | |
sudo python3.8 -m pip install --upgrade pip | |
sudo apt install -y python3.8-venv | |
sudo apt update -y | |
# Docker Install | |
# ============================= | |
sudo apt remove -y docker docker-engine docker.io | |
sudo apt install -y docker.io | |
sudo systemctl start docker | |
sudo systemctl enable docker | |
sudo echo "$(docker --version)" | |
# Docker Post Install | |
# ============================= | |
sudo groupadd docker > /dev/null 2>&1 | |
sudo usermod -aG docker $USER | |
# newgrp docker > /dev/null 2>&1 # Possibility Not Must - #! Stuck The Code | |
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R #! if Needed | |
sudo chmod g+rwx "/home/$USER/.docker" -R #! if Needed | |
sudo systemctl enable docker.service | |
sudo apt update -y | |
# Terraform Install | |
# ============================= | |
sudo apt update -y && sudo apt dist-upgrade -y | |
sudo apt autoremove -y | |
sudo apt install -y gnupg software-properties-common curl | |
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - | |
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | |
sudo apt update -y && sudo apt install -y terraform | |
touch ~/.bashrc | |
terraform -install-autocomplete | |
# AZ CLI Install | |
# ============================= | |
sudo apt update -y && sudo apt dist-upgrade -y | |
sudo apt autoremove -y | |
sudo apt install -y ca-certificates curl apt-transport-https lsb-release gnupg | |
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null | |
AZ_REPO=$(lsb_release -cs) | |
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list | |
sudo apt update -y | |
sudo apt install -y azure-cli | |
# AWS CLI Install | |
# ============================= | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install | |
# GCP CLI Install | |
# ============================= | |
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list | |
sudo apt install -y apt-transport-https ca-certificates gnupg | |
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - | |
sudo apt update -y && sudo apt install -y google-cloud-sdk | |
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && apt-get update -y && apt-get install google-cloud-sdk -y | |
# BASH CLI Installs | |
# ===================================== | |
sudo apt install colordiff -y | |
# export Colors | |
# ===================================== | |
export RED="\033[0;91m" | |
export GREEN="\033[0;92m" | |
export BLUE="\033[0;34m" | |
export CYAN="\033[0;36m" | |
export YELLOW="\033[0;93m" | |
export NC="\033[0m" | |
# Bash TimeSaver | |
# ================================ | |
# ================================ | |
sudo echo ''' | |
if [ -e ~/.bash_aliases ]; then | |
. ~/.bash_aliases | |
fi | |
if [ -e ~/.bash_functions ]; then | |
. ~/.bash_functions | |
fi | |
''' >> ~/.bashrc | |
# Bash Aliases | |
# ================================ | |
# ================================ | |
# Aliases | |
sudo echo ''' | |
# Network | |
# ================================= | |
# Get My IP | |
alias ippublic="curl ipinfo.io/ip" | |
alias ipprivate="ipconfig getifaddr en0" | |
alias ports="netstat -tulanp" | |
alias ping5="ping -c 5" | |
# OS | |
# =================================== | |
# Update Ubuntu | |
alias update="sudo apt update -y " | |
alias update-full="sudo apt update -y && sudo apt upgrae -y && sudo apt-dist upgrade -y" | |
# Terminal | |
# ======================================== | |
# Clear Terminal Screen | |
alias c="clear" | |
# Bash RC Updates | |
alias brc="source ~/.bashrc" | |
# CD Aliases | |
alias ..="cd .." | |
alias ...="cd ../../" | |
alias ....="cd ../../../" | |
alias .....="cd ../../../../" | |
alias ~="cd ~" | |
# Terminal Outputs | |
# =================================== | |
# Color Grep Output | |
alias grep="grep --color=auto" | |
# Find a command in your grep history | |
alias gh="history | grep $1" | |
# History | |
alias h="history" | |
# Jobs | |
alias j="jobs" | |
#COLORS | |
#======================== | |
alias RED="\033[0;91m" | |
alias GREEN="\033[0;92m" | |
alias BLUE="\033[0;34m" | |
alias CYAN="\033[0;36m" | |
alias YELLOW="\033[0;93m" | |
alias NC="\033[0m" | |
# Time | |
#======================== | |
alias nowtime="date +%T" | |
alias nowdate="date +%D" | |
alias now="date \"+%D %T\"" | |
# Sorting | |
# ================================================= | |
# Sort By File Size | |
alias lsize="ls --human-readable --size -1 -S --classify" | |
# Sort Bt Modification Time | |
alias ltime="ls -t -1" | |
# Directory and Files | |
# ================================================= | |
# Count Files in a Folder | |
alias count="find . -type f | wc -l" | |
# Force Remove | |
alias rmf="rm -rf" | |
# Recursive Copy | |
alias cpr="cp -r" | |
alias rm="rm -i" | |
alias cp="cp -i" | |
alias mv="mv -i" | |
# Show Only Hidden Files | |
alias l.="ls -d .* --color=auto" | |
# Colored Difference Between Files | |
alias diff="colordiff" | |
# System | |
# ============================== | |
# reboot / halt / poweroff | |
alias reboot="sudo /sbin/reboot" | |
alias poweroff="sudo /sbin/poweroff" | |
alias halt="sudo /sbin/halt" | |
alias shutdown="sudo /sbin/shutdown" | |
# Python | |
# ================================================= | |
# Venv | |
alias venv-create="python3.8 -m venv .venv" | |
alias venv-activate="source .venv/bin/activate" | |
# New Python Server | |
alias www="python3 -m http.server $1" | |
# Git | |
# ================================================= | |
alias gpull="git pull" | |
alias gpush="git push" | |
# Web | |
# ============================= | |
# Download In Background | |
alias wget="wget -c " | |
# Generate New Path | |
alias getpass="openssl rand -base64 $1" | |
''' > ~/.bash_aliases | |
# exec bash | |
# Bash Functions | |
# ================================================= | |
# ================================================= | |
sudo echo ''' | |
# Directory and Files | |
# ================================================= | |
# Create Folder than CD In To It | |
mkcd () | |
{ | |
mkdir -p -- "$1" && cd -P -- "$1" | |
} | |
# Lazy Git | |
# ================================================= | |
function lazygit() { | |
git add . | |
git commit -a -m "$1" | |
git push | |
} | |
# Colored Time | |
# ================================================= | |
colorTime () { | |
printf "\n\t${GREEN} $(nowdate) ${YELLOW} $(nowtime) ${NC}\n\n" | |
} | |
# Extract Files | |
# =============================================== | |
extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xvjf $1 ;; | |
*.tar.gz) tar xvzf $1 ;; | |
*.tar.xz) tar Jxvf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) unrar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xvf $1 ;; | |
*.tbz2) tar xvjf $1 ;; | |
*.tgz) tar xvzf $1 ;; | |
*.zip) unzip $1 ;; | |
*.Z) uncompress $1 ;; | |
*.7z) 7z x $1 ;; | |
*) echo "dont know how to extract $1..." ;; | |
esac | |
else | |
echo "$1 is not a valid file!" | |
fi | |
} | |
''' > ~/.bash_functions | |
exec bash | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment