diff --git a/install.sh b/install.sh index 3886463..10525ef 100755 --- a/install.sh +++ b/install.sh @@ -8,6 +8,7 @@ fi source "$(dirname $0)/install/_lib.sh" # does a `cd .../install/`, among other things source parse-cli.sh +source check-latest-commit.sh source error-handling.sh source check-minimum-requirements.sh source create-docker-volumes.sh diff --git a/install/check-latest-commit.sh b/install/check-latest-commit.sh new file mode 100644 index 0000000..003639e --- /dev/null +++ b/install/check-latest-commit.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Checks if we are on latest commit from github if it is running from master branch +if [[ -d "../.git" && "${SKIP_COMMIT_CHECK:-0}" != 1 ]]; then + if [[ $(git branch | sed -n '/\* /s///p') == "master" ]]; then + if [[ $(git rev-parse HEAD) != $(git ls-remote $(git rev-parse --abbrev-ref @{u} | sed 's/\// /g') | cut -f1) ]]; then + echo "Seems like you are not using the latest commit from self-hosted repository. Please pull the latest changes and try again."; + exit 1 + fi + fi +fi diff --git a/install/parse-cli.sh b/install/parse-cli.sh index cf4c391..9492a89 100644 --- a/install/parse-cli.sh +++ b/install/parse-cli.sh @@ -17,12 +17,14 @@ EOF SKIP_USER_PROMPT="${SKIP_USER_PROMPT:-}" MINIMIZE_DOWNTIME="${MINIMIZE_DOWNTIME:-}" +SKIP_COMMIT_CHECK="${SKIP_COMMIT_CHECK:-}" while (( $# )); do case "$1" in -h | --help) show_help; exit;; --no-user-prompt) SKIP_USER_PROMPT=1;; --minimize-downtime) MINIMIZE_DOWNTIME=1;; + --skip-commit-check) SKIP_COMMIT_CHECK=1;; --) ;; *) echo "Unexpected argument: $1. Use --help for usage information."; exit 1;; esac