Skip to content

Instantly share code, notes, and snippets.

View alexclifford's full-sized avatar

Alex Clifford alexclifford

  • Melbourne, Australia
View GitHub Profile
@alexclifford
alexclifford / ovftool_restore.sh
Created January 30, 2014 01:23
Restore/Deploy an OVF backup/template
# Restore/Deploy an OVF backup/template
ovftool -ds=datastore -dm=thin -n=new-server /var/backup_files/esxi/ubuntu-template/ubuntu-template.ovf vi://[email protected]
@alexclifford
alexclifford / read_pf_log_file.sh
Created February 5, 2014 00:04
Read a pf log file...
tcpdump -n -e -ttt -r /var/log/pflog
@alexclifford
alexclifford / bashrc_changes
Created March 28, 2014 00:20
Useful ~/.bashrc changes from default Ubuntu install
HISTSIZE=100000
HISTFILESIZE=100000
HISTTIMEFORMAT='%F %T '
@alexclifford
alexclifford / get_esxi_guest_ip_address.sh
Last active October 31, 2023 09:08
ESXi: get the IP address of a host running VMware tools
#!/bin/bash
vim-cmd vmsvc/getallvms | grep -i hostname | cut -d ' ' -f 1 | xargs vim-cmd vmsvc/get.guest | grep ipAddress | sed -n 1p | cut -d '"' -f 2
# or
ssh esxi.example.com /bin/vim-cmd vmsvc/get.guest $(ssh esxi.example.com /bin/vim-cmd vmsvc/getallvms | grep -i hostname | cut -d ' ' -f 1) | grep ipAddress | sed -n 1p | cut -d '"' -f 2
@alexclifford
alexclifford / reset_bash_history.sh
Created March 28, 2014 00:24
Completely reset bash history and logout before more is logged
#!/bin/bash
> ~/.bash_history && history -c && exit
@alexclifford
alexclifford / rescan_vm_for_new_hdd.sh
Created March 28, 2014 00:25
Rescan scsi bus on VM to add new HDD without rebooting
#!/bin/bash
echo "- - -" > /sys/class/scsi_host/host#/scan
@alexclifford
alexclifford / remove_landscape_motd.sh
Created March 28, 2014 00:25
Remove Ubuntu landscape information from motd
#!/bin/bash
apt-get --purge remove landscape-common
@alexclifford
alexclifford / export_moin_wiki.sh
Created March 28, 2014 00:43
Export a MoinMoin wiki to HTML
#!/bin/bash
cd /path/to/moinmoin/
moin --config-dir= --wiki-url=wiki.example.com export dump --target-dir=moin_export/
tar -czf moin_export.tar.gz moin_export
@alexclifford
alexclifford / clean_old_kernels.sh
Last active August 29, 2015 13:57
Remove old, unused, kernels from Ubuntu
sudo apt-get remove --purge $(dpkg -l 'linux-image-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
@alexclifford
alexclifford / parse_ftp_files.sh
Created April 15, 2014 23:15
Parse Nowcast FTP data to create a coordinates plotted Google Map
#!/bin/bash
# cat out all the files' contents to a single file
for DIR in `ls /home/nowcast/FTP_root/au/`; do zcat /home/nowcast/FTP_root/au/$DIR/* >> file.txt; done;
# keep only uniq entries
sort file.txt | uniq >> final_file.txt
# print out the lat/long/timestamp in the required javascript syntax for the Google Maps HTML file
# cloud to ground
awk '$3 <= -38 && $3 >= -39 && $4 >= 146.5 && $4 <= 147.5 && $6 == 1 { print "add_markers(1," $3 "," $4 ",\x27" $1 " " $2 " - " $3 " " $4 "\x27,\x27" $1 " " $2 " - " $3 " " $4 "\x27,\x27/lightning-icon-Sparse-1.png\x27)"}' final_file.txt >> markers_cloud_to_ground.txt