Created
March 13, 2025 08:06
-
-
Save Kristjan-Reinsberg/2a85193ee22d616cacd2674d50c14342 to your computer and use it in GitHub Desktop.
.bash_aliases (ssh connections and useful list)
This file contains hidden or 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
| # DEPENDS: .bashrc must include this file | |
| # LOAD CHANGES MANUALLY: source ~/.bash_aliases OR ~/.bash_aliases | |
| # LIST ALL ALIASES: alias | |
| #INFO MESSAGE | |
| echo -e "\e[1;34m.bash aliases LOADED" | |
| # VARIABLES | |
| export eis_user='firstname.lastname' | |
| export info_color='\e[1;34mINFO: ' | |
| # HELPERS | |
| alias c='clear' | |
| # CONNECTING TO PROJECTS | |
| # project1_com live | |
| # project2_com (no parameter === stage) | |
| #################### | |
| ### SSH PROJECTS ### | |
| #################### | |
| project1_com(){ | |
| local url="https://project.com" | |
| local ip="195.66.777.888" | |
| local dir="/var/www/" | |
| local env=$1 | |
| if [ "$env" == "live" ]; then | |
| echo -e "$info_color $url" | |
| ssh "$eis_user"@"$ip" "cd '$dir' && ls" | |
| else | |
| echo -e "$info_color $url:3334" | |
| ssh "$eis_user"@"$ip" -p 3332 "cd '$dir' && ls" | |
| fi | |
| } | |
| project2_com(){ | |
| local url="https://project2.ee" | |
| local login="/haldus" | |
| local ip="195.44.55.666" | |
| local dir="/var/www/" | |
| local env=$1 | |
| if [ "$env" == "live" ]; then | |
| echo -e "$info_color $url" | |
| echo -e "$info_color $url$login" | |
| ssh -t "$eis_user@$ip" "cd $dir && ls" | |
| else | |
| echo -e "$info_color $url:3334" | |
| echo -e "$info_color $url:3334$login" | |
| ssh -t "$eis_user@$ip" -p 3332 "cd $dir && ls" | |
| fi | |
| } | |
| #### SHOW USEFUL COMMANDS #### | |
| useful() { | |
| declare -a mysql_docker=("mysqldump -u user -p pass > export.sql (EXPORT)" "docker exec -it your_container_name bash (IMPORT 1/2)" "-u wp_user -p && source export.sql (IMPORT 2/2 docker db root folder)") | |
| declare -a apache_rights=("groups firstname.lastname" "sudo usermod -aG developers firstname.lastname" "sudo usermod -aG www-data firstname.lastname") | |
| declare -a apache_files=("zip -r -0 files.zip 2023 2024 2025" ) | |
| declare -a php=("update-alternatives --config php") | |
| #declare -a category_name=("" "" "") | |
| declare -A command_categories | |
| command_categories["MYSQL-DOCKER"]="mysql_docker" | |
| command_categories["APACHE-RIGHTS"]="apache_rights" | |
| command_categories["APACHE-FILES"]="apache_files" | |
| command_categories["APACHE"]="php" | |
| for category in "${!command_categories[@]}"; do | |
| echo -e "\e[1;33m$category:\e[0m" # Yellow | |
| # Get the array name dynamically and loop through the array | |
| array_name="${command_categories[$category]}" | |
| # Indirectly reference the array using eval | |
| eval "commands=(\"\${$array_name[@]}\")" | |
| for command in "${commands[@]}"; do | |
| echo " - $command" | |
| done | |
| echo | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment