Use java.nio to create/copy files

This commit is contained in:
Daniel Ziltener 2019-12-09 13:41:49 +01:00
parent f22e32c04d
commit a4ebeaacae
1 changed files with 27 additions and 14 deletions

View File

@ -1,5 +1,6 @@
(ns com.sompani.onboarding
(:require [clojure.java.shell :as sh]
[clojure.java.io :as io]
[clojure.string :as str]
[vault.core :as vault]
vault.client.http
@ -8,26 +9,38 @@
[taoensso.timbre :as timbre
:refer [log trace debug info warn error fatal report
logf tracef debugf infof warnf errorf fatalf reportf
spy get-env]]))
spy get-env]])
(:import (java.nio.file Files)))
(def vault-client (vault/new-client "http://127.0.0.1:8200"))
;; # Webserver configuration
(defn make-dirs! [{:keys [company-name]}]
(doseq [dir ["staging.%s.talent.careers-cache"
"staging.%s.talent.careers-logs"
"staging.%s.talent.careers-sessions"
"staging.%s.talent.careers-uploads"
"staging.%s.talent.careers.1234"
"%s.talent.careers-cache"
"%s.talent.careers-logs"
"%s.talent.careers-sessions"
"%s.talent.careers-uploads"
"%s.talent.careers.1234"]]
(sh/sh "install" "-o" "http" "-g" "http" "-d" (format dir company-name) :dir "/srv/http"))
(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")))
(doseq [dir-str ["/srv/http/staging.%s.talent.careers-cache"
"/srv/http/staging.%s.talent.careers-logs"
"/srv/http/staging.%s.talent.careers-sessions"
"/srv/http/staging.%s.talent.careers-uploads"
"/srv/http/staging.%s.talent.careers.1234"
"/srv/http/%s.talent.careers-cache"
"/srv/http/%s.talent.careers-logs"
"/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))]]
(Files/createDirectory dir nil)
;; (sh/sh "install" "-o" "http" "-g" "http" "-d" (format dir company-name) :dir "/srv/http")
)
(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")))
nil)
;; (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"))
)
(defn create-nginx-server! [datamap]
(doseq [file ["resources/nginx/skel.talent.careers"