move link functionality into utils as a sh function

This commit is contained in:
Damian Silbergleith Cunniff 2019-05-24 19:43:57 -07:00
parent caae172589
commit 67821fcc0d
3 changed files with 22 additions and 15 deletions

View File

@ -7,6 +7,9 @@ trap "kill 0" EXIT
# Source in util.sh so we can have our nice tools # Source in util.sh so we can have our nice tools
. $(cd $(dirname $0); pwd)/util.sh . $(cd $(dirname $0); pwd)/util.sh
# first include any user configs if they've been mounted
link_user_configs
# Immediately run auto_enable_configs so that nginx is in a runnable state # Immediately run auto_enable_configs so that nginx is in a runnable state
auto_enable_configs auto_enable_configs

View File

@ -1,15 +0,0 @@
#!/bin/sh
SOURCE_DIR=/etc/nginx/user.conf.d
TARGET_DIR=/etc/nginx/conf.d
echo "symlinking scripts from ${SOURCE_DIR} to ${TARGET_DIR}"
if [ ! -d "$SOURCE_DIR" ]; then
echo "no ${SOURCE_DIR}, nothing to do."
else
for conf in ${SOURCE_DIR}/*.conf; do
echo "symlinking: ${conf}" "${TARGET_DIR}/$(basename ${conf})"
ln -s "${conf}" "${TARGET_DIR}/$(basename ${conf})"
done
fi

View File

@ -91,3 +91,22 @@ is_renewal_required() {
is_finshed_week_sec=$(( ($one_week_sec - $last_renewal_delta_sec) )) is_finshed_week_sec=$(( ($one_week_sec - $last_renewal_delta_sec) ))
[ $is_finshed_week_sec -lt 0 ] [ $is_finshed_week_sec -lt 0 ]
} }
# symlinks any *.conf files in /etc/nginx/user.conf.d
# to /etc/nginx/conf.d so they are included as configs
# this allows a user to easily mount their own configs
link_user_configs() {
SOURCE_DIR=${1-/etc/nginx/user.conf.d}
TARGET_DIR=${2-/etc/nginx/conf.d}
echo "symlinking scripts from ${SOURCE_DIR} to ${TARGET_DIR}"
if [ ! -d "$SOURCE_DIR" ]; then
echo "no ${SOURCE_DIR}, nothing to do."
else
for conf in ${SOURCE_DIR}/*.conf; do
echo "symlinking: ${conf}" "${TARGET_DIR}/$(basename ${conf})"
ln -s "${conf}" "${TARGET_DIR}/$(basename ${conf})"
done
fi
}