From 88da901eddff125b3e71d9706fbe02edffc659b3 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Sat, 29 Jun 2019 15:36:01 -0600 Subject: [PATCH] ncp-update: fixes on the new step based upgrade system Signed-off-by: nachoparker --- changelog.md | 4 +- etc/library.sh | 10 ++--- run_update_history.sh | 14 +++--- update.sh | 6 ++- updates/{1.10.11.sh => 1.13.6.sh} | 75 ++++++++++++++++++++++++++++++- 5 files changed, 93 insertions(+), 16 deletions(-) mode change 100644 => 100755 run_update_history.sh rename updates/{1.10.11.sh => 1.13.6.sh} (67%) mode change 100755 => 100644 diff --git a/changelog.md b/changelog.md index 493b736d2..417c76ae5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ -[v1.13.5](https://github.com/nextcloud/nextcloudpi/commit/abba511) (2019-06-29) ncp-web: adjust ipv6 local restrictions +[v1.13.6](https://github.com/nextcloud/nextcloudpi/commit/0b77407) (2019-06-29) ncp-update: fixes on the new step based upgrade system + +[v1.13.5](https://github.com/nextcloud/nextcloudpi/commit/fbdab43) (2019-06-29) ncp-web: adjust ipv6 local restrictions [v1.13.4 ](https://github.com/nextcloud/nextcloudpi/commit/ce4477c) (2019-06-29) nc-previews: adjust preview sizes diff --git a/etc/library.sh b/etc/library.sh index ca73142fa..d2ec12b60 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -92,7 +92,7 @@ function configure_app() function run_app() { local ncp_app=$1 - local script="$(find "$BINDIR" -name $ncp_app.sh)" + local script="$(find "$BINDIR" -name $ncp_app.sh | head -1)" [[ -f "$script" ]] || { echo "file $script not found"; return 1; } @@ -147,7 +147,7 @@ function is_active_app() local script="$bin_dir/$ncp_app.sh" local cfg_file="$CFGDIR/$ncp_app.cfg" - [[ -f "$script" ]] || local script="$(find "$BINDIR" -name $ncp_app.sh)" + [[ -f "$script" ]] || local script="$(find "$BINDIR" -name $ncp_app.sh | head -1)" [[ -f "$script" ]] || { echo "file $script not found"; return 1; } # function @@ -194,7 +194,7 @@ function install_app() local script="$ncp_app" local ncp_app="$(basename "$script" .sh)" else - local script="$(find "$BINDIR" -name $ncp_app.sh)" + local script="$(find "$BINDIR" -name $ncp_app.sh | head -1)" fi # do it @@ -234,7 +234,7 @@ function is_more_recent_than() { local version_A="$1" local version_B="$2" - + local major_a=$( cut -d. -f1 <<<"$version_A" ) local minor_a=$( cut -d. -f2 <<<"$version_A" ) local patch_a=$( cut -d. -f3 <<<"$version_A" ) @@ -250,7 +250,7 @@ function is_more_recent_than() return 1 elif [ "$major_b" -eq "$major_a" ] && [ "$minor_b" -gt "$minor_a" ]; then return 1 - elif [ "$major_b" -eq "$major_a" ] && [ "$minor_b" -eq "$minor_a" ] && [ "$patch_b" -gt "$patch_a" ]; then + elif [ "$major_b" -eq "$major_a" ] && [ "$minor_b" -eq "$minor_a" ] && [ "$patch_b" -ge "$patch_a" ]; then return 1 fi diff --git a/run_update_history.sh b/run_update_history.sh old mode 100644 new mode 100755 index 0770a3b14..1b5558b04 --- a/run_update_history.sh +++ b/run_update_history.sh @@ -7,15 +7,15 @@ set -e source /usr/local/etc/library.sh # Updates folder contains the "history" of updates -updates="$1" -[ -d "$updates" ] || { echo "$updates does not exist. Abort" >&2; exit 1; } +updates_dir="$1" +[ -d "$updates_dir" ] || { echo "$updates_dir does not exist. Abort" >&2; exit 1; } # Get the array of updates dir # The files in updates dir are sorted by tag number # Files names follow the syntax of a tag: x.y.z.sh while read line ; do updates_list+=("$line") -done < <( ls -1 "$updates" | sort -V) +done < <( ls -1 "$updates_dir" | sort -V) starting_checkpoint=0 len=${#updates_list[@]} @@ -40,7 +40,7 @@ if is_more_recent_than "$latest_checkpoint_version" "$current_version" ; then # An update is *applicable* when it is more recent than the current version # An older update/checkpoint is not *applicable* to our system - + lower_bound=0 upper_bound=$end_of_list while [ $lower_bound -le $upper_bound ]; do @@ -97,12 +97,12 @@ if is_more_recent_than "$latest_checkpoint_version" "$current_version" ; then # Starting checkpoint has been found so update the system for the rest updates for(( i="$starting_checkpoint"; i<="$end_of_list"; i++)); do - update_file=${updates_list[i]} + update_file=${updates_list[$i]} tag_update=$( basename "$update_file" .sh ) echo -e "Updating system to version $tag_update . . ." - ./"$updates"/"$update_file" || exit 1 - echo -e "System updated successfully to version $tag_update" + bash "$updates_dir/$update_file" || exit 1 echo "v$tag_update" > /usr/local/etc/ncp-version + echo -e "System updated successfully to version v$tag_update" done fi diff --git a/update.sh b/update.sh index 07b0a82aa..4cd32684d 100755 --- a/update.sh +++ b/update.sh @@ -11,6 +11,7 @@ set -e CONFDIR=/usr/local/etc/ncp-config.d/ +UPDATESDIR=updates # don't make sense in a docker container EXCL_DOCKER=" @@ -49,8 +50,6 @@ cp etc/library.sh /usr/local/etc/ source /usr/local/etc/library.sh -./run_update_history.sh "updates" - mkdir -p "$CONFDIR" # prevent installing some ncp-apps in the docker version @@ -123,6 +122,9 @@ cp -r ncp-app /var/www/ # update services cp docker/{lamp/010lamp,nextcloud/020nextcloud,nextcloudpi/000ncp} /etc/services-enabled.d + # update old images + ./run_update_history.sh "$UPDATESDIR" + } exit 0 diff --git a/updates/1.10.11.sh b/updates/1.13.6.sh old mode 100755 new mode 100644 similarity index 67% rename from updates/1.10.11.sh rename to updates/1.13.6.sh index e074ad09c..0e9c49e49 --- a/updates/1.10.11.sh +++ b/updates/1.13.6.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + ## BACKWARD FIXES ( for older images ) source /usr/local/etc/library.sh @@ -24,6 +26,13 @@ EOF : } + # remove files that have been moved + rm -f "$BINDIR"/CONFIG/nc-notify-updates.sh + rm -f "$BINDIR"/TOOLS/nc-update-nc-apps.sh + rm -f "$BINDIR"/TOOLS/nc-update-nextcloud.sh + rm -f "$BINDIR"/TOOLS/nc-update.sh + rm -f "$BINDIR"/{SYSTEM/unattended-upgrades.sh,CONFIG/nc-autoupdate-nc.sh,CONFIG/nc-autoupdate-ncp.sh,CONFIG/nc-update-nc-apps-auto.sh} + # update to the latest version is_active_app nc-autoupdate-nc && run_app nc-autoupdate-nc @@ -48,7 +57,7 @@ EOF is_active_app nc-update-nc-apps-auto && run_app nc-update-nc-apps-auto # rework letsencrypt notification - USER="$(jq -r '.params[2].value' "$CONFDIR"/letsencrypt.cfg)" + USER="$(jq -r '.params[2].value' "$CFGDIR"/letsencrypt.cfg)" mkdir -p /etc/letsencrypt/renewal-hooks/deploy/ cat > /etc/letsencrypt/renewal-hooks/deploy/ncp < /etc/apache2/sites-available/ncp.conf < + DocumentRoot /var/www/ncp-web + SSLEngine on + SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem + SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key + + # 2 days to avoid very big backups requests to timeout + TimeOut 172800 + + + DefineExternalAuth pwauth pipe /usr/sbin/pwauth + + + + + + AuthType Basic + AuthName "ncp-web login" + AuthBasicProvider external + AuthExternal pwauth + + SetEnvIf Request_URI "^" noauth + SetEnvIf Request_URI "^index\.php$" !noauth + SetEnvIf Request_URI "^/$" !noauth + SetEnvIf Request_URI "^/wizard/index.php$" !noauth + SetEnvIf Request_URI "^/wizard/$" !noauth + + + + + Require host localhost + Require local + Require ip 192.168 + Require ip 172 + Require ip 10 + Require ip fd00::/8 + Require ip fe80::/10 + + + + Require env noauth + Require user ncp + + + + + +EOF + # remove redundant opcache configuration. Leave until update bug is fixed -> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815968 # Bug #416 reappeared after we moved to php7.2 and debian buster packages. (keep last) [[ "$( ls -l /etc/php/7.2/fpm/conf.d/*-opcache.ini | wc -l )" -gt 1 ]] && rm "$( ls /etc/php/7.2/fpm/conf.d/*-opcache.ini | tail -1 )" [[ "$( ls -l /etc/php/7.2/cli/conf.d/*-opcache.ini | wc -l )" -gt 1 ]] && rm "$( ls /etc/php/7.2/cli/conf.d/*-opcache.ini | tail -1 )" } # end - only live updates + +exit 0