From 489051ec45887530d0e996cf9d318e7ceebdadf8 Mon Sep 17 00:00:00 2001 From: Mitch Tishmack Date: Fri, 8 Apr 2016 13:12:12 -0500 Subject: [PATCH] Initial cray osx setup. --- cray-osx.el | 27 ++++++ readme.org | 261 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 cray-osx.el diff --git a/cray-osx.el b/cray-osx.el new file mode 100644 index 0000000..e670253 --- /dev/null +++ b/cray-osx.el @@ -0,0 +1,27 @@ +;;-*-mode: emacs-lisp; coding: utf-8;-*- +;; All these variables control what/how readme.org gets tangled +;; into dotfiles. Off by default set to t to turn them on as +;; needed. + +;; OS types +(setq bsd-p nil) +(setq linux-p nil) +(setq osx-p t) + +;; Optional things +(setq nix-p t) +(setq tmux-p t) +(setq git-p t) +(setq emacs-p t) +(setq vim-p nil) +(setq zsh-p t) +(setq mosh-p t) +(setq x-p t) + +;; Language specific +(setq haskell-p t) +(setq perl-p t) +(setq ruby-p nil) + +;; Cray specific predicate +(setq cray-p t) diff --git a/readme.org b/readme.org index bcffe93..59ccae2 100644 --- a/readme.org +++ b/readme.org @@ -371,6 +371,32 @@ modmap() [ -f "${HOME}/.Xmodmap" ] && xmodmap "${HOME}/.Xmodmap" } #+END_SRC +*** cray +#+BEGIN_SRC sh :tangle (when (eq cray-p t) "tmp/.profile") +stash() +{ + maybe_git_repo "ssh://git@stash.us.cray.com:7999/${1}.git" || \ + maybe_git_repo "ssh://git@stash.us.cray.com:7999/~${1}.git" +} + +haste() +{ + set -e + URL=http://buildservice.us.cray.com:7777/ + if [ ! -z "$@" ]; then + for x in "$@"; do + if [ -f "${x}" ]; then + curl -X POST -s -d "@${x}" ${URL}documents | awk -F '"' '{print "'$URL'"$4}'; + else + echo "file ${x} does not exist to upload" + fi + done + else + cat /dev/stdin | curl -X POST -s -d "@-" ${URL}documents | awk -F '"' '{print "'$URL'"$4}'; + fi + set +e +} +#+END_SRC ** Aliases *** General #+BEGIN_SRC sh @@ -1447,6 +1473,241 @@ cal.each do |line| end #+END_SRC +** 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 * Git ** ~/.gitconfig