From 61b28985bb7002e6187a9e7419e4dc19a438e6e7 Mon Sep 17 00:00:00 2001
From: Michel Memeteau <mm@ekimia.fr>
Date: Fri, 3 Apr 2020 13:38:53 +0200
Subject: [PATCH] export admin email ( default in etc env )

---
 install.linux.sh |  8 +++++++-
 utils/provision  | 19 ++++++++++++-------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/install.linux.sh b/install.linux.sh
index 8b5051d..381fcc2 100755
--- a/install.linux.sh
+++ b/install.linux.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 #Current version of libre.sh to be installed 
-LIBRE_VERSION=187-repo-mode-to-retrieve-application-recipe
+LIBRE_VERSION=develop
 # System env vars  : can be overrided by a values.env file next to this install file
 
 
@@ -52,6 +52,10 @@ MAIL_PASS=
 MAIL_HOST=mail.indie.host
 MAIL_PORT=587
 
+# Default admin emails for apps
+
+ADMIN_EMAIL=support@ekimia.fr
+
 ### TODO : source a setting file is present to override defaults
 
 echo "-------- Welcome to libre.sh $LIBRE_VERSION installer"
@@ -79,6 +83,8 @@ echo "MAIL_HOST=${MAIL_HOST}" >> /etc/environment
 
 echo "MAIL_PORT=${MAIL_PORT}" >> /etc/environment
 
+echo "ADMIN_EMAIL=${ADMIN_EMAIL}" >> /etc/environment
+
 
 # STEP Install Docker 
 
diff --git a/utils/provision b/utils/provision
index af27200..b54d766 100755
--- a/utils/provision
+++ b/utils/provision
@@ -28,6 +28,7 @@ read -r -d '' usage <<-'EOF'
   -u   [arg] URL to process. Required.
   -a   [arg] Application to install. (in the form github.com/indiehosters/wordpress or wordpress in REPO_MODE)
   -t   [arg] Checkout a specific tag or branch from the application repo. default to master
+  -e   [arg] Specify the email of the application admin 
   -s         Start the application right away.
   -b         Buys the associated domain name.
   -i         Configure OpenDKIM.
@@ -117,18 +118,21 @@ function application () {
   
   #Define the tag/branch 
   
-  if [ "${arg_t}" = "1" ]; then
-    warning "No tag/branch specified, Using master "
-    git_tag=master
-  else
-    git_tag=${arg_t}
-  fi
   git clone ${git_url} -b ${arg_t} /data/domains/${arg_u} 
 
   cd /data/domains/${arg_u}
   
   if [ -f ./scripts/install ]; then
-    export URL=${arg_u}
+    #domain
+    export URL=${arg_u} 
+    #admin email
+    if [ -z "${arg_e}" ]; then
+      warning "No admin_email specified with -e , using default hoster email"
+    else
+      export ADMIN_EMAIL=${arg_e}
+      debug " admin email is ${ADMIN_EMAIL} "
+    fi
+
     if [ -z ${MAIL_DOMAIN:-} ]; then
       warning "you have no email server setup, we'll print a random configuration in your application. Make sure to check the parameters for your app to send proper emails."
       warning "To stop having this warning, please configure your libre.sh to be abble to create email accounts."
@@ -148,6 +152,7 @@ function application () {
   fi
 }
 
+
 function start () {
   systemctl start u@${arg_u}
   systemctl enable u@${arg_u}
-- 
GitLab