Skip to content

Instantly share code, notes, and snippets.

View rhysrhaven's full-sized avatar

Rhys Rhaven rhysrhaven

View GitHub Profile
@rhysrhaven
rhysrhaven / sharemon.sh
Created May 20, 2015 01:13
Teachers inbox sharing mechanism
#!/bin/bash -eu
# This monitors the incoming_dir (directories named after their users)
# Any zip files uploaded to said dirs will be shared in the shared_dir
# under a random directory, and the link emailed to the users.
# Requires dma, but you can replace that with other MTAs.
incoming_dir='/home/share'
shared_dir='/var/www/drop'
share_server='share.rhavenindustrys.com/drop'
webkey_size='64'
@rhysrhaven
rhysrhaven / gibson.sh
Created May 20, 2015 01:08
Xtreemefs automata?
# ..__Creating_The_Gibson__..
# For obvious reasons
ROLLBACK='/tmp/gibsonrollback.sh'
>${ROLLBACK} # blanks the file
if [[ "$1" == "rollback" ]]; then bash ${ROLLBACK}; exit; fi
function add_rollback {
echo "echo $@" >> ${ROLLBACK}
echo "$@" >> ${ROLLBACK}
}
@rhysrhaven
rhysrhaven / complicity.sh
Created May 20, 2015 01:05
wrapper around duplicity in bash
#!/bin/bash -eu
## Complicity: A wrapper for Duplicity backup tool
## Configure, Load into /etc/cron.daily/, done.
## Version 1.4
# Base directory Duplicity backs up
base_dir='/'
# Excluded directories from the base directory. Like /proc. ** is wildcard
exclude_dirs=('**')

Keybase proof

I hereby claim:

  • I am rhysrhaven on github.
  • I am rhysrhaven (https://keybase.io/rhysrhaven) on keybase.
  • I have a public key ASChoVfAnkrChMlpqqD2cEH0Utbwe0W2bwVvnee9AduHGwo

To claim this, I am signing this object:

@rhysrhaven
rhysrhaven / Bash State Machine
Last active December 17, 2022 13:21
Simple bash state machine to re-run script in the same place after failure. Better to use case statement fall through if you have Bash 4.
#!/bin/bash
LOL=/tmp/LOLZ
RUNNING=true
while $RUNNING; do
case $([ -f $LOL ] && cat $LOL) in
INIT)
echo "Reached INIT State. Moving to WORK state."
echo "WORK" > $LOL
@rhysrhaven
rhysrhaven / dnscheck.sh
Last active October 25, 2018 14:05
Returns records from DNS servers. Built to be used as an external check from Zabbix.
#!/bin/bash
#
# DNS Check Script
# Given two parameters, the DNS record type and a domainname
# Will return the record if exists, 'NXDOMAIN' if it doesnt.
#
DIG='/usr/bin/dig'
VALID_RECORDS=(
'mx'
ㄕサ'ибレㄩⅰ ㎡бレῳ'и∆モサ ς₮サㄩレサㄩ Я'レㄚ∑サ ῳб∆サ'и∆бレ モサ₮∆би