mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-21 12:08:12 +01:00
Test new nextcloud
This commit is contained in:
@@ -47,11 +47,14 @@ RUN \
|
||||
sed -i "s|client_max_body_size 512M;|client_max_body_size 8192M;|g" /defaults/nginx/site-confs/default.conf.sample && \
|
||||
sed -i "s|client_body_timeout 300s;|client_body_timeout 900s;|g" /defaults/nginx/site-confs/default.conf.sample && \
|
||||
\
|
||||
# Change location of executable
|
||||
#sed -i "s|/config|/data/config|g" /usr/bin/occ && \
|
||||
#\
|
||||
# Change location of log
|
||||
sed -i "s|s6-setuidgid abc php -f /config/www/nextcloud/cron.php|(s6-setuidgid abc php -f /config/www/nextcloud/cron.php) \&>/proc/1/fd/1|g" /etc/crontabs/root
|
||||
sed -i "s|s6-setuidgid abc php -f /config/www/nextcloud/cron.php|(s6-setuidgid abc php -f /config/www/nextcloud/cron.php) \&>/proc/1/fd/1|g" /etc/crontabs/root && \
|
||||
\
|
||||
# Run custom scripts after installation
|
||||
echo "touch /runfile" >> /etc/s6-overlay/s6-rc.d/init-nextcloud-config/run && \
|
||||
echo "/./etc/entrypoint.sh" >> /etc/s6-overlay/s6-rc.d/init-nextcloud-config/run && \
|
||||
chmod 777 /migrations/02-default-location && \
|
||||
sed -i "1a /./defaults/nextcloud-perms.sh" /migrations/02-default-location
|
||||
|
||||
# Global LSIO modifications
|
||||
ARG CONFIGLOCATION="/data/config"
|
||||
@@ -72,9 +75,6 @@ RUN \
|
||||
# Avoid chmod /config
|
||||
&& for file in /etc/services.d/*/* /etc/cont-init.d/* /etc/s6-overlay/s6-rc.d/*/*;do if [ -f $file ] && [[ ! -z $(awk '/chown.*abc:abc.*\\/,/.*\/config( |$)/{print FILENAME}' $file) ]] ; then sed -i "s|/config$|/data|g" $file; fi ;done \
|
||||
\
|
||||
# Docker mods addition
|
||||
#&& if [ -f /docker-mods ]; then sed -i 's|bash|bashio|g' /docker-mods && sed -i "1a if bashio::config.has_value \"DOCKER_MODS\"; then DOCKER_MODS=\$(bashio::config \"DOCKER_MODS\"); fi" /docker-mods; fi \
|
||||
\
|
||||
# Replace lsiown if not found
|
||||
&& if [ ! -f /usr/bin/lsiown ]; then for file in $(grep -sril "lsiown" /etc); do sed -i "s|lsiown|chown|g" $file; done; fi
|
||||
|
||||
@@ -123,7 +123,16 @@ VOLUME ["/share", "/ssl", "/data", "/media"]
|
||||
ARG CONFIGLOCATION="/www/nextcloud/config"
|
||||
# hadolint ignore=SC2015, SC2013, SC2086, SC2016
|
||||
RUN \
|
||||
# Avoid using legacy cont-init.d
|
||||
mkdir -p /scripts && mv /etc/cont-init.d/* /scripts && \
|
||||
sed -i "s|/etc/cont-init.d|/scripts|g" /etc/entrypoint.sh && \
|
||||
\
|
||||
# Give permissions
|
||||
chmod 777 /etc/entrypoint.sh /defaults/nextcloud-perms.sh && \
|
||||
\
|
||||
# Correct erroneous modifications
|
||||
for file in $(grep -Esril "/www/nextcloud/data/config" /etc /defaults); do sed -Ei "s=(/www/nextcloud/data/config)+(/| |$|\"|\')=$CONFIGLOCATION\2=g" $file; done && \
|
||||
for file in $(grep -Esril "/data/data" /etc /defaults); do sed -Ei "s=(/data/data)+(/| |$|\"|\')=/data\2=g" $file; done && \
|
||||
\
|
||||
# Correct nginx files
|
||||
sed -i "/Strict-Transport-Security/d" /defaults/nginx/site-confs/default.conf.sample && \
|
||||
|
||||
@@ -124,6 +124,6 @@
|
||||
"slug": "nextcloud_ocr",
|
||||
"uart": true,
|
||||
"url": "https://github.com/alexbelgium/hassio-addons/tree/master/nextcloud",
|
||||
"version": "27.0.0",
|
||||
"version": "27.0.0-test_DO_NOT_INSTALL",
|
||||
"webui": "https://[HOST]:[PORT:443]"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,19 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
####################################
|
||||
# Clean nginx files at each reboot #
|
||||
####################################
|
||||
|
||||
echo "Cleaning files"
|
||||
for var in /data/config/nginx /data/config/crontabs /data/config/logs; do
|
||||
if [ -d "$var" ]; then rm -r "$var"; fi
|
||||
done
|
||||
|
||||
########################
|
||||
# Settings permissions #
|
||||
########################
|
||||
|
||||
ocpath="${NEXTCLOUD_PATH}"
|
||||
htuser='abc'
|
||||
htgroup='abc'
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
####################################
|
||||
# Clean nginx files at each reboot #
|
||||
####################################
|
||||
|
||||
echo "Cleaning files"
|
||||
for var in /data/config/nginx /data/config/crontabs /data/config/logs; do
|
||||
if [ -d "$var" ]; then rm -r "$var"; fi
|
||||
done
|
||||
|
||||
######################################
|
||||
# Make links between logs and docker #
|
||||
######################################
|
||||
@@ -28,17 +19,15 @@ done
|
||||
# CHECK STATUS #
|
||||
################
|
||||
|
||||
# Clean remnant files
|
||||
if [ -f /notinstalled ]; then
|
||||
rm /notinstalled
|
||||
fi
|
||||
|
||||
# Specify launcher
|
||||
LAUNCHER="sudo -u abc php /app/www/public/occ"
|
||||
|
||||
# Only execute if installed
|
||||
if [ -f /notinstalled ]; then exit 0; fi
|
||||
|
||||
# Check current version
|
||||
if [ -f /app/www/public/version.php ]; then
|
||||
CURRENTVERSION="$(sed -n "s|.*\OC_VersionString = '*\(.*[^ ]\) *';.*|\1|p" /data/config/www/nextcloud/version.php)"
|
||||
if [ -f /data/config/www/nextcloud/config/config.php ]; then
|
||||
CURRENTVERSION="$(sed -n "s|.*\OC_VersionString = '*\(.*[^ ]\) *';.*|\1|p" /data/config/www/nextcloud/config/config.php)"
|
||||
else
|
||||
CURRENTVERSION="Not found"
|
||||
fi
|
||||
@@ -46,7 +35,7 @@ fi
|
||||
echo " "
|
||||
|
||||
# If not installed, or files not available
|
||||
if [[ $($LAUNCHER -V 2>&1) == *"not installed"* ]] || [ ! -f /app/www/public/version.php ]; then
|
||||
if [[ $($LAUNCHER -V 2>&1) == *"not installed"* ]] || [ ! -f /data/config/www/nextcloud/config/config.php ]; then
|
||||
bashio::log.green "--------------------------------------------------------------------------------------------------------------"
|
||||
bashio::log.yellow "Nextcloud not installed, please wait for addon startup, login Webui, install Nextcloud, then restart the addon"
|
||||
bashio::log.green "--------------------------------------------------------------------------------------------------------------"
|
||||
@@ -54,37 +43,12 @@ if [[ $($LAUNCHER -V 2>&1) == *"not installed"* ]] || [ ! -f /app/www/public/ver
|
||||
touch /notinstalled
|
||||
exit 0
|
||||
# Is there missing files
|
||||
elif [[ $($LAUNCHER -V 2>&1) == *"Composer autoloader not found"* ]] || [[ $($LAUNCHER -V 2>&1) == *"No such file"* ]] ; then
|
||||
bashio::log.red "--------------------------------------------------"
|
||||
bashio::log.red " Missing files detected, Nextcloud will reinstall "
|
||||
bashio::log.red "--------------------------------------------------"
|
||||
touch /reinstall
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair-share-owner"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:mode --off"
|
||||
# Everything is fine
|
||||
elif [[ $($LAUNCHER -V 2>&1) =~ ^"Nextcloud "[0-9].* ]]; then
|
||||
# Log
|
||||
bashio::log.green "----------------------------------------"
|
||||
bashio::log.green " Nextcloud $CURRENTVERSION is installed "
|
||||
bashio::log.green "----------------------------------------"
|
||||
# Tentative to downgrade
|
||||
elif [[ $($LAUNCHER -V 2>&1) == *"Downgrading"* ]]; then
|
||||
# Get currently installed version
|
||||
version="$($LAUNCHER -V 2>&1)"
|
||||
version="${version% to *}"
|
||||
version="${version#*from }"
|
||||
until [ "$(echo "$version" | awk -F. '{ print NF - 1 }')" -le "2" ]; do
|
||||
version="${version%\.*}"
|
||||
done
|
||||
# Inform
|
||||
bashio::log.red "-----------------------------------------------------------------------------------------------------"
|
||||
bashio::log.red " Error : a downgrade was detected. This is not possible. The current version $version will reinstall "
|
||||
bashio::log.red "-----------------------------------------------------------------------------------------------------"
|
||||
# Reinstall current version
|
||||
CURRENTVERSION="$version"
|
||||
touch /reinstall
|
||||
else
|
||||
bashio::log.red "-------------------------------------------------"
|
||||
bashio::log.red " Unknown error detected, auto-repair will launch "
|
||||
@@ -93,64 +57,25 @@ else
|
||||
bashio::log.red "$($LAUNCHER -V 2>&1)"
|
||||
bashio::log.red "------------------------------------------------------------------"
|
||||
bashio::exit.nok
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair-share-owner"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:mode --off"
|
||||
sudo -u abc -s /bin/bash -c "php /app/www/public/occ maintenance:repair"
|
||||
sudo -u abc -s /bin/bash -c "php /app/www/public/occ maintenance:repair-share-owner"
|
||||
sudo -u abc -s /bin/bash -c "php /app/www/public/occ upgrade"
|
||||
sudo -u abc -s /bin/bash -c "php /app/www/public/occ maintenance:mode --off"
|
||||
fi
|
||||
|
||||
echo " "
|
||||
|
||||
######################
|
||||
# REINSTALL IF ISSUE #
|
||||
######################
|
||||
|
||||
# Reinstall if needed
|
||||
if [ -f /reinstall ]; then
|
||||
rm /reinstall
|
||||
bashio::log.red "... issue with installation detected, reinstallation will proceed"
|
||||
|
||||
# Check container version
|
||||
CONTAINERVERSION="$(cat /nextcloudversion)"
|
||||
|
||||
# Downloader function
|
||||
function nextcloud_download {
|
||||
mkdir -p /app
|
||||
if [ -f /app/nextcloud.tar.bz2 ]; then rm /app/nextcloud.tar.bz2; fi
|
||||
curl -s -o /app/nextcloud.tar.bz2 -L "https://download.nextcloud.com/server/releases/$1.tar.bz2"
|
||||
}
|
||||
|
||||
# Redownload nextcloud if wrong version
|
||||
if [[ ! "$CURRENTVERSION" == "$CONTAINERVERSION" ]]; then
|
||||
bashio::log.red "... version installed is : $CURRENTVERSION and version bundled is : $CONTAINERVERSION, need to redownload files"
|
||||
bashio::log.green "... download nextcloud version"
|
||||
nextcloud_download "nextcloud-${CURRENTVERSION}" || (bashio::log.fatal "Your version doesn't exist... Please restore backup or fully uninstall addon" && exit 1)
|
||||
fi
|
||||
|
||||
# Reinstall
|
||||
bashio::log.green "... reinstall ongoing, please wait"
|
||||
if [ -f /data/config/www/nextcloud/index.php ]; then rm /data/config/www/nextcloud/index.php; fi && \
|
||||
# INSTALL
|
||||
/./etc/s6-overlay/s6-rc.d/init-nextcloud-config/run
|
||||
# RESET PERMISSIONS
|
||||
/./etc/cont-init.d/01-folders.sh
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair-share-owner"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:mode --off"
|
||||
fi
|
||||
|
||||
###########################
|
||||
# DISABLE MAINTENACE MODE #
|
||||
###########################
|
||||
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:mode --off" &>/dev/null || true
|
||||
sudo -u abc -s /bin/bash -c "php /data/app/www/public/occ maintenance:mode --off" &>/dev/null || true
|
||||
|
||||
##############
|
||||
# CLEAN OCDE #
|
||||
##############
|
||||
|
||||
sudo -u abc php /data/config/www/nextcloud/occ app:remove --no-interaction "richdocumentscode" &>/dev/null || true
|
||||
sudo -u abc php /data/config/www/nextcloud/occ app:remove --no-interaction "richdocumentscode_arm64" &>/dev/null || true
|
||||
sudo -u abc php /data/config/www/nextcloud/occ app:remove --no-interaction "richdocumentscode_amd64" &>/dev/null || true
|
||||
|
||||
sudo -u abc php /data/app/www/public/occ app:remove --no-interaction "richdocumentscode" &>/dev/null || true
|
||||
sudo -u abc php /data/app/www/public/occ app:remove --no-interaction "richdocumentscode_arm64" &>/dev/null || true
|
||||
sudo -u abc php /data/app/www/public/occ app:remove --no-interaction "richdocumentscode_amd64" &>/dev/null || true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
|
||||
if bashio::services.available 'mysql'; then
|
||||
|
||||
bashio::log.green "---"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
|
||||
if bashio::config.true 'use_own_certs'; then
|
||||
|
||||
bashio::log.green "Using referenced ssl certificates"
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
exit 0
|
||||
|
||||
# Only execute if installed
|
||||
if [ -f /notinstalled ]; then exit 0; fi
|
||||
|
||||
# Check current version
|
||||
if [ -f /data/config/www/nextcloud/version.php ]; then
|
||||
CURRENTVERSION="$(sed -n "s|.*\OC_VersionString = '*\(.*[^ ]\) *';.*|\1|p" /data/config/www/nextcloud/version.php)"
|
||||
else
|
||||
CURRENTVERSION="Not found"
|
||||
fi
|
||||
|
||||
# Check container version
|
||||
CONTAINERVERSION="$(cat /nextcloudversion)"
|
||||
|
||||
# Inform if new version available
|
||||
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
||||
|
||||
# Updater nextcloud code
|
||||
if ! bashio::config.true "disable_updates_nextcloud"; then
|
||||
bashio::log.green "Auto_updater set, checking for updates"
|
||||
# Install new version
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/updater/updater.phar --no-interaction"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||
# Install additional versions
|
||||
while [[ $(occ update:check 2>&1) == *"update available"* ]]; do
|
||||
bashio::log.yellow "-----------------------------------------------------------------------"
|
||||
bashio::log.yellow " new version available, updating. Please do not turn off your addon! "
|
||||
bashio::log.yellow "-----------------------------------------------------------------------"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/updater/updater.phar --no-interaction"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||
done
|
||||
# Reset permissions
|
||||
/./etc/cont-init.d/01-folders.sh
|
||||
elif bashio::config.true "disable_updates" && [ "$(version "$CONTAINERVERSION")" -gt "$(version "$CURRENTVERSION")" ]; then
|
||||
bashio::log.warning " "
|
||||
bashio::log.warning "----------------------------------------- "
|
||||
bashio::log.warning "New version available : $CONTAINERVERSION"
|
||||
bashio::log.warning "-----------------------------------------"
|
||||
bashio::log.warning " "
|
||||
bashio::log.warning "...auto_updater not set in addon options, please update from nextcloud settings"
|
||||
bashio::log.warning "If you don't update you risk an addon breakage !"
|
||||
bashio::log.warning " "
|
||||
bashio::log.warning "-----------------------------------------"
|
||||
fi
|
||||
|
||||
# Updater apps code
|
||||
if ! bashio::config.true "disable_updates"; then
|
||||
bashio::log.green "... checking for app updates"
|
||||
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ app:update --all"
|
||||
else
|
||||
bashio::log.yellow "... disable_updates set, apps need to be updated manually"
|
||||
fi
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
|
||||
# Only execute if installed
|
||||
if [ -f /notinstalled ]; then exit 0; fi
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2086
|
||||
|
||||
|
||||
# Only execute if installed
|
||||
if [ -f /notinstalled ]; then exit 0; fi
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
|
||||
# Only execute if installed
|
||||
if [ -f /notinstalled ]; then exit 0; fi
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
|
||||
# Only execute if installed
|
||||
if [ -f /notinstalled ]; then exit 0; fi
|
||||
|
||||
|
||||
27
nextcloud/rootfs/etc/entrypoint.sh
Normal file
27
nextcloud/rootfs/etc/entrypoint.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
echo "Starting..."
|
||||
|
||||
############################
|
||||
# Backup Dockerfile Script #
|
||||
############################
|
||||
|
||||
if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then
|
||||
chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
/./etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh
|
||||
fi
|
||||
|
||||
####################
|
||||
# Starting scripts #
|
||||
####################
|
||||
|
||||
for SCRIPTS in /etc/cont-init.d/*; do
|
||||
[ -e "$SCRIPTS" ] || continue
|
||||
echo "$SCRIPTS: executing"
|
||||
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
||||
chmod a+x "$SCRIPTS"
|
||||
# Change shebang if no s6 supervision
|
||||
sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS"
|
||||
/."$SCRIPTS" || echo "$SCRIPTS: exiting $?"
|
||||
done
|
||||
Reference in New Issue
Block a user