Skip to content

Instantly share code, notes, and snippets.

View genothomas's full-sized avatar
🎯
Focusing

Geno Thomas genothomas

🎯
Focusing
View GitHub Profile
@genothomas
genothomas / private_fork.md
Created March 10, 2022 22:47
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

#!/bin/bash
sudo mkdir -p /etc/pki/tls/certs
sudo chmod 755 /etc/pki/tls/certs
sudo apt-get install libssl1.0.0 -y
cd /etc/pki/tls/certs
export FQDN=`hostname -f`
echo -------------------
echo FQDN is $FQDN
#!/bin/bash
#
# using sed begin and end range
#
# then using awk to get Nth match
#
echo "***get only certificate data..."
openssl s_client -showcerts -servername www.google.com -connect www.google.com:443 < /dev/null 2>/dev/null | sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p'
#!/bin/bash
#
# Shows how awk can have use embedded bash variable
#
thedir="/tmp"
ls $thedir | awk -v thedir=$thedir '{ printf "directory %s has file %s\n",thedir,$1 }'
#!/bin/bash
#
# validates if key and cert are matched
#
openssl rsa -noout -modulus -in $1 | openssl md5
openssl x509 -noout -modulus -in $2 | openssl md5
echo "if the md5 matches, the key matches the cert"
@genothomas
genothomas / sockping.sh
Created June 22, 2021 06:38 — forked from khmarochos/sockping.sh
To establish a TCP-connection and be keeping it alive
#!/bin/bash
function log {
echo $(date) ' >> ' $* >&2
}
function die {
echo $* >&2
exit 1
}
for dir in $(find /export/secondary2/snapshots -wholename '/export/secondary2/snapshots/*/*' -type d); do { files=$(ls "${dir}" | wc -l); if [[ "${files}" -gt 2 ]]; then echo $dir; ls -tl "${dir}"; for file in $(ls -t "${dir}" | tail --lines +3); do { read -p "Remove ${file}?" -n 1 -r; if [[ "${REPLY}" =~ ^[Yy]$ ]]; then echo " ... removing ${dir}/${file}"; rm "${dir}/${file}"; else echo " ... skipping ${dir}/${file}"; fi; } done; fi; } done
for dir in $(find /export/secondary2/snapshots -wholename '/export/secondary2/snapshots/*/*' -type d -mtime +21); do { if [[ "$(ls ${dir} | wc -l)" -lt 1 ]]; then continue; fi; ls -tl "${dir}"; read -p "Remove ${dir}?" -n 1 -r; if [[ "${REPLY}" =~ ^[Yy]$ ]]; then echo " ... removing ${dir}"; rm -rf "${dir}"; else echo " ... skipping ${dir}"; fi; } done
@genothomas
genothomas / servers
Created June 22, 2021 06:37 — forked from khmarochos/servers
To run a command on a bunch of servers, so you can say: spread.sh --command 'rm -rf / &' --grep-criteria '#centos|#msdos'
#
# The format is following:
# hostname:username:port:ssh-key #comments #tags
# All parameters besides of the first are optional
#
# Regular servers
host1
host2
host3
# The servers where we shall use an alternative username to log in
@genothomas
genothomas / diskhogs.sh
Created June 22, 2021 06:36 — forked from khmarochos/diskhogs.sh
Ever craved for a tool to monitor what files are growing faster than other ones? Just run it by cron: diskhogs.sh /var/lib/libvirt/images
#!/bin/sh
# Checking the spool directory
SPOOL=/var/spool/diskhogs
if [ ! -e "${SPOOL}" ]; then
mkdir -p "${SPOOL}"
fi
if [ ! -d "${SPOOL}" ]; then
echo "There are no ${SPOOL} directory" >&2
exit 1
@genothomas
genothomas / .bash_today
Created June 22, 2021 06:36 — forked from khmarochos/.bash_today
.bash_today: This simple script lists today’s tasks every time you log in (or create a new window in your screen)
# Just add me to your .bashrc:
# [ -x ~/.bashrc_today ] && . ~/.bashrc_today
TODAYD="${HOME}/.today.d"
if [ ! -d "${TODAYD}/today" ]; then
mkdir -p "${TODAYD}/today"
fi
TODAY=$(date +%F)