From bc115dada3a2a470911a63bd86a0bffb9e30ae73 Mon Sep 17 00:00:00 2001 From: Geoffrey Roberts Date: Tue, 20 Nov 2018 14:03:04 +1100 Subject: [PATCH 1/6] Initial pass at separating locks and temp dirs by project --- functions.sh | 5 +++-- letsencrypt_drupal.sh | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/functions.sh b/functions.sh index 6ce72d0..8f95e2c 100644 --- a/functions.sh +++ b/functions.sh @@ -1,18 +1,19 @@ #!/usr/bin/env bash CERT_DIR=~/.letsencrypt_drupal -TMP_DIR=/tmp/letsencrypt_drupal +TMP_DIR=/tmp/letsencrypt_drupal/$PROJECT_NAME FILE_BASECONFIG=${TMP_DIR}/baseconfig FILE_DRUSH_ALIAS=${TMP_DIR}/drush_alias FILE_DRUPAL_VERSION=${TMP_DIR}/drupal_version FILE_PROJECT_ROOT=${TMP_DIR}/project_root +LOCK_FILENAME=/tmp/cert_renew_lock_${PROJECT_NAME} #--------------------------------------------------------------------- acquire_lock_or_exit() { # Check we are not running already: http://mywiki.wooledge.org/BashFAQ/045 # @ToDo: Platform specific lock. - exec 8>/tmp/cert_renew_lock + exec 8>${LOCK_FILENAME} if ! flock -n 8 ; then logline "Another instance of this script running."; exit 1 diff --git a/letsencrypt_drupal.sh b/letsencrypt_drupal.sh index ab383dd..0b1f9b9 100755 --- a/letsencrypt_drupal.sh +++ b/letsencrypt_drupal.sh @@ -18,6 +18,9 @@ DRUPAL_VERSION="$2" PROJECT_ROOT="$3" DRUSH_ALIAS_NO_AT="${DRUSH_ALIAS/@/}" +PROJECT_NAME=$(echo "$DRUSH_ALIAS_NO_AT" | cut -d'.' -f1) +PROJECT_ENV=$(echo "$DRUSH_ALIAS_NO_AT" | cut -d'.' -f2) + CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DEHYDRATED="https://github.com/lukas2511/dehydrated.git" From f1d2eedcf05d0b2b0218b4852c14fceeca2c6f62 Mon Sep 17 00:00:00 2001 From: Geoffrey Roberts Date: Tue, 20 Nov 2018 14:04:00 +1100 Subject: [PATCH 2/6] Remove todo because that's what we're addressing --- functions.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions.sh b/functions.sh index 8f95e2c..20b0dd6 100644 --- a/functions.sh +++ b/functions.sh @@ -12,7 +12,6 @@ LOCK_FILENAME=/tmp/cert_renew_lock_${PROJECT_NAME} acquire_lock_or_exit() { # Check we are not running already: http://mywiki.wooledge.org/BashFAQ/045 - # @ToDo: Platform specific lock. exec 8>${LOCK_FILENAME} if ! flock -n 8 ; then logline "Another instance of this script running."; From fbe138e6012d99c6a02f6cc2044902e7bb1e8739 Mon Sep 17 00:00:00 2001 From: Geoffrey Roberts Date: Tue, 20 Nov 2018 14:12:37 +1100 Subject: [PATCH 3/6] Each folder must belong to their own user, so we can't do subdirs --- functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index 20b0dd6..68386f5 100644 --- a/functions.sh +++ b/functions.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash CERT_DIR=~/.letsencrypt_drupal -TMP_DIR=/tmp/letsencrypt_drupal/$PROJECT_NAME +TMP_DIR=/tmp/letsencrypt_drupal_$PROJECT_NAME FILE_BASECONFIG=${TMP_DIR}/baseconfig FILE_DRUSH_ALIAS=${TMP_DIR}/drush_alias FILE_DRUPAL_VERSION=${TMP_DIR}/drupal_version From 52d7036028693667bdc93b055a49af2d216f9489 Mon Sep 17 00:00:00 2001 From: Geoffrey Roberts Date: Tue, 20 Nov 2018 14:14:49 +1100 Subject: [PATCH 4/6] Fiddling directory names --- functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index 68386f5..a78f40f 100644 --- a/functions.sh +++ b/functions.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash CERT_DIR=~/.letsencrypt_drupal -TMP_DIR=/tmp/letsencrypt_drupal_$PROJECT_NAME +TMP_DIR=/tmp/letsencrypt_drupal_${PROJECT_NAME} FILE_BASECONFIG=${TMP_DIR}/baseconfig FILE_DRUSH_ALIAS=${TMP_DIR}/drush_alias FILE_DRUPAL_VERSION=${TMP_DIR}/drupal_version From defe1321dbf8a0d3a86a58f953d63832a24585a8 Mon Sep 17 00:00:00 2001 From: Geoffrey Roberts Date: Tue, 20 Nov 2018 14:19:04 +1100 Subject: [PATCH 5/6] Export project name and env for functions.sh --- letsencrypt_drupal.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/letsencrypt_drupal.sh b/letsencrypt_drupal.sh index 0b1f9b9..fbab292 100755 --- a/letsencrypt_drupal.sh +++ b/letsencrypt_drupal.sh @@ -18,8 +18,10 @@ DRUPAL_VERSION="$2" PROJECT_ROOT="$3" DRUSH_ALIAS_NO_AT="${DRUSH_ALIAS/@/}" -PROJECT_NAME=$(echo "$DRUSH_ALIAS_NO_AT" | cut -d'.' -f1) -PROJECT_ENV=$(echo "$DRUSH_ALIAS_NO_AT" | cut -d'.' -f2) + +# We need to export these variables so functions.sh can use them. +export PROJECT_NAME=$(echo "$DRUSH_ALIAS_NO_AT" | cut -d'.' -f1) +export PROJECT_ENV=$(echo "$DRUSH_ALIAS_NO_AT" | cut -d'.' -f2) CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DEHYDRATED="https://github.com/lukas2511/dehydrated.git" From 6a83cb3ee9ad90afca11ec84ab589e9cb79e3019 Mon Sep 17 00:00:00 2001 From: Geoffrey Roberts Date: Thu, 6 Feb 2020 16:18:24 +1100 Subject: [PATCH 6/6] Update Dehydrated repo, add extra switches prop --- letsencrypt_drupal.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/letsencrypt_drupal.sh b/letsencrypt_drupal.sh index ab383dd..7ec728d 100755 --- a/letsencrypt_drupal.sh +++ b/letsencrypt_drupal.sh @@ -11,15 +11,18 @@ # ** 7|8 # * Path to project root # ** Must contain letsencrypt_drupal folder. See readme. +# * Switches for Dehydrated +# ** Pass through these command line args to Dehydrated. OK if blank. # Basic variables. DRUSH_ALIAS="$1" DRUPAL_VERSION="$2" PROJECT_ROOT="$3" +DEHYDRATED_SWITCHES="$4" DRUSH_ALIAS_NO_AT="${DRUSH_ALIAS/@/}" CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -DEHYDRATED="https://github.com/lukas2511/dehydrated.git" +DEHYDRATED="https://github.com/dehydrated-io/dehydrated.git" FILE_DOMAINSTXT=${PROJECT_ROOT}/letsencrypt_drupal/domains_${DRUSH_ALIAS_NO_AT}.txt FILE_CONFIG=${PROJECT_ROOT}/letsencrypt_drupal @@ -102,7 +105,7 @@ main() { echo ${DRUPAL_VERSION} > ${FILE_DRUPAL_VERSION} echo ${PROJECT_ROOT} > ${FILE_PROJECT_ROOT} - ${CURRENT_DIR}/dehydrated/dehydrated --config ${FILE_BASECONFIG} --cron --accept-terms + ${CURRENT_DIR}/dehydrated/dehydrated --config ${FILE_BASECONFIG} --cron --accept-terms ${DEHYDRATED_SWITCHES} } self_update