public
Description: bash scripts, aliases, other misc things go here
Homepage: http://opensource.thinkrelevance.com
Clone URL: git://github.com/relevance/etc.git
Search Repo:
move everything over from svn
rsanheim (author)
Thu Apr 10 21:39:14 -0700 2008
commit  c4490ba208e1d1abc01768730acc114c70e9c3ea
tree    f5d8e2d3be23cfc298c2884712fb17e139125168
parent  0c29a6a67ca3b9c542471fcf7688918bcbf85334
...
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
0
@@ -1 +1,14 @@
0
+#!/bin/sh
0
+
0
+MAILTO=you@yourdomain.com
0
+
0
+df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
0
+do
0
+ consumed=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
0
+ partition=$(echo $output | awk '{ print $2 }' )
0
+ if [ $consumed -ge 95 ]; then
0
+ echo "Running out of disk space on \"$partition [$consumed% consumed]\" on $(hostname)" |
0
+ mail -s "[ALERT]: $(hostname) is almost out of disk space" $MAILTO
0
+ fi
0
+done
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
0
@@ -1 +1,46 @@
0
+#!/bin/sh
0
+#
0
+# Startup script for the nginx Server
0
+#
0
+# chkconfig: 345 85 15
0
+# description: nginx is a World Wide Web server.
0
+# processname: nginx
0
+# pidfile: /usr/local/nginx/logs/nginx.pid
0
+
0
+# Source function library.
0
+. /etc/rc.d/init.d/functions
0
+
0
+case "$1" in
0
+ start)
0
+ echo -n "Starting nginx"
0
+ /usr/local/sbin/nginx -c /usr/local/nginx/conf/nginx.conf || echo -n " already running"
0
+ touch /var/lock/subsys/nginx
0
+ echo
0
+ ;;
0
+ stop)
0
+ echo -n "Stopping nginx"
0
+ killproc nginx
0
+ echo
0
+ rm -f /var/lock/subsys/nginx
0
+ rm -f /usr/local/nginx/logs/nginx.pid
0
+ ;;
0
+ restart)
0
+ echo -n "Restarting nginx"
0
+ $0 stop
0
+ # One second might not be time enough for a daemon to stop,
0
+ # if this happens, d_start will fail (and dpkg will break if
0
+ # the package is being upgraded). Change the timeout if needed
0
+ # be, or change d_stop to have start-stop-daemon use --retry.
0
+ # Notice that using --retry slows down the shutdown process somewhat.
0
+ sleep 1
0
+ $0 start
0
+ echo "."
0
+ ;;
0
+ *)
0
+ echo "Usage: $0 {start|stop|restart}"
0
+ exit 1
0
+ ;;
0
+esac
0
+
0
+exit 0
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
0
@@ -1 +1,98 @@
0
+echo "[ executing aliases.sh ]"
0
+
0
+# general shortcuts
0
+alias c='cd '
0
+alias mv='mv -i'
0
+alias rm='rm -i'
0
+alias :='cd ..'
0
+alias ::='cd ../..'
0
+alias :::='cd ../../..'
0
+alias v='vmstat'
0
+alias md=mkdir
0
+
0
+# Need to do this so you use backspace in screen...I have no idea why
0
+alias screen='TERM=screen screen'
0
+
0
+# listing files
0
+alias l='ls -al'
0
+alias lt='ll -t'
0
+alias la='lt -a'
0
+alias lth='ll -t|head'
0
+alias lh='ls -Shl | less'
0
+alias tf='tail -f'
0
+alias t500='tail -n 500'
0
+alias t1000='tail -n 1000'
0
+alias t2000='tail -n 2000'
0
+
0
+# svn
0
+alias sup='svn up'
0
+alias sst='svn st'
0
+alias sstu='svn st -u'
0
+alias sci='svn ci -m'
0
+alias sdiff='svn diff | colordiff'
0
+alias smate='svn diff | mate && svn ci'
0
+alias sadd="sst | grep '?' | cut -c5- | xargs svn add"
0
+
0
+# git
0
+alias gst='git status'
0
+alias gl='git pull'
0
+alias gp='git push'
0
+alias gd='git diff | mate'
0
+alias gc='git commit -v'
0
+alias gca='git commit -v -a'
0
+alias gb='git branch'
0
+alias gba='git branch -a'
0
+
0
+# git svn
0
+alias gsr='git svn rebase'
0
+alias gsd='git svn dcommit'
0
+
0
+# editing shortcuts
0
+alias m='mate'
0
+alias e='emacs'
0
+alias erc='e /etc/bashrc'
0
+alias newrc='. /etc/bashrc'
0
+alias rsync_nosvn="rsync --exclude=.svn -r "
0
+alias rsync_novc="rsync --exclude=.svn --exclude=.git -r "
0
+
0
+alias sourceit='. ~/src/scripts/profile.d/00_startup.sh'
0
+
0
+# mate shortcuts
0
+alias m8prof='m ~/src/scripts/profile.d/'
0
+
0
+# ignore svn metadata - pipe this into xargs to do stuff
0
+alias no_svn="find . -path '*/.svn' -prune -o -type f -print"
0
+
0
+function findfile { find . -name \*$1\*
0
+}
0
+function orig { mv $1 orig-$1 ; cp orig-$1 $1; ls -lt $1 orig-$1
0
+}
0
+function ps? { ps -aux | grep -i $* | grep -v grep
0
+}
0
+
0
+# Mac style apache control
0
+# alias htstart='sudo /System/Library/StartupItems/Apache/Apache start'
0
+# alias htrestart='sudo /System/Library/StartupItems/Apache/Apache restart'
0
+# alias htstop='sudo /System/Library/StartupItems/Apache/Apache stop'
0
+
0
+# Debian style apache control
0
+alias htreload='sudo /etc/init.d/apache2 reload'
0
+alias htrestart='sudo /etc/init.d/apache2 restart'
0
+alias htstop='sudo /etc/init.d/apache2 stop'
0
+
0
+# top level folder shortcuts
0
+alias src='cd ~/src'
0
+alias docs='cd ~/documents'
0
+alias scripts='cd ~/src/scripts'
0
+
0
+# ssh autocompletion
0
+SSH_COMPLETE=( $(cat ~/.ssh/known_hosts | \
0
+cut -f 1 -d ' ' | \
0
+sed -e s/,.*//g | \
0
+uniq | \
0
+egrep -v [0123456789]) )
0
+complete -o default -W "${SSH_COMPLETE[*]}" ssh
0
+
0
+alias h?="history | grep "
0
+alias ps?="ps aux | grep "
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
0
@@ -1 +1,50 @@
0
+echo "[ executing ruby.sh ]"
0
+
0
+# always load gems for ruby
0
+export RUBYOPT=rubygems
0
+
0
+complete -C ~/src/scripts/bin/rake_autocompletion.rb -o default rake
0
+
0
+# ruby shortcuts
0
+alias gems='cd /opt/local/lib/ruby/gems/1.8/gems'
0
+
0
+alias sc='script/console'
0
+alias ss='script/server'
0
+alias sg='script/generate'
0
+
0
+# testing shortcuts
0
+alias rt='rake --trace'
0
+alias rtf='rake test:functionals --trace'
0
+alias rti='rake test:integration --trace'
0
+alias rtl='rake test:lib --trace'
0
+alias rtp='rake test:plugins --trace'
0
+alias rtu='rake test:units --trace'
0
+
0
+alias rrcov='rake coverage:all:test'
0
+alias rrrcovall='rake test:coverage:all:test'
0
+
0
+alias rdm='rake db:migrate'
0
+alias rdtp='rake db:test:prepare'
0
+alias rdfl='rake db:fixtures:load'
0
+
0
+# unit_record and autotest
0
+alias autou='autotest'
0
+alias autof='AUTOTEST=functional autotest'
0
+
0
+# capistrano
0
+alias csd='cap staging deploy'
0
+
0
+# open rails code
0
+alias m8rails125='mate ~/src/rails/rel_1-2-5'
0
+alias m8rails126='mate ~/src/rails/rel_1-2-6'
0
+alias m8rails201='mate ~/src/rails/rel_2-0-1'
0
+alias m8rails202='mate ~/src/rails/rel_2-0-2'
0
+alias m8railsedge='mate ~/src/rails/trunk'
0
+alias m8railsstable='mate ~/src/rails/2-0-stable'
0
+
0
+# shorten mongrel cluster commands
0
+# example: cluster_start myapp
0
+cluster_restart () { mongrel_rails cluster::restart -C /etc/mongrel_cluster/$1.yml;}
0
+cluster_start () { mongrel_rails cluster::start -C /etc/mongrel_cluster/$1.yml;}
0
+cluster_stop () { mongrel_rails cluster::stop -C /etc/mongrel_cluster/$1.yml;}
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
0
@@ -1 +1,84 @@
0
+worker_processes 2;
0
+error_log /var/www/apps/application/current/log/nginx.error.log debug;
0
+pid /var/www/apps/application/shared/pids/nginx.pid;
0
+
0
+events {
0
+ worker_connections 1024;
0
+}
0
+
0
+http {
0
+ include /usr/local/nginx/conf/mime.types;
0
+ default_type application/octet-stream;
0
+
0
+ log_format main '$remote_addr - $remote_user [$time_local] $status '
0
+ '"$request" $body_bytes_sent "$http_referer" '
0
+ '"$http_user_agent" "$http_x_forwarded_for"';
0
+
0
+ access_log /var/www/apps/application/current/log/nginx.access.log main;
0
+
0
+ sendfile on;
0
+ tcp_nopush on;
0
+ tcp_nodelay on;
0
+ keepalive_timeout 70;
0
+
0
+ gzip on;
0
+ gzip_min_length 1000;
0
+ gzip_buffers 4 8k;
0
+ gzip_comp_level 9;
0
+ gzip_proxied any;
0
+ gzip_types application/xml application/javascript application/x-javascript application/atom+xml application/rss+xml;
0
+ gzip_types text/css text/html text/javascript text/js text/plain text/xml;
0
+
0
+ upstream mongrel {
0
+ server 127.0.0.1:8000;
0
+ server 127.0.0.1:8001;
0
+ }
0
+
0
+ server {
0
+ listen 80;
0
+ server_name 10.3.16.62;
0
+ root /var/www/apps/application/current/public;
0
+ index index.html index.htm;
0
+
0
+ location / {
0
+ proxy_set_header X-Real-IP $remote_addr;
0
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
0
+ proxy_set_header Host "10.3.16.62";
0
+ proxy_redirect false;
0
+ proxy_max_temp_file_size 0;
0
+
0
+ # if static file exists serve now, skip rewrite rules
0
+ if (-f $request_filename) {
0
+ expires max;
0
+ break;
0
+ }
0
+ if (-f $request_filename/index.html) {
0
+ expires 7d;
0
+ rewrite (.*) $1/index.html break;
0
+ }
0
+ # support rails page caching
0
+ if (-f $request_filename.html) {
0
+ rewrite (.*) $1.html break;
0
+ }
0
+ # pass it onto upstream mongrel cluster
0
+ if (!-f $request_filename) {
0
+ proxy_pass http://mongrel;
0
+ break;
0
+ }
0
+ }
0
+
0
+ location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov).*?$ {
0
+ root current_path/public;
0
+ if (!-f $request_filename) {
0
+ proxy_pass http://mongrel;
0
+ break;
0
+ }
0
+ }
0
+
0
+ error_page 500 502 503 504 /50x.html;
0
+ location = /50x.html {
0
+ root /var/www/apps/application/current/public;
0
+ }
0
+ }
0
+}
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
0
@@ -1 +1,161 @@
0
+
0
+### BEGIN INIT INFO
0
+# Provides: cruisecontrol.rb
0
+# Required-Start: $local_fs $remote_fs
0
+# Required-Stop: $local_fs $remote_fs
0
+# Default-Start: 2 3 4 5
0
+# Default-Stop: S 0 1 6
0
+# Short-Description: CruiseControl.rb
0
+# Description: Continuous build integration system. This runs the web interface (via mongrel and the builders).
0
+### END INIT INFO
0
+
0
+# Author: Aaron Bedra <aaron@thinkrelevance.com>
0
+#
0
+# Please remove the "Author" lines above and replace them
0
+# with your own name if you copy and modify this script.
0
+
0
+# Do NOT "set -e"
0
+
0
+
0
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
0
+PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/var/lib/gems/1.8/bin/
0
+CCRBDIR=/home/cruise/cruisecontrolrb/
0
+DESC="Continous Integration"
0
+NAME=cruisecontrolrb
0
+DAEMON_ARGS="start -d"
0
+SCRIPTNAME=/etc/init.d/$NAME
0
+CCRBUSER="cruise"
0
+
0
+# Read configuration variable file if it is present
0
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
0
+
0
+EXTRAARGS="--chuid $CCRBUSER --chdir $CCRBDIR --quiet $EXTRAARGS"
0
+PIDFILE=$CCRBDIR/tmp/pids/mongrel.pid
0
+BUILDER_PIDS=$CCRBDIR/tmp/pids/builders
0
+DAEMON=$CCRBDIR/cruise
0
+
0
+# Exit if the package is not installed
0
+[ -x "$DAEMON" ] || exit 0
0
+
0
+# Load the VERBOSE setting and other rcS variables
0
+[ -f /etc/default/rcS ] && . /etc/default/rcS
0
+
0
+# Define LSB log_* functions.
0
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
0
+. /lib/lsb/init-functions
0
+
0
+#
0
+# Function that starts the daemon/service
0
+#
0
+do_start()
0
+{
0
+ # Return
0
+ # 0 if daemon has been started
0
+ # 1 if daemon was already running
0
+ # 2 if daemon could not be started
0
+ start-stop-daemon --start --pidfile $PIDFILE $EXTRAARGS --exec $DAEMON --test > /dev/null \
0
+ || return 1
0
+ start-stop-daemon --start --pidfile $PIDFILE $EXTRAARGS --exec $DAEMON -- \
0
+ $DAEMON_ARGS \
0
+ || return 2
0
+ # Add code here, if necessary, that waits for the process to be ready
0
+ # to handle requests from services started subsequently which depend
0
+ # on this one. As a last resort, sleep for some time.
0
+}
0
+
0
+#
0
+# Function that stops the daemon/service
0
+#
0
+do_stop()
0
+{
0
+ # Return
0
+ # 0 if daemon has been stopped
0
+ # 1 if daemon was already stopped
0
+ # 2 if daemon could not be stopped
0
+ # other if a failure occurred
0
+ start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE
0
+ RETVAL="$?"
0
+ [ "$RETVAL" = 2 ] && return 2
0
+
0
+ # Kill all builders
0
+ for BPID in `ls $BUILDER_PIDS/*.pid`; do
0
+ start-stop-daemon --stop --signal KILL --pidfile "$BPID"
0
+ [ "$?" = 2 ] && return 2
0
+ rm -f "$BPID"
0
+ done
0
+ # Many daemons don't delete their pidfiles when they exit.
0
+ rm -f $PIDFILE
0
+
0
+ return "$RETVAL"
0
+}
0
+
0
+#
0
+# Function that sends a SIGHUP to the daemon/service
0
+#
0
+do_reload() {
0
+ #
0
+ # If the daemon can reload its configuration without
0
+ # restarting (for example, when it is sent a SIGHUP),
0
+ # then implement that here.
0
+ #
0
+ start-stop-daemon --stop --signal 1 --pidfile $PIDFILE
0
+ return 0
0
+}
0
+
0
+case "$1" in
0
+ start)
0
+ log_daemon_msg "Starting $DESC" "$NAME"
0
+ do_start
0
+ case "$?" in
0
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
0
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
0
+ esac
0
+ ;;
0
+ stop)
0
+ log_daemon_msg "Stopping $DESC" "$NAME"
0
+ do_stop
0
+ case "$?" in
0
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
0
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
0
+ esac
0
+ ;;
0
+ #reload|force-reload)
0
+ #
0
+ # If do_reload() is not implemented then leave this commented out
0
+ # and leave 'force-reload' as an alias for 'restart'.
0
+ #
0
+ #log_daemon_msg "Reloading $DESC" "$NAME"
0
+ #do_reload
0
+ #log_end_msg $?
0
+ #;;
0
+ restart|force-reload)
0
+ #
0
+ # If the "reload" option is implemented then remove the
0
+ # 'force-reload' alias
0
+ #
0
+ log_daemon_msg "Restarting $DESC" "$NAME"
0
+ do_stop
0
+ case "$?" in
0
+ 0|1)
0
+ do_start
0
+ case "$?" in
0
+ 0) log_end_msg 0 ;;
0
+ 1) log_end_msg 1 ;; # Old process is still running
0
+ *) log_end_msg 1 ;; # Failed to start
0
+ esac
0
+ ;;
0
+ *)
0
+ # Failed to stop
0
+ log_end_msg 1
0
+ ;;
0
+ esac
0
+ ;;
0
+ *)
0
+ #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
0
+ echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
0
+ exit 3
0
+ ;;
0
+esac
0
+
0
+:

Comments

    No one has commented yet.