Skip to content

Instantly share code, notes, and snippets.

@adam12
adam12 / update-slave.sh
Created December 18, 2008 23:52
Bash script to use scp to sync nameservers
#!/bin/bash
TEMPFILE=`mktemp -p /tmp`
HOSTNAME=`hostname`
MASTERS="xx.xx.xx.xx"
REMOTE_URI="[email protected]"
for domain in `/bin/grep ^zone /etc/named.conf | /bin/grep "type master" | /bin/
awk '{print $2}' | /bin/awk -F\" '{print $2}'`
do
/usr/bin/printf "zone \"${domain}\" {\n type slave;\n file \"/var/named/slaves/${domain}.db\";\n masters { ${MASTERS}; };\n};\n\n"
@adam12
adam12 / mergekeys.sh
Created January 4, 2009 04:13
My mergekeys.sh
#!/bin/bash
function setup {
if [ ! -d ~/.ssh ]; then
echo "SSH folder doesn't exist, creating..."
mkdir ~/.ssh
fi
if [ ! -d ~/keys ]; then
echo "Keys folder doesn't exist, creating..."
module Linux
class User
class << self
# Generate an MD5 salt string
def salt
seeds = ('a'..'z').to_a
seeds.concat( ('A'..'Z').to_a )
seeds.concat( (0..9).to_a )
#!/bin/sh
case "$SSH_ORIGINAL_COMMAND" in
*\&*)
echo "Rejected"
;;
*\(*)
echo "Rejected"
;;
*\{*)
#!/bin/sh
/usr/bin/sa-update
if [ $? -eq 0 ]; then
# New rules were installed. Restart spamd
echo 'New spamassassin rules available and installed. Restarting spamassassin'
pkill -9 -f /usr/bin/spamd
/usr/bin/spamd -d -c -m 5
exit 0
else
@adam12
adam12 / codeigniter.conf
Created October 13, 2012 00:09
nginx+php-fpm+ci
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~* \.php$ {
class Application < Sinatra::Base
enable :inline_templates
get '/:folder' do |folder|
if File.directory? 'uploads/' + folder
@files = Dir.glob('uploads/' + folder + '/*')
@folder = folder
erb :index
else
'No files'
Domain
is invalid without a unique name
is invalid without master if slave?
is invalid without a name
is invalid if master not a valid IP
is invalid if type is not NATIVE MASTER or SLAVE
should have a valid factory
#slave?
should be true if type == SLAVE
@adam12
adam12 / apache.conf
Created December 13, 2012 23:31
Monit Configurations
check process apache with pidfile /var/run/apache2.pid
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program = "/etc/init.d/apache2 stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if failed host localhost port 80 protocol http then restart
if 3 restarts within 5 cycles then timeout
#!/bin/bash
### Run with
# while (nc -e info.sh -v -l -p 1025); do sleep 1; done
#
users() {
who | cut -f1 -d ' ' | uniq | awk -v ORS=, '{ print "\042"$1"\042" }' | sed 's/,$//'
}