Skip to content

Instantly share code, notes, and snippets.

View olaseni's full-sized avatar
🎯
Focusing

Olaseni Oluwunmi olaseni

🎯
Focusing
View GitHub Profile
@olaseni
olaseni / list_gcp_iprange.sh
Created July 10, 2019 05:34 — forked from n0531m/list_gcp_iprange.sh
Google Cloud Platform : ip address range
#!/bin/bash
# https://cloud.google.com/compute/docs/faq#find_ip_range
# nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
myarray=()
for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | cut -f 2 -d :`
do
myarray+=($LINE)
for LINE2 in `dig txt $LINE +short | tr " " "\n" | grep include | cut -f 2 -d :`
@olaseni
olaseni / block-ip.sh
Last active May 2, 2019 06:07
Blocks/rejects an IP address irrespective of port, for TCP connections
#!/usr/bin/env bash
block() {
# $1 is the remote address you want to block.
route add $1 gw 127.0.0.1 lo
route add -host $1 reject
# Flush the cache.
@olaseni
olaseni / zimbra_manage_disclaimers.sh
Last active October 4, 2024 20:18
Zimbra Enable/Disable Disclaimers
# Run as zimbra user
# Add Disclaimer
zmprov mcf zimbraDomainMandatoryMailSignatureEnabled TRUE
zmprov md DOMAIN.COM zimbraAmavisDomainDisclaimerText "text disclamer"
zmprov md DOMAIN.COM zimbraAmavisDomainDisclaimerHTML "<html><body><h1>HTML Disclaimer</h1><br> <h1>User 1</h1><br>phone number here</body></html>"
./libexec/zmaltermimeconfig -e DOMAIN.COM
./libexec/zmaltermimeconfig # if have multiple MTAs
@olaseni
olaseni / generate-ssh-key.sh
Created August 23, 2018 19:47 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@olaseni
olaseni / dump_ram_metrics.sh
Last active May 2, 2019 05:17
A simple bash script that dumps RAM metrics and usage.
#!/usr/bin/env bash
# RAM/CPU consumers
# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
# ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 20 # more details, less metrics
# ps aux --sort=-%mem | awk 'NR<=10{print $0}' # even more details
LOG="/var/log/ram.dump.log"
DATE="$(date)"
# echo -e "RAM Dump @ ${DATE} :\n $(vmstat -sn -SM | egrep '(total|free)')" >> ${LOG}