Browse Source

Update post-receive hook script

bryan 5 years ago
parent
commit
03b1610cfd

+ 14 - 10
scripts/_var_lib_git_gogs-repositories_bryan_www.git_hooks_post-receive.sh

@@ -4,11 +4,11 @@
 GIT_DIR="$(pwd)"
 TMP_GIT_DIR="/tmp/${GIT_DIR##*/}"
 
-if [ ! -d "${TMP_GIT_DIR}" ]; then
+if [[ ! -d "${TMP_GIT_DIR}" ]]; then
     git clone "${GIT_DIR}" "${TMP_GIT_DIR}"
-    cd "${TMP_GIT_DIR}"
+    cd "${TMP_GIT_DIR}" || exit $?
 else
-    cd "${TMP_GIT_DIR}"
+    cd "${TMP_GIT_DIR}" || exit $?
     unset GIT_DIR
     git fetch --all
     git reset --hard origin/master
@@ -16,12 +16,16 @@ else
 fi
 
 for site in *.*/; do
-  [ ! -d /var/www/${site} ] && mkdir -p /var/www/${site} && chgrp -R /var/www/${site} && chmod g+s /var/www/${site}
-  pushd ${site}
-  bundle install --deployment
-  bundle exec jekyll build --destination /var/www/${site}
-  popd
+    deploy_dir="/var/www/${site}"
+    if [[ ! -d "$deploy_dir" ]]; then
+        mkdir -p "$deploy_dir"
+        chgrp -R "$deploy_dir"
+        chmod g+s "$deploy_dir"
+    fi
+    pushd "${site}" || exit $?
+    bundle install --deployment
+    bundle exec jekyll build --destination "$deploy_dir"
+    popd || exit $?
 done
 
-
-exit
+exit 0