This file contains 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
## incomplete; just a guide so I can remember | |
$log_file | |
last_length = `cat /tmp/${log_file}_last_length` | |
current_legnth = 'wc -c $log_file' | |
if [[ $last_file_length > 0 ]] ; then | |
diff_length = current_length - last_length | |
if [[ diff_length >= 0 ]] ; then |
This file contains 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
sc.exe config $ServiceName start= "delayed-auto" |
This file contains 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
# load xml | |
[xml]$xml = `what evber out put that prints xml - or can load xml from file path` | |
# read xml contents | |
$xml.nodeName.ChildNodes |
This file contains 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
$path = 'C:\omar\Web.config' | |
$xml = [xml](Get-Content $path) | |
$UseWebResourceCDN=$xml.configuration.appSettings.add | where {$_.key -eq 'UseWebResourceCDN'} | |
$UseWebResourceCDN.Value = 'True' | |
$xml.save($path) |
This file contains 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
# prints stdout and logs to file | |
function logger () | |
{ | |
echo "${1}" | tee -a $LOG_FILE | |
} | |
# function to wrap errors and exit | |
# USAGE: rc=${PIPESTATUS[0]} ; check_return_value | |
rc=0 | |
function check_return_value |
This file contains 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
sed ':a;N;$!ba;s/\n/\\n/g' |
This file contains 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
# 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 |
This file contains 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
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' |
This file contains 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
# 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 |
This file contains 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
# ON SERVER: | |
1. install chef-server | |
2. intialize new chef instance `sudo chef-server-ctl reconfigure` |