Skip to content

Instantly share code, notes, and snippets.

View mims92's full-sized avatar

Mims mims92

  • Liege
View GitHub Profile
@mims92
mims92 / Odroid-TurnLedOnOff.sh
Last active January 7, 2018 20:23
Odroid XU4 - Bash - Turns the blue LED off/on
# $ led [on|off]
#!/bin/bash
led_path=/sys/class/leds/blue\:heartbeart/trigger
if [ "$1" == "off" ]
then
echo none > ${led_path}
fi
@mims92
mims92 / Linux - Bash - Purge iptables rules
Last active February 19, 2018 14:13
Linux-Empty_iptables.sh
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -L
@mims92
mims92 / update_ip
Created December 20, 2018 09:43
Linux - Bash - Update AWS Route53 DNS with public IP
# Update a DNS record with the public IP
# Use a CRON
# chmod +x update_ip
# Run: source update_ip
#!/bin/bash
current_ip=$CURRENT_IP
new_ip=$(curl -s https://api.ipify.org)
new_ip_validation=$(curl -s https://checkip.amazonaws.com)
@mims92
mims92 / aws
Last active January 4, 2019 14:26
Linux - AWSCLI - aws cli with python3.6
# Requirement
# - https://gist.github.com/mims92/83b911783c2a23377c3f7dc9d1fe38b9
#--------
# Installation
# - Create the exectuable file under your PATH
#--------
# Files are being mounted in /app inside the container
#!/bin/bash
@mims92
mims92 / aws-ec2.sh
Created November 18, 2019 10:26
AWS - Bash - List Instances
#!/bin/bash
#Usage: aws-ec2 <profile name>
aws ec2 describe-instances --profile $1 \
| jq -r '.[][].Instances[] | [ .InstanceId, (.Tags[]|select(.Key=="Name")|.Value), (.NetworkInterfaces[].PrivateIpAddresses[].PrivateIpAddress)]'
@mims92
mims92 / awsaccounts
Created January 3, 2020 08:43
AWS - Bash - List all accounts id and name of the organization
#!/bin/bash
#chmod +x /usr/bin/awsaccounts
#Usage: awsaccounts
aws organizations list-accounts --profile <profile name> | jq -r -e '["ID","", "NAME"], (.Accounts[] | [.Id, .Name] ) | @tsv'
@mims92
mims92 / awsssm
Created January 3, 2020 08:51
AWS - Bash - Start session using SSM Session manager
#!/bin/bash
#chmod +x /usr/bin/awsssm
#Usage: awsssm <instance id> <profile name>
aws ssm start-session --target $1 --profile $2
@mims92
mims92 / awsec2
Last active January 30, 2020 09:42
AWS - Bash - List all EC2 instances
#!/bin/bash
#chmod +x /usr/bin/awsec2
#Usage: awsec2 <profile-name>
aws ec2 describe-instances --profile $1 | jq -r '.[][].Instances[] | [ .InstanceId, (.Tags[]|select(.Key=="Name")|.Value), (.NetworkInterfaces[].PrivateIpAddresses[].PrivateIpAddress)] | select (.!=null) | @tsv' | column -s$'\t' -t'
@mims92
mims92 / Dockerfile
Last active March 25, 2020 16:51
Linux - Docker - python & aws cli
# Requirements
# - Docker
#--------
# Installation
# - docker build -t <your image name> .
#--------
# "root" folder is app
FROM python:3.6-alpine
RUN pip3 install -U awscli
@mims92
mims92 / awsecs
Created July 27, 2020 10:46
AWS - Bash - Get tasks instances
#!/bin/bash
#chmod +x /usr/bin/awsecs
#Usage: awsecs <service-name> <profile name>
#Output: list of ec2 instance id
SERVICE="$1"
shift
PROFILE="$1"
shift