Working dir, dns and nginx creation
This commit is contained in:
parent
77c588b487
commit
8c776921ee
|
@ -12,7 +12,8 @@
|
|||
spy get-env]])
|
||||
(:import (java.nio.file Files
|
||||
LinkOption)
|
||||
(java.nio.file.attribute PosixFileAttributeView)))
|
||||
(java.nio.file.attribute PosixFileAttributeView
|
||||
FileAttribute)))
|
||||
|
||||
(def vault-client (vault/new-client "http://127.0.0.1:8200"))
|
||||
|
||||
|
@ -29,11 +30,12 @@
|
|||
(.setGroup group)))
|
||||
|
||||
(defn make-dirs! [{:keys [company-name]}]
|
||||
(let [attrs (Files/readAttributes (.toPath (io/file "srv/http/www.sompani.com"))
|
||||
PosixFileAttributeView
|
||||
(into-array LinkOption [LinkOption/NOFOLLOW_LINKS]))
|
||||
group (.group attrs)
|
||||
owner (.owner attrs)]
|
||||
(let [attrs (Files/getFileAttributeView (.toPath (io/file "/srv/http/www.sompani.com"))
|
||||
PosixFileAttributeView
|
||||
(into-array LinkOption [LinkOption/NOFOLLOW_LINKS]))
|
||||
;; group (.group attrs)
|
||||
owner (.getOwner attrs)
|
||||
fattr (into-array FileAttribute [])]
|
||||
(doseq [dir-str ["/srv/http/staging.%s.talent.careers-cache"
|
||||
"/srv/http/staging.%s.talent.careers-logs"
|
||||
"/srv/http/staging.%s.talent.careers-sessions"
|
||||
|
@ -45,30 +47,33 @@
|
|||
"/srv/http/%s.talent.careers-uploads"
|
||||
"/srv/http/%s.talent.careers.1234"]
|
||||
:let [dir (.toPath (io/file (format dir-str company-name)))]]
|
||||
(Files/createDirectory dir nil)
|
||||
(Files/createDirectory dir fattr)
|
||||
(set-owner dir owner)
|
||||
(set-group dir group)
|
||||
;; (set-group dir group)
|
||||
)
|
||||
(let [link (.toPath (io/file (format "/srv/http/staging.%s.talent.careers" company-name)))]
|
||||
(Files/createSymbolicLink link
|
||||
(.toPath (io/file (format "/srv/http/staging.%s.talent.careers-1234" company-name)))
|
||||
nil)
|
||||
fattr)
|
||||
(set-owner link owner)
|
||||
(set-group link group))
|
||||
;; (set-group link group)
|
||||
)
|
||||
|
||||
(let [link (.toPath (io/file (format "/srv/http/%s.talent.careers" company-name)))]
|
||||
(Files/createSymbolicLink link
|
||||
(.toPath (io/file (format "/srv/http/%s.talent.careers-1234" company-name)))
|
||||
nil)
|
||||
fattr)
|
||||
(set-owner link owner)
|
||||
(set-group link group))))
|
||||
;; (set-group link group)
|
||||
)))
|
||||
|
||||
(defn create-nginx-server! [datamap]
|
||||
(doseq [file ["resources/nginx/skel.talent.careers"
|
||||
"resources/nginx/staging.skel.talent.careers"]
|
||||
:let [out-file (format "/etc/nginx/servers-available/%s" (str/replace file #"skel" (:company-name datamap)))]]
|
||||
(info "using template" file "to create" out-file)
|
||||
(-> (slurp file)
|
||||
(doseq [file ["skel.talent.careers"
|
||||
"staging.skel.talent.careers"]
|
||||
:let [in-file (str "resources/nginx/" file)
|
||||
out-file (format "/etc/nginx/servers-available/%s" (str/replace file #"skel" (:company-name datamap)))]]
|
||||
(info "using template" in-file "to create" out-file)
|
||||
(-> (slurp in-file)
|
||||
(cljstache/render datamap)
|
||||
(spit out-file))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue