Skip to content

Commit c2057ca

Browse files
authored
Merge pull request #520 from linuxserver/previous-version-spaces
2 parents 0ec959e + 00b7ea5 commit c2057ca

File tree

1 file changed

+20
-20
lines changed
  • root/etc/s6-overlay/s6-rc.d/init-nextcloud-config

1 file changed

+20
-20
lines changed

root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mkdir -p \
1010
/data
1111

1212
# migrate legacy install (copy inside container)
13-
if [ -f /config/www/nextcloud/version.php ]; then
13+
if [[ -f /config/www/nextcloud/version.php ]]; then
1414
echo "Migrating legacy install (this can take a while) ...)"
1515
rsync -rlD --remove-source-files --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/
1616
rm -rf /config/www/nextcloud/updater/
@@ -26,17 +26,17 @@ fi
2626

2727
# symlink config folders
2828
for dir in apps config themes; do
29-
if [ "$(readlink /app/www/public/${dir})" != "/config/www/nextcloud/${dir}" ]; then
29+
if [[ "$(readlink /app/www/public/${dir})" != "/config/www/nextcloud/${dir}" ]]; then
3030
rm -rf "/app/www/public/${dir}"
3131
ln -s "/config/www/nextcloud/${dir}" "/app/www/public/${dir}"
3232
lsiown abc:abc "/config/www/nextcloud/${dir}" "/app/www/public/${dir}"
3333
fi
3434
done
3535

3636
# get versions
37-
image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null)
38-
installed_version=$(php -r "require '/config/www/nextcloud/config/config.php'; echo \$CONFIG['version'];" 2>/dev/null)
39-
if [ "${installed_version}" = "" ]; then
37+
image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null | xargs)
38+
installed_version=$(php -r "require '/config/www/nextcloud/config/config.php'; echo \$CONFIG['version'];" 2>/dev/null | xargs)
39+
if [[ "${installed_version}" = "" ]]; then
4040
installed_version="0.0.0.0"
4141
fi
4242
image_major="${image_version%%.*}"
@@ -54,23 +54,23 @@ if vergt "${installed_version}" "${image_version}"; then
5454
sleep infinity
5555
fi
5656

57-
if [ "${installed_version}" != "0.0.0.0" ] && vergt "${image_major}" "${max_upgrade}"; then
57+
if [[ "${installed_version}" != "0.0.0.0" ]] && vergt "${image_major}" "${max_upgrade}"; then
5858
echo "Can't start Nextcloud because the version of the data (${installed_version}) is more than one major version behind the docker image version (${image_version}) and upgrading more than one major version is not supported. Please run an image tagged for the major version ${max_upgrade} first."
5959
sleep infinity
6060
fi
6161

62-
if [ "${installed_version}" = "0.0.0.0" ] || [ ! -f /app/www/public/version.php ] || [ -z "$(ls -A /config/www/nextcloud/apps 2>/dev/null)" ]; then
62+
if [[ "${installed_version}" = "0.0.0.0" ]] || [[ ! -f /app/www/public/version.php ]] || [[ -z "$(ls -A /config/www/nextcloud/apps 2>/dev/null)" ]]; then
6363
touch /tmp/needs_install
6464
fi
6565

66-
if [ "${installed_version}" != "0.0.0.0" ] && vergt "${image_version}" "${installed_version}"; then
66+
if [[ "${installed_version}" != "0.0.0.0" ]] && vergt "${image_version}" "${installed_version}"; then
6767
touch /tmp/needs_upgrade
6868
fi
6969

7070
# initialize nextcloud
71-
if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_install ] || [ -f /tmp/needs_upgrade ]; then
71+
if [[ -f /config/www/nextcloud/config/needs_migration ]] || [[ -f /tmp/needs_install ]] || [[ -f /tmp/needs_upgrade ]]; then
7272
echo "Initializing nextcloud ${image_version} (this can take a while) ..."
73-
if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_upgrade ]; then
73+
if [[ -f /config/www/nextcloud/config/needs_migration ]] || [[ -f /tmp/needs_upgrade ]]; then
7474
echo "Upgrading nextcloud from ${installed_version} ..."
7575
shippedApps=$(jq -r .shippedApps[] /app/www/src/core/shipped.json)
7676
for app in ${shippedApps}; do
@@ -80,11 +80,11 @@ if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_instal
8080

8181
rsync -rlD --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/
8282
for dir in apps config themes; do
83-
if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_upgrade ] || [ -z "$(ls -A /app/www/public/${dir} 2>/dev/null)" ]; then
83+
if [[ -f /config/www/nextcloud/config/needs_migration ]] || [[ -f /tmp/needs_upgrade ]] || [[ -z "$(ls -A /app/www/public/${dir} 2>/dev/null)" ]]; then
8484
rsync -rlD --include "/${dir}" --exclude '/*' /app/www/src/ /config/www/nextcloud/
8585
fi
8686
done
87-
if [ -z "$(ls -A /data/ 2>/dev/null)" ]; then
87+
if [[ -z "$(ls -A /data/ 2>/dev/null)" ]]; then
8888
rsync -rlD --include "/data" --exclude '/*' /app/www/src/ /
8989
fi
9090

@@ -94,11 +94,11 @@ if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_instal
9494
/app/www/public \
9595
/config/www/nextcloud
9696

97-
if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_upgrade ]; then
97+
if [[ -f /config/www/nextcloud/config/needs_migration ]] || [[ -f /tmp/needs_upgrade ]]; then
9898
# Upgrade
9999
occ upgrade
100100
else
101-
if [ "${installed_version}" = "0.0.0.0" ]; then
101+
if [[ "${installed_version}" = "0.0.0.0" ]]; then
102102
# Install
103103
echo "New nextcloud instance"
104104
echo "Please run the web-based installer on first connect!"
@@ -148,29 +148,29 @@ for APP in richdocumentscode; do
148148
echo "Removing ${APP}"
149149
fi
150150
APP_PATH=$(occ app:getpath "${APP}" 2>/dev/null)
151-
if [ -z "${APP_PATH}" ] || [ ! -d "${APP_PATH}" ]; then
151+
if [[ -z "${APP_PATH}" ]] || [[ ! -d "${APP_PATH}" ]]; then
152152
APP_PATH="/app/www/public/apps/${APP}"
153153
fi
154-
if [ -d "${APP_PATH}" ]; then
154+
if [[ -d "${APP_PATH}" ]]; then
155155
occ app:disable "${APP}" >/dev/null 2>&1
156156
fi
157157
APP_STATUS="$(occ config:app:get "${APP}" enabled 2>/dev/null)"
158-
if [ "${APP_STATUS}" != "no" ] && [ -n "${APP_STATUS}" ]; then
158+
if [[ "${APP_STATUS}" != "no" ]] && [[ -n "${APP_STATUS}" ]]; then
159159
occ config:app:set "${APP}" enabled --value="no" >/dev/null 2>&1
160160
fi
161161
occ app:remove "${APP}" >/dev/null 2>&1
162162
rm -rf "${APP_PATH}"
163163
done
164164

165165
# set data directory
166-
if [ ! -s /config/www/nextcloud/config/config.php ]; then
166+
if [[ ! -s /config/www/nextcloud/config/config.php ]]; then
167167
echo -e "<?php\n\$CONFIG = array (\n 'datadirectory' => '/data',\n);" >/config/www/nextcloud/config/config.php
168-
elif [ -f /config/www/nextcloud/config/config.php ]; then
168+
elif [[ -f /config/www/nextcloud/config/config.php ]]; then
169169
sed -i "s|/app/www/public/data|/data|g" /config/www/nextcloud/config/config.php
170170
fi
171171

172172
#modify javascript mime type and add .mjs support
173-
if [ -s /etc/nginx/mime.types ]; then
173+
if [[ -s /etc/nginx/mime.types ]]; then
174174
sed -i 's|\bjs;|js mjs;|g' /etc/nginx/mime.types
175175
sed -i 's|\bapplication/javascript|text/javascript|g' /etc/nginx/mime.types
176176
fi

0 commit comments

Comments
 (0)