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
#!/bin/bash | |
# Enable extended globbing for the +(...) pattern | |
shopt -s extglob | |
## Variable Declartions ## | |
OUTPUT="text" # set output format | |
## FUNCTIONS ## | |
# apply Instance DB deletion protection |
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
#!/bin/bash | |
# Set variables for tags, region, SSH key location & user | |
# Set these 4 to appropriate values | |
REGION="eu-central-1" | |
TAG="<EC2_TAG>" | |
SSH="~/.ssh/<PATH_TO_FILE>" | |
USER="ubuntu" | |
# Check AWS credentials exist |
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
#!/bin/bash | |
region="eu-west-1" | |
cluster="<CLUSTER_NAME>" | |
## Get Task names from Cluster | |
task_status () { | |
echo "Task Name and Status:" | |
mapfile -t tasksInCluster < <(aws ecs list-tasks --region $region --cluster $cluster | jq -r '.taskArns[]') | |
for task in "${tasksInCluster[@]}"; do | |
aws ecs describe-tasks --region $region --cluster $cluster --tasks $task | jq -r '.tasks[].containers[] | .name + " " + .lastStatus' |
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
ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" user@host |
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
find -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \; |
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
#!/bin/bash | |
# Set variables for tags, region, SSH key location & user | |
# Set these 4 to appropriate values | |
REGION="eu-central-1" | |
TAG="chris-sandbox" | |
SSH="~/.ssh/frankfurt.pem" | |
USER="ubuntu" | |
# Check AWS credentials exist |
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
#!/bin/bash | |
# error handling | |
error_handler() { | |
echo "Error occurred in script at line: ${1}" | |
echo "Line exited with status: ${2}" | |
} | |
trap 'error_handler ${LINENO} $?' ERR |
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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
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
#!/bin/bash | |
# error handling | |
error_handler() { | |
echo "Error occurred in script at line: ${1}" | |
echo "Line exited with status: ${2}" | |
} | |
trap 'error_handler ${LINENO} $?' ERR |
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
package_to_install () { | |
# enter the package you want installed in PKG_NAME below | |
PKG_NAME="<PACKAGE_NAME>" | |
if ! type $PKG_NAME > /dev/null 2>&1; then | |
# check Linux package manager (yum or apt) | |
declare -A osInfo; | |
osInfo[/etc/redhat-release]=yum | |
osInfo[/etc/arch-release]=pacman | |
osInfo[/etc/gentoo-release]=emerge | |
osInfo[/etc/SuSE-release]=zypp |
NewerOlder