Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Installs pecl memcache php5 extension on a Joyent Accelerator

//

#!/bin/sh
# Installs pecl memcache php5 extension on a Joyent Accelerator
#
# $Id$

VERSION=2.2.3
TEMPDIR=`/usr/bin/mktemp`

cd ${TEMPDIR}
/usr/sfw/bin/wget http://pecl.php.net/get/memcache-${VERSION}.tgz
/opt/local/bin/tar -zxvf memcache-${VERSION}.tgz
cd memcache-${VERSION}
/opt/local/bin/phpize
./configure
/usr/bin/make
/usr/bin/make install
/opt/local/bin/gsed -i"" "s/;extension=memcache.so/extension=memcache.so/" /opt/local/etc/php.ini

Nginx configure options for Accel w/FLV support

Build nginx on an Accelerator with support for flash video. Assumes you have PCRE and OpenSSL built as per the wiki/forum. Keep everything tidy in /opt/local/nginx.

./configure --prefix=/opt/local/nginx --with-http_ssl_module --with-openssl=../openssl-0.9.8e --with-cc-opt="-m64 -I/usr/local/include -I/usr/local/ssl/include" --with-ld-opt="-L/lib/64 -L/usr/sfw/lib/64 -R/usr/sfw/lib/64 -R/lib/64 -L/usr/local/ssl/lib -m64 -L/usr/local/lib -R/usr/local/lib" --with-http_flv_module

Script to setup ssh tunnel to a remote mysql server

#!/usr/bin/env ruby

require 'yaml'
require 'rubygems'
require_gem 'net-ssh'

$stdout.sync = true

def help
  puts <<-USAGE
	This tool allows you to setup an ssh tunnel to a remote mySQL server

  Useage:
    dbssh <target>
    Please specify configuration in ~/.dbsshrc

  Example:  

    example ~/.dbsshrc:   

      server_name:
        server: servername.com.au
        username: user_id
        password: password_cleartext
        remote_port: 3306
        local_port: 3307
        
  USAGE
  exit
end

app_name = ARGV[0] || help
$config = YAML::load(File.open(File.expand_path("~/.dbsshrc")))[app_name]

puts "connecting to #{$config["server"]}"

exec("ssh -2 -f -c blowfish -N -C #{$config["username"]}@#{$config["server"]} -L #{$config["local_port"]}/127.0.0.1/#{$config["remote_port"]}")

puts ""
puts "success!"

Old Hostname

z13894AA.textdrive.com

Reset Accelerator

Switch to Root User, then type:

reboot

Send e-mail through accelerator commandline

At command prompt:
 sendmail -t

Then type each line followed by a return:
To: test@test.com
From: registration@test.com
Subject: Thanks For Signing up!
This is the thank you!
.

Generate a bind9 rndc key

// description of your code here

dnssec-keygen -a hmac-md5 -b 256 -n HOST mybrandnewkey


The result will be something like "K%2Ftmp%2Fmybrandnewkey.+157+42885", so you do

cat K%2Ftmp%2Fmybrandnewkey.+157+42885.private


Put the key in /etc/rndc.key like this:
key "rndc-key" {
        algorithm hmac-md5;
        secret "Hr1U28EsMhp8r0TEEjAmksoldReEYuiWwQFH0/gkk6I=";
};

bind9 rndc.conf template

I'm in your /etc, managing your named.

include "/etc/rndc.key";

options {
default-server  127.0.0.1;
default-key     "rndc-key";
};

bind9 google apps zone template

Change 1.2.3.4 for your accelerator's ip and mydomain.net for your domain name

$TTL 86400
@ IN SOA ns1.mydomain.net. hostmaster.mydomain.net. (
                              2007052701      ; serial
                              3H              ; refresh
                              15M             ; retry
                              1W              ; expiry
                              1D )            ; minimum

                    IN NS     ns1.mydomain.net.
                    IN NS     ns1.everydns.net.
                    IN NS     ns2.everydns.net.
                    IN NS     ns3.everydns.net.
                    IN NS     ns4.everydns.net.

@                   IN TXT    "v=spf1 ip4:1.2.3.4 include:gmail.com~all include:mydomain.joyent.net~all ~all"

@                   IN MX   1 aspmx.l.google.com.
@                   IN MX   3 alt1.aspmx.l.google.com.
@                   IN MX   3 alt2.aspmx.l.google.com.
@                   IN MX   5 aspmx2.googlemail.com.
@                   IN MX   5 aspmx3.googlemail.com.
@                   IN MX   5 aspmx4.googlemail.com.
@                   IN MX   5 aspmx5.googlemail.com.

_xmpp-server._tcp   IN SRV  5 0 5269 xmpp-server.l.google.com.
_xmpp-server._tcp   IN SRV 20 0 5269 xmpp-server1.l.google.com.
_xmpp-server._tcp   IN SRV 20 0 5269 xmpp-server2.l.google.com.
_xmpp-server._tcp   IN SRV 20 0 5269 xmpp-server3.l.google.com.
_xmpp-server._tcp   IN SRV 20 0 5269 xmpp-server4.l.google.com.

_jabber._tcp        IN SRV  5 0 5269 xmpp-server.l.google.com.
_jabber._tcp        IN SRV 20 0 5269 xmpp-server1.l.google.com.
_jabber._tcp        IN SRV 20 0 5269 xmpp-server2.l.google.com.
_jabber._tcp        IN SRV 20 0 5269 xmpp-server3.l.google.com.
_jabber._tcp        IN SRV 20 0 5269 xmpp-server4.l.google.com.


@                   IN A      1.2.3.4
www                 IN CNAME  @
mail                IN CNAME  ghs.google.com.
start               IN CNAME  ghs.google.com.
calendar            IN CNAME  ghs.google.com.

bind9 0.0.127.in-addr.arpa template

Refered as /var/named/named.local in my named.conf template

$TTL    86400
@       IN      SOA     localhost. root.localhost.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
              IN      NS      localhost.

1       IN      PTR     localhost.