Skip to content

Instantly share code, notes, and snippets.

View ddepaoli3's full-sized avatar
🌶️
automation in progress

Daniel Depaoli ddepaoli3

🌶️
automation in progress
View GitHub Profile
@ddepaoli3
ddepaoli3 / generate_sso_profile.sh
Last active June 27, 2023 07:36
Generate AWS config file with all accounts in a AWS Organization
#!/bin/bash
SSO_START_URL=
SSO_ACCOUNT_ID=
SSO_ROLE_NAME=
cp ~/.aws/config ~/.aws/config.bak.`date +%F`
cat << EOF > ~/.aws/config
[profile root]
@ddepaoli3
ddepaoli3 / retropie-shutdown-and-switch-to-x11.py
Last active August 2, 2021 12:19
retropie-shutdown-and-switch-to-x11.py
#!/usr/bin/env python
# Initial script from:
# https://retropie.org.uk/forum/topic/13141/gpio-button-to-exit-emulator/3
import RPi.GPIO as GPIO
import time
import subprocess
#https://github.com/crcerror/ES-generic-shutdown script location
@ddepaoli3
ddepaoli3 / lista-ricette-giallo-zafferano.md
Last active October 30, 2023 11:42
Lista di ricette GialloZafferano con link
@ddepaoli3
ddepaoli3 / bash-cli-openssl-stdin-encryption
Last active February 9, 2021 14:24 — forked from robert2d/bash-cli-openssl-stdin-encryption
Bash $STDIN Encryption with openssl and aes256
# Encrypt in base64 output STDIN and provide a password(prompt)
echo "message" | openssl enc -base64 -aes-256-cbc -a
# Decrypt STDIN and provide a password(prompt)
echo "encrypted" | openssl enc -aes-256-cbc -a -d
@ddepaoli3
ddepaoli3 / setup_aws_credentials.sh
Last active January 26, 2021 11:29
AWS STS export environment variables
function setup_aws_credentials() {
profile_name=$1
role_arn=`/usr/bin/grep -A4 "$profile_name\]" ~/.aws/credentials|/usr/bin/grep role_arn|sed 's/^.*arn:/arn:/g'`
if [[ -z "$role_arn" ]]
then
role_arn=`/usr/bin/grep -A4 "$profile_name\]" ~/.aws/config|/usr/bin/grep role_arn|sed 's/^.*arn:/arn:/g'`
fi
local stscredentials
@ddepaoli3
ddepaoli3 / send_message_to_telegram.sh
Last active December 10, 2019 12:55
Send message to telegram with curl
#!/bin/bash
#HOW TO USE SCRIPT:
# curl https://gist.githubusercontent.com/ddepaoli3/495bb416217c97f9c1da1e5c7d84752a/raw/549b7aaad6529379297f62682f10887a725bde41/send_message_to_telegram.sh | bash /dev/stdin '<message>' '<chat_id>' '<chat_token>'
#
MESSAGE=$1
CHAT_ID=$2
TOKEN=$3
@ddepaoli3
ddepaoli3 / amazon-cloudwatch-agent.json
Created September 4, 2019 10:10
AWS cloudwatch agent settings with all available metrics for linux system
{
"metrics": {
"namespace": "CWAgent",
"append_dimensions": {
"InstanceId": "${aws:InstanceId}",
"AutoScalingGroupName": "${aws:AutoScalingGroupName}"
},
"aggregation_dimensions": [
[
"InstanceId"
@ddepaoli3
ddepaoli3 / send_sms.sh
Created June 18, 2019 13:22
Send SMS using aws sns
#!/bin/bash
# ./send_sms.sh +3934091929 "ciao ciao" "profile-name"
#Comand to set the default sender Name, i.e. the name you see in sms in the field 'from'
#aws --profile aws-profile sns set-sms-attributes --attributes DefaultSenderID=SenderName
NUMBER=$1
MESSAGE=$2
PROFILE=$3
@ddepaoli3
ddepaoli3 / hackVPN.sh
Created March 12, 2019 10:46
Force all public IP range to be routed trough the default gateway to avoid VPN redirect. All privates IP ranges are not affected
#!/bin/bash
DEFAULT_GW_IP="192.168.1.1" #Local gateway
force_public_route()
{
#netmask -c 0.0.0.0:9.255.255.255
sudo route add -net 0.0.0.0/5 $DEFAULT_GW_IP
sudo route add -net 8.0.0.0/7 $DEFAULT_GW_IP
@ddepaoli3
ddepaoli3 / userdata-ubuntu-vnc.sh
Created March 11, 2019 19:11
Userdata for Ubuntu for installing desktop environment and VNC server
#!/bin/bash
#Password: passed with argument or autogenerated
autogenpass=`date +%s | sha256sum | base64 | head -c 15 ; echo`
password=${1:-$autogenpass}
mkdir /root/.vnc
sudo apt-get update
sudo apt-get install --yes git ansible