Skip to content

Commit 88da901

Browse files
committed
ncp-update: fixes on the new step based upgrade system
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent 2aa28d2 commit 88da901

File tree

5 files changed

+93
-16
lines changed

5 files changed

+93
-16
lines changed

changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
[v1.13.5](https://github.com/nextcloud/nextcloudpi/commit/abba511) (2019-06-29) ncp-web: adjust ipv6 local restrictions
2+
[v1.13.6](https://github.com/nextcloud/nextcloudpi/commit/0b77407) (2019-06-29) ncp-update: fixes on the new step based upgrade system
3+
4+
[v1.13.5](https://github.com/nextcloud/nextcloudpi/commit/fbdab43) (2019-06-29) ncp-web: adjust ipv6 local restrictions
35

46
[v1.13.4 ](https://github.com/nextcloud/nextcloudpi/commit/ce4477c) (2019-06-29) nc-previews: adjust preview sizes
57

etc/library.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function configure_app()
9292
function run_app()
9393
{
9494
local ncp_app=$1
95-
local script="$(find "$BINDIR" -name $ncp_app.sh)"
95+
local script="$(find "$BINDIR" -name $ncp_app.sh | head -1)"
9696

9797
[[ -f "$script" ]] || { echo "file $script not found"; return 1; }
9898

@@ -147,7 +147,7 @@ function is_active_app()
147147
local script="$bin_dir/$ncp_app.sh"
148148
local cfg_file="$CFGDIR/$ncp_app.cfg"
149149

150-
[[ -f "$script" ]] || local script="$(find "$BINDIR" -name $ncp_app.sh)"
150+
[[ -f "$script" ]] || local script="$(find "$BINDIR" -name $ncp_app.sh | head -1)"
151151
[[ -f "$script" ]] || { echo "file $script not found"; return 1; }
152152

153153
# function
@@ -194,7 +194,7 @@ function install_app()
194194
local script="$ncp_app"
195195
local ncp_app="$(basename "$script" .sh)"
196196
else
197-
local script="$(find "$BINDIR" -name $ncp_app.sh)"
197+
local script="$(find "$BINDIR" -name $ncp_app.sh | head -1)"
198198
fi
199199

200200
# do it
@@ -234,7 +234,7 @@ function is_more_recent_than()
234234
{
235235
local version_A="$1"
236236
local version_B="$2"
237-
237+
238238
local major_a=$( cut -d. -f1 <<<"$version_A" )
239239
local minor_a=$( cut -d. -f2 <<<"$version_A" )
240240
local patch_a=$( cut -d. -f3 <<<"$version_A" )
@@ -250,7 +250,7 @@ function is_more_recent_than()
250250
return 1
251251
elif [ "$major_b" -eq "$major_a" ] && [ "$minor_b" -gt "$minor_a" ]; then
252252
return 1
253-
elif [ "$major_b" -eq "$major_a" ] && [ "$minor_b" -eq "$minor_a" ] && [ "$patch_b" -gt "$patch_a" ]; then
253+
elif [ "$major_b" -eq "$major_a" ] && [ "$minor_b" -eq "$minor_a" ] && [ "$patch_b" -ge "$patch_a" ]; then
254254
return 1
255255
fi
256256

run_update_history.sh

100644100755
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ set -e
77
source /usr/local/etc/library.sh
88

99
# Updates folder contains the "history" of updates
10-
updates="$1"
11-
[ -d "$updates" ] || { echo "$updates does not exist. Abort" >&2; exit 1; }
10+
updates_dir="$1"
11+
[ -d "$updates_dir" ] || { echo "$updates_dir does not exist. Abort" >&2; exit 1; }
1212

1313
# Get the array of updates dir
1414
# The files in updates dir are sorted by tag number
1515
# Files names follow the syntax of a tag: x.y.z.sh
1616
while read line ; do
1717
updates_list+=("$line")
18-
done < <( ls -1 "$updates" | sort -V)
18+
done < <( ls -1 "$updates_dir" | sort -V)
1919

2020
starting_checkpoint=0
2121
len=${#updates_list[@]}
@@ -40,7 +40,7 @@ if is_more_recent_than "$latest_checkpoint_version" "$current_version" ; then
4040

4141
# An update is *applicable* when it is more recent than the current version
4242
# An older update/checkpoint is not *applicable* to our system
43-
43+
4444
lower_bound=0
4545
upper_bound=$end_of_list
4646
while [ $lower_bound -le $upper_bound ]; do
@@ -97,12 +97,12 @@ if is_more_recent_than "$latest_checkpoint_version" "$current_version" ; then
9797
# Starting checkpoint has been found so update the system for the rest updates
9898

9999
for(( i="$starting_checkpoint"; i<="$end_of_list"; i++)); do
100-
update_file=${updates_list[i]}
100+
update_file=${updates_list[$i]}
101101
tag_update=$( basename "$update_file" .sh )
102102
echo -e "Updating system to version $tag_update . . ."
103-
./"$updates"/"$update_file" || exit 1
104-
echo -e "System updated successfully to version $tag_update"
103+
bash "$updates_dir/$update_file" || exit 1
105104
echo "v$tag_update" > /usr/local/etc/ncp-version
105+
echo -e "System updated successfully to version v$tag_update"
106106
done
107107
fi
108108

update.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
set -e
1212

1313
CONFDIR=/usr/local/etc/ncp-config.d/
14+
UPDATESDIR=updates
1415

1516
# don't make sense in a docker container
1617
EXCL_DOCKER="
@@ -49,8 +50,6 @@ cp etc/library.sh /usr/local/etc/
4950

5051
source /usr/local/etc/library.sh
5152

52-
./run_update_history.sh "updates"
53-
5453
mkdir -p "$CONFDIR"
5554

5655
# prevent installing some ncp-apps in the docker version
@@ -123,6 +122,9 @@ cp -r ncp-app /var/www/
123122
# update services
124123
cp docker/{lamp/010lamp,nextcloud/020nextcloud,nextcloudpi/000ncp} /etc/services-enabled.d
125124

125+
# update old images
126+
./run_update_history.sh "$UPDATESDIR"
127+
126128
}
127129

128130
exit 0
Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
## BACKWARD FIXES ( for older images )
46

57
source /usr/local/etc/library.sh
@@ -24,6 +26,13 @@ EOF
2426
:
2527
}
2628

29+
# remove files that have been moved
30+
rm -f "$BINDIR"/CONFIG/nc-notify-updates.sh
31+
rm -f "$BINDIR"/TOOLS/nc-update-nc-apps.sh
32+
rm -f "$BINDIR"/TOOLS/nc-update-nextcloud.sh
33+
rm -f "$BINDIR"/TOOLS/nc-update.sh
34+
rm -f "$BINDIR"/{SYSTEM/unattended-upgrades.sh,CONFIG/nc-autoupdate-nc.sh,CONFIG/nc-autoupdate-ncp.sh,CONFIG/nc-update-nc-apps-auto.sh}
35+
2736
# update to the latest version
2837
is_active_app nc-autoupdate-nc && run_app nc-autoupdate-nc
2938

@@ -48,7 +57,7 @@ EOF
4857
is_active_app nc-update-nc-apps-auto && run_app nc-update-nc-apps-auto
4958

5059
# rework letsencrypt notification
51-
USER="$(jq -r '.params[2].value' "$CONFDIR"/letsencrypt.cfg)"
60+
USER="$(jq -r '.params[2].value' "$CFGDIR"/letsencrypt.cfg)"
5261
mkdir -p /etc/letsencrypt/renewal-hooks/deploy/
5362
cat > /etc/letsencrypt/renewal-hooks/deploy/ncp <<EOF
5463
#!/bin/bash
@@ -117,9 +126,73 @@ EOF
117126
# fix logrotate files
118127
chmod 0444 /etc/logrotate.d/*
119128

129+
# adjust preview sizes
130+
[[ "$(ncc config:system:get preview_max_x)" == "" ]] && {
131+
ncc config:app:set previewgenerator squareSizes --value="32 256"
132+
ncc config:app:set previewgenerator widthSizes --value="256 384"
133+
ncc config:app:set previewgenerator heightSizes --value="256"
134+
ncc config:system:set preview_max_x --value 2048
135+
ncc config:system:set preview_max_y --value 2048
136+
ncc config:system:set jpeg_quality --value 60
137+
}
138+
139+
# adjust local IPv6
140+
cat > /etc/apache2/sites-available/ncp.conf <<EOF
141+
Listen 4443
142+
<VirtualHost _default_:4443>
143+
DocumentRoot /var/www/ncp-web
144+
SSLEngine on
145+
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
146+
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
147+
148+
# 2 days to avoid very big backups requests to timeout
149+
TimeOut 172800
150+
151+
<IfModule mod_authnz_external.c>
152+
DefineExternalAuth pwauth pipe /usr/sbin/pwauth
153+
</IfModule>
154+
155+
</VirtualHost>
156+
<Directory /var/www/ncp-web/>
157+
158+
AuthType Basic
159+
AuthName "ncp-web login"
160+
AuthBasicProvider external
161+
AuthExternal pwauth
162+
163+
SetEnvIf Request_URI "^" noauth
164+
SetEnvIf Request_URI "^index\.php$" !noauth
165+
SetEnvIf Request_URI "^/$" !noauth
166+
SetEnvIf Request_URI "^/wizard/index.php$" !noauth
167+
SetEnvIf Request_URI "^/wizard/$" !noauth
168+
169+
<RequireAll>
170+
171+
<RequireAny>
172+
Require host localhost
173+
Require local
174+
Require ip 192.168
175+
Require ip 172
176+
Require ip 10
177+
Require ip fd00::/8
178+
Require ip fe80::/10
179+
</RequireAny>
180+
181+
<RequireAny>
182+
Require env noauth
183+
Require user ncp
184+
</RequireAny>
185+
186+
</RequireAll>
187+
188+
</Directory>
189+
EOF
190+
120191
# remove redundant opcache configuration. Leave until update bug is fixed -> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815968
121192
# Bug #416 reappeared after we moved to php7.2 and debian buster packages. (keep last)
122193
[[ "$( 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 )"
123194
[[ "$( 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 )"
124195

125196
} # end - only live updates
197+
198+
exit 0

0 commit comments

Comments
 (0)