diff --git a/easyinstall.sh b/easyinstall.sh index effe3f7c..14494628 100755 --- a/easyinstall.sh +++ b/easyinstall.sh @@ -222,6 +222,15 @@ function stopOldWebInterface() { # Checks for upstream changes to the git repo and fast-forwards changes if needed function updateRaScsiGit() { cd "$BASE" || exit 1 + + set +e + git rev-parse --is-inside-work-tree &> /dev/null + if [[ $? -ge 1 ]]; then + echo "Warning: This does not seem to be a valid clone of a git repository. I will not be able to pull the latest code." + return 0 + fi + set -e + stashed=0 if [[ $(git diff --stat) != '' ]]; then echo "There are local changes to the RaSCSI code; we will stash and reapply them." diff --git a/src/oled_monitor/start.sh b/src/oled_monitor/start.sh index 2b4dac19..5e58754d 100755 --- a/src/oled_monitor/start.sh +++ b/src/oled_monitor/start.sh @@ -77,28 +77,34 @@ fi # Create the venv if it doesn't exist if ! test -e venv; then - echo "Creating python venv for OLED Screen" - python3 -m venv venv - echo "Activating venv" - source venv/bin/activate - echo "Installing requirements.txt" - pip3 install wheel - CFLAGS="$COMPILER_FLAGS" pip3 install -r requirements.txt - git rev-parse HEAD > current + echo "Creating python venv for OLED Screen" + python3 -m venv venv + echo "Activating venv" + source venv/bin/activate + echo "Installing requirements.txt" + pip3 install wheel + CFLAGS="$COMPILER_FLAGS" pip3 install -r requirements.txt + git rev-parse HEAD > current fi source venv/bin/activate -# Detect if someone updates - we need to re-run pip3 install. -if ! test -e current; then - git rev-parse > current +# Detect if someone updates the git repo - we need to re-run pip3 install. +set +e +git rev-parse --is-inside-work-tree &> /dev/null +if [[ $? -eq 0 ]]; then + set -e + if ! test -e current; then + git rev-parse > current + elif [ "$(cat current)" != "$(git rev-parse HEAD)" ]; then + echo "New version detected, updating libraries from requirements.txt" + CFLAGS="$COMPILER_FLAGS" pip3 install -r requirements.txt + git rev-parse HEAD > current + fi else - if [ "$(cat current)" != "$(git rev-parse HEAD)" ]; then - echo "New version detected, updating requirements.txt" - CFLAGS="$COMPILER_FLAGS" pip3 install -r requirements.txt - git rev-parse HEAD > current - fi + echo "Warning: Not running from a valid git repository. Will not be able to update the code." fi +set -e # parse arguments while [ "$1" != "" ]; do diff --git a/src/web/start.sh b/src/web/start.sh index 36b2a94c..cbc52f21 100755 --- a/src/web/start.sh +++ b/src/web/start.sh @@ -57,16 +57,22 @@ fi source venv/bin/activate -# Detect if someone updates - we need to re-run pip3 install. -if ! test -e current; then - git rev-parse > current -else - if [ "$(cat current)" != "$(git rev-parse HEAD)" ]; then - echo "New version detected, updating requirements.txt" +# Detect if someone updates the git repo - we need to re-run pip3 install. +set +e +git rev-parse --is-inside-work-tree &> /dev/null +if [[ $? -eq 0 ]]; then + set -e + if ! test -e current; then + git rev-parse > current + elif [ "$(cat current)" != "$(git rev-parse HEAD)" ]; then + echo "New version detected, updating libraries from requirements.txt" pip3 install -r requirements.txt git rev-parse HEAD > current fi +else + echo "Warning: Not running from a valid git repository. Will not be able to update the code." fi +set -e # parse arguments while [ "$1" != "" ]; do