Skip to content

Instantly share code, notes, and snippets.

View omar-yassin's full-sized avatar

Omar Yassin omar-yassin

View GitHub Profile
@omar-yassin
omar-yassin / gist:c698d73d28aeba261be8
Last active February 7, 2024 17:36
AWS EC2 GET WINDOWS PASSWORD + AUTO RDP
#!/bin/bash
#ASSUMES KeyPairs are stored in ~/.ssh
# Also make sure to install jq and have in your path to run below
# JQ: https://stedolan.github.io/jq/
AWS_BIN="/usr/local/bin/aws"
AWS_PROFILE="omar-dev"
KP_DIR="~/.ssh"
@omar-yassin
omar-yassin / gist:06f2436164ad51b6fa0a
Created October 16, 2015 13:21
Powershell Script: retrieve ENV Vars
$script:ComputerName = [Environment]::getenvironmentvariable("COMPUTERNAME")
$script:BootTime = [Environment]::getenvironmentvariable("AWS_BootTime", "Machine")
$script:LaunchTime = [Environment]::getenvironmentvariable("AWS_LaunchTime", "Machine")
$script:DeployTime = [Environment]::getenvironmentvariable("AWS_DeployTime", "Machine")
$script:EnvName = [Environment]::getenvironmentvariable("AWS_EbEnvironmentName", "Machine")
$script:EbAppName = [Environment]::getenvironmentvariable("AWS_EbApplicationName", "Machine")
$script:CDN_STATUS = [Environment]::getenvironmentvariable("CDN_STATUS", "Machine")
@omar-yassin
omar-yassin / gist:413d1a361c0ab9834e8c
Last active October 9, 2015 18:02
Linux: Burn to optical media
#!/bin/bash
# SUDOERS /etc/sudoers.d/lbbackup
# Cmnd_Alias LS_HARDWARE = /usr/bin/lshw
# Cmnd_Alias MOUNT_UDF = /bin/mount -oloop\,rw *
# Cmnd_Alias UNMOUNT_UDF = /bin/umount /data/TEMP_UDF_DIR/MOUNT_UDF
# Cmnd_Alias BURN_UDF = /usr/bin/growisofs
# Cmnd_Alias CHOWN_MOUNT = /bin/chown -R lbbackup\:lbbackup /data/TEMP_UDF_DIR/MOUNT_UDF
# lbbackup ALL=(ALL) NOPASSWD: LS_HARDWARE, MOUNT_UDF, UNMOUNT_UDF, BURN_UDF, CHOWN_MOUNT
@omar-yassin
omar-yassin / gist:2e55fe201a12aecb12a1
Created October 9, 2015 17:57
Riemann custom config
; pardon syntax - clojure newb
; Custom subject
(def email
(mailer
{
:from "[email protected]"
:host "localhost"
:subject (fn [events] (apply str "RIEMANN DETECTION: " (get-in (first events) [:host]) " TRIGGERED [" (get-in (first events) [:service]) " STATE]: " (get-in (first events) [:state])))
}
@omar-yassin
omar-yassin / gist:3d2b1ad717551f832ae6
Created October 9, 2015 17:53
Flowdock: Tail log and stream to flowdock FLOW
unbuffer tail -f /var/log/log.log | egrep --line-buffered "DEPLOY_SUMMARY" | xargs -I {} /usr/bin/curl -XPOST -H "content-type:application/json" -d '{"content":"{}","external_user_name": "Deploy"}' https://api.flowdock.com/v1/messages/chat/xxxxx
@omar-yassin
omar-yassin / gist:5d3ad496d570b35a721e
Created September 24, 2015 19:17
# Install chef-server
# ON SERVER:
1. install chef-server
2. intialize new chef instance `sudo chef-server-ctl reconfigure`
@omar-yassin
omar-yassin / gist:49252a62e45cbf49b641
Last active March 9, 2023 19:09
SUDOERS cheatsheet
# REMEMBER TO USE VISUDO - you can potentially lock yourself out if sudoers file has parse error
# change visudo editor to VIM
Defaults editor=/usr/bin/vim
# example of /etc/sudoers.d/lbbackup
Cmnd_Alias LS_HARDWARE = /usr/bin/lshw
Cmnd_Alias MOUNT_UDF = /bin/mount -oloop\,rw *
Cmnd_Alias UNMOUNT_UDF = /bin/umount /data/TEMP_UDF_DIR/MOUNT_UDF
select key/value
aws --profile xxx --output json ec2 describe-instances --instance-ids i-xxxxxx | jq -r '.Reservations[].Instances[].Tags[] | select(.Key | contains("computername")) | .Value'
@omar-yassin
omar-yassin / gist:223f7904e27738e3b2e3
Created August 26, 2015 18:52
AWS CLI SES send-email
# email using aws ses
function send-email ()
{
email_message="/tmp/email_message"
email_cleanup="/tmp/email_cleanup"
email_destination="/tmp/email_destination"
# we need to clean up our logs so we can send via json; remove new line and quotes
# and I don't understand the bash issue with running cat | sed in the $email_message declaration. Fun TODO to understand why?
cat $LOG_FILE | sed ':a;N;$!ba;s/\n/\\n/g' | tr -d '"' > $email_cleanup
@omar-yassin
omar-yassin / gist:a88a7b610c5356b039cc
Created August 24, 2015 18:19
SED: Convert New Lines to \n (to keep new lines in JSON)
sed ':a;N;$!ba;s/\n/\\n/g'