| @@ -0,0 +1,242 @@ | |||
| #+TITLE: Cray Configuration | |||
| #+AUTHOR: Mitch Tishmack | |||
| #+STARTUP: hidestars | |||
| #+STARTUP: odd | |||
| #+BABEL: :cache yes | |||
| #+PROPERTY: header-args :cache yes :padline no :mkdirp yes :comments no | |||
| * Cray specific | |||
| ** ~/bin/essh | |||
| Expect ssh, to aide login to smw's etc.. | |||
| #+BEGIN_SRC expect :tangle (when (eq cray-p t) "tmp/bin/essh") :mkdirp yes :tangle-mode (identity #o755) | |||
| #!/usr/bin/expect | |||
| set prompt "> " | |||
| set password [lindex $argv 1] | |||
| set connstr [lindex $argv 0] | |||
| if {$argc > 2} { | |||
| eval spawn ssh -q $connstr "[lrange $argv 2 end]" | |||
| set timeout 3600 | |||
| expect { | |||
| timeout { | |||
| puts "Command took too long" | |||
| exit 1 | |||
| } | |||
| "yes/no" { | |||
| send "yes\r" | |||
| exp_continue | |||
| } | |||
| "assword:" { | |||
| send -- "$password\r" | |||
| exp_continue | |||
| } | |||
| } | |||
| } else { | |||
| spawn ssh -q $connstr | |||
| set timeout 5 | |||
| expect { | |||
| timeout { | |||
| puts "Connection timed out" | |||
| exit 1 | |||
| } | |||
| "yes/no" { | |||
| send "yes\r" | |||
| exp_continue | |||
| } | |||
| "assword:" { | |||
| send -- "$password\r" | |||
| exp_continue | |||
| } | |||
| "$prompt" { | |||
| interact | |||
| } | |||
| } | |||
| } | |||
| #+END_SRC | |||
| *** ~/bin/escp | |||
| Similar to the above only for scp. | |||
| #+BEGIN_SRC expect :tangle (when (eq cray-p t) "tmp/bin/escp") :mkdirp yes :tangle-mode (identity #o755) | |||
| #!/usr/bin/expect | |||
| set prompt "> " | |||
| set password [lindex $argv 0] | |||
| if {$argc > 2} { | |||
| eval spawn scp -q "[lrange $argv 1 end]" | |||
| set timeout 3600 | |||
| expect { | |||
| timeout { | |||
| puts "Command took too long" | |||
| exit 1 | |||
| } | |||
| "yes/no" { | |||
| send "yes\r" | |||
| exp_continue | |||
| } | |||
| "assword:" { | |||
| send -- "$password\r" | |||
| exp_continue | |||
| } | |||
| } | |||
| } | |||
| #+END_SRC | |||
| *** ~/bin/flushdns | |||
| For some reason this sometimes needs to happen, stupid work dns. | |||
| #+BEGIN_SRC sh :tangle-mode (identity #o755) :tangle (when (and (eq cray-p t) (eq osx-p t)) "tmp/bin/flushdns") :mkdirp yes :tangle-mode (identity #o755) | |||
| #!/bin/sh | |||
| set +e | |||
| dscacheutil -flushcache | |||
| sudo killall -HUP mDNSResponder | |||
| sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist | |||
| sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist | |||
| exit $? | |||
| #+END_SRC | |||
| *** ~/bin/tomod | |||
| #+BEGIN_SRC sh :tangle (when (eq cray-p t) "tmp/bin/tomod") :mkdirp yes :tangle-mode (identity #o755) | |||
| #!/usr/bin/env sh | |||
| #-*-mode: Shell-script; coding: utf-8;-*- | |||
| export script=$(basename "$0") | |||
| export dir=$(cd "$(dirname "$0")"; pwd) | |||
| export iam=${dir}/${script} | |||
| remote=cfosbld01 | |||
| export PATH=/usr/local/brew/10.10/bin:~/bin:${PATH} | |||
| branch=$(git rev-parse --abbrev-ref HEAD) | |||
| if [ $? -ne 0 ]; then | |||
| echo not on a branch or in a git repo | |||
| exit 2 | |||
| fi | |||
| base_git="$(pwd)" | |||
| opwd="${base_git}" | |||
| while true; do | |||
| if [ -d ".git" ]; then | |||
| base_git="$(pwd)" | |||
| break | |||
| fi | |||
| if [ "$(pwd)" == "/" ]; then | |||
| echo "No .git base directory found from ${opwd}" | |||
| exit 2 | |||
| fi | |||
| ((count=$count+1)) | |||
| cd .. | |||
| done | |||
| svn_url=$(git svn info --url) | |||
| remote_svn="/notbackedup/users/mtishmack/mod_data/${branch}" | |||
| ssh $remote "module load cpkg sdev craysvn; rm -fr ${remote_svn}; mkdir -p ${remote_svn} && svn co ${svn_url} ${remote_svn} > /dev/null 2>&1;" | |||
| echo "rsyncing local git branch to ${remote}:${remote_svn}" | |||
| rsync \ | |||
| --stats \ | |||
| --checksum \ | |||
| -avz \ | |||
| --hard-links \ | |||
| --exclude=.git \ | |||
| --delete-excluded \ | |||
| --delete \ | |||
| --filter="-rs_.svn" \ | |||
| --filter="-ss_covhtml" \ | |||
| --filter="-ss_dev.yml" \ | |||
| --filter="-ss_.gitignore" \ | |||
| --filter="-ss_*.log" \ | |||
| --filter="-ss_.\#*" \ | |||
| --filter="-ss_*.swp" \ | |||
| --filter="-ss_*.pyc" \ | |||
| --filter="-ss_venv" \ | |||
| --filter="-ss_testdirs" \ | |||
| --filter="-ss_testfiles" \ | |||
| --filter="-ss_.*.git.*" \ | |||
| --filter="-ss_*.o" \ | |||
| --filter="-ss_*.o.cmd" \ | |||
| --filter="-ss_*.ko" \ | |||
| --filter="-ss_*.ko.cmd" \ | |||
| --filter="-ss_*.tmp_versions" \ | |||
| "${base_git}/" "${remote}:${remote_svn}" | |||
| echo "done rsyncing ${base_git} to ${remote}:${remote_svn}" | |||
| #+END_SRC | |||
| *** ~/bin/towip | |||
| #+BEGIN_SRC sh :tangle (when (eq cray-p t) "tmp/bin/towip") :mkdirp yes :tangle-mode (identity #o755) | |||
| #!/usr/bin/env sh | |||
| #-*-mode: Shell-script; coding: utf-8;-*- | |||
| export script=$(basename "$0") | |||
| export dir=$(cd "$(dirname "$0")"; pwd) | |||
| export iam=${dir}/${script} | |||
| remote=cfosbld01 | |||
| export PATH=/usr/local/brew/10.10/bin:~/bin:${PATH} | |||
| branch=$(git rev-parse --abbrev-ref HEAD) | |||
| if [ $? -ne 0 ]; then | |||
| echo not on a branch or in a git repo | |||
| exit 2 | |||
| fi | |||
| base_git="$(pwd)" | |||
| opwd="${base_git}" | |||
| while true; do | |||
| if [ -d ".git" ]; then | |||
| base_git="$(pwd)" | |||
| break | |||
| fi | |||
| if [ "$(pwd)" == "/" ]; then | |||
| echo "No .git base directory found from ${opwd}" | |||
| exit 2 | |||
| fi | |||
| ((count=$count+1)) | |||
| cd .. | |||
| done | |||
| svn_url=$(git svn info --url) | |||
| remote_svn="/notbackedup/users/mtishmack/wip-dws" | |||
| ssh $remote "module load cpkg sdev craysvn; rm -fr ${remote_svn}; mkdir -p ${remote_svn} && svn co ${svn_url} ${remote_svn} > /dev/null 2>&1;" | |||
| echo "rsyncing local git branch to ${remote}:${remote_svn}" | |||
| rsync \ | |||
| --progress \ | |||
| --checksum \ | |||
| -avz \ | |||
| --hard-links \ | |||
| --exclude=.git \ | |||
| --delete-excluded \ | |||
| --delete \ | |||
| --filter="-rs_.svn" \ | |||
| --filter="-ss_covhtml" \ | |||
| --filter="-ss_dev.yml" \ | |||
| --filter="-ss_.gitignore" \ | |||
| --filter="-ss_*.log" \ | |||
| --filter="-ss_.\#*" \ | |||
| --filter="-ss_*.swp" \ | |||
| --filter="-ss_*.pyc" \ | |||
| --filter="-ss_*.o" \ | |||
| --filter="-ss_*.o.cmd" \ | |||
| --filter="-ss_*.tmp_versions" \ | |||
| --filter="-ss_venv" \ | |||
| --filter="-ss_testdirs" \ | |||
| --filter="-ss_testfiles" \ | |||
| --filter="-ss_.*.git.*" \ | |||
| "${base_git}/" "${remote}:${remote_svn}" | |||
| echo "done rsyncing ${base_git} to ${remote}:${remote_svn}" | |||
| #+END_SRC | |||