From f9cfdecf2f61bc1acc1b7bd94c54fb116549898e Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 5 Aug 2024 18:03:37 -0400 Subject: [PATCH] improved update script --- python_file_hack.sh | 31 ++++++++++++++----------------- update.sh | 2 +- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/python_file_hack.sh b/python_file_hack.sh index 8ed9158..f4a0618 100755 --- a/python_file_hack.sh +++ b/python_file_hack.sh @@ -1,32 +1,29 @@ #!/bin/bash set -e - -update_file() { - local file="$1" - local search="$2" - local replace="$3" - local additional="$4" - - if grep -qF "$search" "$file"; then - sed -ri "/$search/,+$additional c $replace" "$file" - else - echo "Unable to find the text $search in $file, update python_file_hack.sh" - exit 1 - fi -} - # this is a hack to overwrite Django's broken TZ stuff that causes errors (500 page) to fail. See https://code.djangoproject.com/ticket/33674 + FILE="/usr/local/lib/python3.11/site-packages/django/templatetags/tz.py" SEARCH=" with timezone.override(self.tz.resolve(context)):" REPLACE="\ try:\n with timezone.override(self.tz.resolve(context)):\n output = self.nodelist.render(context)\n return output\n except:\n return self.nodelist.render(context)" -update_file "$FILE" "$SEARCH" "$REPLACE" "2" +if grep -qF "$SEARCH" "$FILE"; then + sed -i "/$SEARCH/,+2 c $REPLACE" "$FILE" +else + echo "Unable to find the text $SEARCH in $FILE, update or remove fix_tz_hack.sh" + exit 1 +fi # Reportlab causes certain label settings to throw an error # https://github.com/virantha/pypdfocr/issues/80 FILE="/usr/local/lib/python3.11/site-packages/reportlab/platypus/paragraph.py" SEARCH=" if availWidth<_FUZZ:" REPLACE="\ # removed\n" -update_file "$FILE" "$SEARCH" "$REPLACE" "2" + +if grep -qF "$SEARCH" "$FILE"; then + sed -i "/$SEARCH/,+2 c $REPLACE" "$FILE" +else + echo "Unable to find the text $SEARCH in $FILE, update or remove fix_tz_hack.sh" + exit 1 +fi diff --git a/update.sh b/update.sh index f8a11b3..eab0824 100755 --- a/update.sh +++ b/update.sh @@ -34,4 +34,4 @@ fi sed -i "s/server_name _;/server_name $SITE_DOMAIN;/" "./nginx.prod.conf" docker compose build -docker compose up -d \ No newline at end of file +docker compose restart -d \ No newline at end of file