File permissions
This commit is contained in:
parent
a4ebeaacae
commit
1a87b41140
@ -10,13 +10,30 @@
|
||||
:refer [log trace debug info warn error fatal report
|
||||
logf tracef debugf infof warnf errorf fatalf reportf
|
||||
spy get-env]])
|
||||
(:import (java.nio.file Files)))
|
||||
(:import (java.nio.file Files
|
||||
LinkOption)
|
||||
(java.nio.file.attribute PosixFileAttributeView)))
|
||||
|
||||
(def vault-client (vault/new-client "http://127.0.0.1:8200"))
|
||||
|
||||
;; # Webserver configuration
|
||||
|
||||
(defn- set-owner [path owner]
|
||||
(->
|
||||
(Files/getFileAttributeView path PosixFileAttributeView LinkOption/NOFOLLOW_LINKS)
|
||||
(.setOwner owner)))
|
||||
|
||||
(defn- set-group [path group]
|
||||
(->
|
||||
(Files/getFileAttributeView path PosixFileAttributeView LinkOption/NOFOLLOW_LINKS)
|
||||
(.setGroup group)))
|
||||
|
||||
(defn make-dirs! [{:keys [company-name]}]
|
||||
(let [attrs (Files/readAttributes (.toPath (io/file "srv/http/www.sompani.com"))
|
||||
PosixFileAttributeView
|
||||
LinkOption/NOFOLLOW_LINKS)
|
||||
group (.group attrs)
|
||||
owner (.owner attrs)]
|
||||
(doseq [dir-str ["/srv/http/staging.%s.talent.careers-cache"
|
||||
"/srv/http/staging.%s.talent.careers-logs"
|
||||
"/srv/http/staging.%s.talent.careers-sessions"
|
||||
@ -27,20 +44,24 @@
|
||||
"/srv/http/%s.talent.careers-sessions"
|
||||
"/srv/http/%s.talent.careers-uploads"
|
||||
"/srv/http/%s.talent.careers.1234"]
|
||||
:let [dir (.toPath (io/file dir-str))]]
|
||||
:let [dir (.toPath (io/file (format dir-str company-name)))]]
|
||||
(Files/createDirectory dir nil)
|
||||
;; (sh/sh "install" "-o" "http" "-g" "http" "-d" (format dir company-name) :dir "/srv/http")
|
||||
(set-owner dir owner)
|
||||
(set-group dir group)
|
||||
)
|
||||
(Files/createSymbolicLink (.toPath (io/file (format "/srv/http/staging.%s.talent.careers")))
|
||||
(.toPath (io/file (format "/srv/http/staging.%s.talent.careers-1234")))
|
||||
nil)
|
||||
(Files/createSymbolicLink (.toPath (io/file (format "/srv/http/%s.talent.careers")))
|
||||
(.toPath (io/file (format "/srv/http/%s.talent.careers-1234")))
|
||||
(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)
|
||||
(set-owner link owner)
|
||||
(set-group link group))
|
||||
|
||||
;; (debug (sh/sh "ln" "-s" "staging.%s.talent.careers.1234" "staging.%s.talent.careers" :dir "/srv/http"))
|
||||
;; (debug (sh/sh "ln" "-s" "%s.talent.careers.1234" "%s.talent.careers" :dir "/srv/http"))
|
||||
)
|
||||
(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)
|
||||
(set-owner link owner)
|
||||
(set-group link group))))
|
||||
|
||||
(defn create-nginx-server! [datamap]
|
||||
(doseq [file ["resources/nginx/skel.talent.careers"
|
||||
|
Loading…
Reference in New Issue
Block a user