Skip to content

Instantly share code, notes, and snippets.

View Diablo2050's full-sized avatar

Amr Rashad Diablo2050

  • CloudSource @cloudsrc
  • Amsterdam, Netherlands
View GitHub Profile
@Diablo2050
Diablo2050 / s3-recover-folder
Created February 17, 2021 07:49
S3 recover deleted folders with versioning enabled.
#!/bin/bash
# if you have profiles other than default unhash the below line and profide the profile name
#export AWS_PROFILE=NAME
recoverfiles=$(aws s3api list-object-versions --bucket BUCKET_NAME --prefix FOLDER_NAME/ --query "DeleteMarkers[?IsLatest && starts_with(LastModified,'2021-02-16')].{Key:Key,VersionId:VersionId}")
for row in $(echo "${recoverfiles}" | jq -c '.[]'); do
key=$(echo "${row}" | jq -r '.Key' )
# versionId=$(echo "${row}" | jq -r '.VersionId' )
aws s3api delete-object --bucket inno-themes-prod --key $key --version-id null
done
@Diablo2050
Diablo2050 / essentials.md
Created February 8, 2021 17:05
terminal-essentials

1- System Information


When we are dropped in a terminal of a server we will need to gather basic information on the system using the below commands:

1- How to know the which OS we are in ?

cat /etc/os-release

2- How to know which kernel we are using ?

@Diablo2050
Diablo2050 / cloudflare-ddns-update.sh
Created August 24, 2020 13:53 — forked from Tras2/cloudflare-ddns-update.sh
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
#!/bin/bash
cores=$(lscpu | egrep "^CPU\(s\)")
cpu_model=$(grep "model name" /proc/cpuinfo | uniq)
ram=$(free -g | grep Mem | awk '{ print $2 }')
red="\e[91m"
norm="\e[0m"
echo -e "$red
CPU INFO:\n $norm
$cores
$cpu_model