view 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 source
1 ":";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 $*;
5 (ns rlm.push
6 (:gen-class
7 :name rlm.push
8 :main true)
9 (:use [clojure.contrib
10 [duck-streams :only [file-str]]
11 command-line str-utils shell-out]
12 [rlm shell-write
13 [shell-inspect :only [command-line?]]]))
16 (def laserkard ["/home/r/Desktop/web/laserkard"
17 "/home/r/lasercutter"
18 "/home/r/laser-files"
19 "/home/r/emc2"])
21 (def moonlitnights ["/home/r/Desktop/web/moonlitnights"])
23 (def judyates ["/home/r/Desktop/web/judyates"])
25 (def rlmcintyre ["/home/r/Desktop/web/rlmcintyre",
26 "/home/r/Desktop/web/boosterpack"
27 "/home/r/Desktop/web/lib"])
29 (def bortreb ["/home/r/Desktop/web/bortreb"])
31 (def aurellem ["/home/r/aurellem/site-output"])
33 (def mit ["/home/r/Desktop/MIT"])
36 (def config
37 ["/home/r/.swank-all-repl"
38 "/home/r/.clojure_completions"
39 "/home/r/swank-all"
40 "/home/r/Desktop/web/web.clj"
41 "/etc/lighttpd/lighttpd.conf"
42 "/home/r/.lightpasswords"
43 "/home/r/.profile"
44 "/home/r/.xmodmap.clojure"
45 "/home/r/.xmodmap.xmonad"
46 "/home/r/.xmodmap.normal"
47 "/etc/hosts"
48 "/home/r/Desktop/web/swank-web"
49 "/etc/mercurial/hgrc"
50 "/home/r/.hgrc"
51 "/home/r/.emacs"
52 "/home/r/.emacs.d"
53 "/home/r/.bashrc"
54 "/home/r/.el"
55 "/home/r/.blender"
56 ])
59 (def admin
60 ["/home/r/Desktop/sliceHost_Admin"
61 "/home/r/Desktop/judyates_admin"
62 "/home/r/Desktop/laserkard_admin"
63 "/home/r/Desktop/moonlitnights_admin"])
65 (def genesis
66 [;;"/home/r/Desktop/GenesisOutput"
67 "/home/r/Jake2"
68 ;;"/home/r/workspace" --- removed because it interferes with eclipse's
69 ;; color settings. Stupid eclipse.
70 "/home/r/Genesis"
71 ;;"/home/r/eclipse" --- also interfers with eclipse's stupid colors.
72 ;;"/home/r/telmo"
73 ;;"/home/r/sajit"
74 ])
76 (def projects
77 ["/home/r/aurellem"
78 "/home/r/cortex"
79 "/home/r/mobius"
80 "/home/r/roBin"
81 "/home/r/openal-soft"
82 "/home/r/Desktop/web"])
84 (defn rsync-string [#^java.io.File file]
85 (if (.isFile file)
86 (.getPath file)
87 (str (.getPath file) "/")))
90 (defn rsync-one [destination #^java.io.File file]
91 (let
92 [command
93 ["rsync" "-avzhO" "--delete" "--relative" (str "/." (rsync-string file)) destination ]]
94 (println command)
95 ;(apply sw command)
96 command
97 ))
100 (defn rsync [destination args]
101 (doall (map (partial rsync-one destination) (map file-str args))))
103 (def destinations {"slice" "r@173.203.202.72:/"
104 "rlm" "r@10.0.0.2:/"
105 "sphere" "/home/r/sphere"
106 })
110 (defn push-gen [& args]
111 (with-command-line args
112 "Push Files from this Computer to others."
113 [[all? a? "Update everything. (except genesis and admin)" false]
114 [l? laserkard? "laserkard source" false]
115 [m? moonlitnights? "moonlitnights source" false]
116 [j? judyates? "judyates source" false]
117 [r? rlmcintyre? "rlmcintyre source" false]
118 [b? bortreb? "bortreb repository source" false]
119 [c? config? "webserver config files" false]
120 [d? admin? "website admin folders" false]
121 [g? genesis? "genesis" false]
122 [p? projects? "roBin, aurellem, mobius" false]
123 [e? everything? "absolutely everything" false]
124 [k? mit? "MIT" false]
125 [u? aurellem? "aurellem SITE"]
126 [target t
127 (str "Target computer. mappings are " destinations " or any ipv4 ip address")
128 "rlm"]]
130 (if e? (into (push-gen "-g" "-d" "-k" "-t" target) (push-gen "-a" "-t" target))
131 (if all?
132 (push-gen "-l" "-m" "-j" "-r" "-b" "-c" "-p" "-u" "-t" target)
133 (let [target (get destinations target (str "r@" target ":/"))]
135 (map (partial str-join " ")
136 (reduce into
137 (filter
138 (comp not nil?)
139 [
140 (if u? (rsync target aurellem) nil)
141 (if k? (rsync target mit) nil)
142 (if l? (rsync target laserkard) nil)
143 (if m? (rsync target moonlitnights) nil)
144 (if j? (rsync target judyates) nil)
145 (if r? (rsync target rlmcintyre) nil)
146 (if b? (rsync target bortreb) nil)
147 (if c? (rsync target config) nil)
148 (if d? (rsync target admin) nil)
149 (if g? (rsync target genesis) nil)
150 (if p? (rsync target projects) nil)]))))))))
152 (defn push [& args]
153 (let [commands (apply push-gen args)]
154 (if (not (nil? commands))
155 (dorun (map sw commands)))))
157 (if (command-line?)
158 (apply push *command-line-args*))