diff src/rlm/push.clj @ 0:78a630e650d2

initial import
author Robert McIntyre <rlm@mit.edu>
date Tue, 18 Oct 2011 00:57:08 -0700
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/rlm/push.clj	Tue Oct 18 00:57:08 2011 -0700
     1.3 @@ -0,0 +1,160 @@
     1.4 +":";exec java -verbose:gc -Xmn500M -Xms1500M -Xmx1500M -server -cp $HOME/roBin/src:$HOME/mobius/src:$HOME/roBin/lib/*:$HOME/Genesis/src:$HOME/mobius/assets:$HOME/mobius/monkey-lib/*:$HOME/workspace/Gauntlet/binary:$HOME/workspace/Clips/bin:$HOME/workspace/Propagators/bin  -Djava.library.path=$HOME/roBin/natives/linux   clojure.main $0 $*;
     1.5 +
     1.6 +
     1.7 +
     1.8 +(ns rlm.push
     1.9 +(:gen-class
    1.10 + :name rlm.push
    1.11 + :main true)
    1.12 +(:use [clojure.contrib
    1.13 +       [duck-streams :only [file-str]]
    1.14 +       command-line str-utils shell-out]
    1.15 +      [rlm shell-write
    1.16 +       [shell-inspect :only [command-line?]]]))
    1.17 +
    1.18 +
    1.19 +(def laserkard ["/home/r/Desktop/web/laserkard"
    1.20 +		"/home/r/lasercutter"
    1.21 +		"/home/r/laser-files"
    1.22 +		"/home/r/emc2"])
    1.23 +
    1.24 +(def moonlitnights ["/home/r/Desktop/web/moonlitnights"])
    1.25 +
    1.26 +(def judyates ["/home/r/Desktop/web/judyates"])
    1.27 +
    1.28 +(def rlmcintyre ["/home/r/Desktop/web/rlmcintyre",
    1.29 +		 "/home/r/Desktop/web/boosterpack"
    1.30 +		 "/home/r/Desktop/web/lib"])
    1.31 +
    1.32 +(def bortreb ["/home/r/Desktop/web/bortreb"])
    1.33 +
    1.34 +(def aurellem ["/home/r/aurellem/site-output"])
    1.35 +
    1.36 +(def mit ["/home/r/Desktop/MIT"])
    1.37 +	 
    1.38 +
    1.39 +(def config
    1.40 +     ["/home/r/.swank-all-repl"
    1.41 +      "/home/r/.clojure_completions"
    1.42 +      "/home/r/swank-all"
    1.43 +      "/home/r/Desktop/web/web.clj"
    1.44 +      "/etc/lighttpd/lighttpd.conf"
    1.45 +      "/home/r/.lightpasswords"
    1.46 +      "/home/r/.profile"
    1.47 +      "/home/r/.xmodmap.clojure"
    1.48 +      "/home/r/.xmodmap.xmonad"
    1.49 +      "/home/r/.xmodmap.normal"
    1.50 +      "/etc/hosts"
    1.51 +      "/home/r/Desktop/web/swank-web"
    1.52 +      "/etc/mercurial/hgrc"
    1.53 +      "/home/r/.hgrc"
    1.54 +      "/home/r/.emacs"
    1.55 +      "/home/r/.emacs.d"
    1.56 +      "/home/r/.bashrc"
    1.57 +      "/home/r/.el"
    1.58 +       "/home/r/.blender"
    1.59 +      ])
    1.60 +
    1.61 +
    1.62 +(def admin
    1.63 +     ["/home/r/Desktop/sliceHost_Admin"
    1.64 +      "/home/r/Desktop/judyates_admin"
    1.65 +      "/home/r/Desktop/laserkard_admin"
    1.66 +      "/home/r/Desktop/moonlitnights_admin"])
    1.67 +
    1.68 +(def genesis
    1.69 +     [;;"/home/r/Desktop/GenesisOutput"
    1.70 +      "/home/r/Jake2"
    1.71 +      ;;"/home/r/workspace" --- removed because it interferes with eclipse's
    1.72 +      ;; color settings.  Stupid eclipse.
    1.73 +      "/home/r/Genesis"
    1.74 +      ;;"/home/r/eclipse" --- also interfers with eclipse's stupid colors.
    1.75 +      ;;"/home/r/telmo"
    1.76 +      ;;"/home/r/sajit"
    1.77 +      ])
    1.78 +
    1.79 +(def projects
    1.80 +     ["/home/r/aurellem"
    1.81 +      "/home/r/cortex"
    1.82 +      "/home/r/mobius"
    1.83 +      "/home/r/roBin"
    1.84 +      "/home/r/openal-soft"
    1.85 +      "/home/r/Desktop/web"])
    1.86 +
    1.87 +(defn rsync-string [#^java.io.File file]
    1.88 +  (if (.isFile file) 
    1.89 +    (.getPath file)
    1.90 +    (str (.getPath file) "/")))
    1.91 +
    1.92 +
    1.93 +(defn rsync-one [destination #^java.io.File file]
    1.94 +  (let 
    1.95 +      [command
    1.96 +       ["rsync" "-avzhO" "--delete" "--relative" (str "/." (rsync-string file)) destination ]]
    1.97 +    (println command)
    1.98 +    ;(apply sw command)
    1.99 +    command
   1.100 +    ))
   1.101 +
   1.102 +
   1.103 +(defn rsync [destination args]
   1.104 +  (doall (map (partial rsync-one destination)  (map file-str args))))
   1.105 +    
   1.106 +(def destinations {"slice" "r@173.203.202.72:/"
   1.107 +		   "rlm" "r@10.0.0.2:/"
   1.108 +		   "sphere" "/home/r/sphere" 
   1.109 +		   })
   1.110 +
   1.111 +
   1.112 +
   1.113 +(defn push-gen [& args]
   1.114 +  (with-command-line args 
   1.115 +    "Push Files from this Computer to others."
   1.116 +    [[all? a?  "Update everything. (except genesis and admin)" false]
   1.117 +     [l? laserkard?  "laserkard source" false]
   1.118 +     [m? moonlitnights? "moonlitnights source" false]
   1.119 +     [j? judyates?  "judyates source" false]
   1.120 +     [r? rlmcintyre?  "rlmcintyre source" false]
   1.121 +     [b? bortreb?  "bortreb repository source" false]
   1.122 +     [c? config?  "webserver config files" false]
   1.123 +     [d? admin?  "website admin folders" false]
   1.124 +     [g? genesis?  "genesis" false]
   1.125 +     [p? projects?  "roBin, aurellem, mobius" false]
   1.126 +     [e? everything? "absolutely everything" false]
   1.127 +     [k? mit? "MIT" false]
   1.128 +     [u? aurellem? "aurellem SITE"]
   1.129 +     [target t
   1.130 +      (str "Target computer. mappings are " destinations " or any ipv4 ip address")
   1.131 +      "rlm"]]
   1.132 +
   1.133 +    (if e? (into (push-gen "-g" "-d" "-k" "-t" target) (push-gen "-a" "-t" target))
   1.134 +	(if all?
   1.135 +	  (push-gen "-l" "-m" "-j" "-r" "-b" "-c" "-p" "-u" "-t" target)
   1.136 +	  (let [target (get destinations target (str "r@" target ":/"))]
   1.137 +
   1.138 +	    (map (partial str-join " ")
   1.139 +	    (reduce into
   1.140 +	    (filter
   1.141 +	     (comp not nil?)
   1.142 +	     [
   1.143 +	      (if u? (rsync target aurellem) nil)
   1.144 +	      (if k? (rsync target mit) nil)
   1.145 +	      (if l? (rsync target laserkard) nil)
   1.146 +	      (if m? (rsync target moonlitnights) nil)
   1.147 +	      (if j? (rsync target judyates) nil)
   1.148 +	      (if r? (rsync target rlmcintyre) nil)
   1.149 +	      (if b? (rsync target bortreb) nil)
   1.150 +	      (if c? (rsync target config) nil)
   1.151 +	      (if d? (rsync target admin) nil)
   1.152 +	      (if g? (rsync target genesis) nil)
   1.153 +	      (if p? (rsync target projects) nil)]))))))))
   1.154 +
   1.155 +(defn push [& args]
   1.156 +  (let [commands (apply push-gen args)]
   1.157 +    (if (not (nil? commands))
   1.158 +      (dorun (map sw commands)))))
   1.159 +
   1.160 +(if (command-line?)
   1.161 +  (apply push *command-line-args*))
   1.162 +
   1.163 +