Skip to content

Instantly share code, notes, and snippets.

View bmatthewshea's full-sized avatar

Brady Shea bmatthewshea

View GitHub Profile
#! /bin/sh
#
# postgrey start/stop the postgrey greylisting deamon for postfix
# (priority should be smaller than that of postfix)
#
# Author: (c)2004-2006 Adrian von Bidder <avbidder@fortytwo.ch>
# Based on Debian sarge's 'skeleton' example
# Distribute and/or modify at will.
#
# Version: $Id: postgrey.init 1436 2006-12-07 07:15:03Z avbidder $
@bmatthewshea
bmatthewshea / startexe.cmd
Last active September 12, 2015 17:10
superuser.com/q/972076/47628
@echo off
start "Notepad" "C:\Windows\system32\notepad.exe"
start "Skype" "C:\Program Files (x86)\Skype\Phone\Skype"
start "Firefox CNN" "%programfiles(x86)%\Mozilla Firefox\Firefox.exe" "http://www.cnn.com/"
start "CMD Start Help" "cmd start /?"
#!/bin/bash
#Update file location to your needs/setup - assumes root access needed:
FILE=/etc/vsftpd/vsftpd-virt-htpasswds
#some checks
if [ "$EUID" -ne 0 ]
then echo "Please run this script as root or use sudo. Exiting."
exit
fi
@bmatthewshea
bmatthewshea / windows_ec2_snapshot.bat
Last active September 13, 2016 21:09 — forked from ehlertij/windows_ec2_snapshot.bat
Windows batch script for creating daily EC2 snapshots for a volume and deleting old ones.
set AWS_EC2_COMMAND=aws ec2 --dryrun
set AWS_HOME=.
set AWS_VOLUME=vol-12345678
set AWS_SNAPSHOT_KEEP=10
set VOL_DESC=Daily Snapshot
:: Create snapshot for this volume
CMD /C %AWS_EC2_COMMAND% create-snapshot %AWS_VOLUME% -d "%VOL_DESC%"
:: Find old snapshots for this volume, sort them by date desc
@bmatthewshea
bmatthewshea / .cron_prune_backups.sh
Last active September 14, 2016 13:25
FIND command to reduce backups in folder - saving only 1st of month if older than 90 days
#!/bin/bash
DS=`date "+%Y-%m-%d %H:%M:%S"`
FINDPATH=/opt/mysql-backups
LOG="$FINDPATH"/mysql-backup-removal.log
### find >= 90 day - but leave/exclude a 1st day of month forever...
find "$FINDPATH"/backupname_* -name 'backupname_??-01-*' -prune -o -mtime +90 -exec ls {} \; -exec rm {} \; >> "$LOG"
@bmatthewshea
bmatthewshea / restart-svc-on-log-failure.sh
Created October 17, 2017 14:49
A BASH script to monitor a log and restart a service if idle.
#!/bin/bash
set -x
PATH=$PATH:/opt/scripts
SERVICE=ethminer
# start infinite loop
while :
do
SECS=$(date +%s)
@bmatthewshea
bmatthewshea / ethminer-monitor.sh
Last active January 20, 2018 17:52
BASH/CRONTAB - Restart ethminer service if stalled
#!/bin/bash
PATH=$PATH:/usr/bin:/usr/sbin:/var/log/miners:/home/ubuntu/scripts
SECS=$(date +%s)
ETHMINERLOGFILE=/var/log/miners/ethminer.log
ETHMINERRESTART=/var/log/miners/ethminer-restarts.log
idletime=$(expr $SECS - $(date +%s -r $ETHMINERLOGFILE))
echo -n "$(date) - Status check running.. " &>> $ETHMINERRESTART
if [ "$idletime" -gt 300 ]
@bmatthewshea
bmatthewshea / ethminer
Last active January 24, 2018 17:18
/etc/default/ethminer service default file
# User settings - Here you can enable/disable a given miner profile:
#
RUNAS="ubuntu" # For the amdgpu-pro driver this user must be a member of 'video' group
DAEMON="/opt/miners/ethminer" # Wherever you installed the binary - make sure its executable by above user.
GPU="-G" # -U (nVidia Cuda) or -G (OpenCL) or -X (mixed Cuda/OpenCL cards)
WORKER="Worker1"
LOGFILE="/var/log/miners/ethminer.log"
# values: pool, proxy, solo
@bmatthewshea
bmatthewshea / backup-sqlexpress-db.cmd
Last active April 7, 2018 13:16
SQLExpress simple CMD backup
:: sqlcmd command mostly taken from https://stackoverflow.com/questions/880487/sql-server-command-line-backup-statement
@echo off
setlocal EnableExtensions EnableDelayedExpansion
set DATABASENAME=MyDatabase
set SERVERNAME=MYSERVER
set HOME=C:\Users\Administrator\Documents\Backup and Logs
call :dotimestamp
set BACKUPFILENAME=D:\SQLExpress-Backups\%DATABASENAME%-%TIMESTAMP%.bak
set LOGFILE=backup-sqlexpress-%DATABASENAME%.log
@bmatthewshea
bmatthewshea / .bash_prompt
Last active September 23, 2018 17:54
BASH prompt function / color prompt with time
# add this to end of ~/.bashrc:
# if [ -f ~/.bash_prompt ]; then
# . ~/.bash_prompt
# fi
# prompt function
function myprompt {
local BLUE="\[\033[0;34m\]"
local LIGHT_BLUE="\[\033[1;34m\]"
local RED="\[\033[0;31m\]"