diff options
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | Vagrantfile | 2 | ||||
-rwxr-xr-x | bin/ncp-dist-upgrade | 119 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-limits.sh | 6 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-nextcloud.sh | 6 | ||||
-rw-r--r-- | bin/ncp/UPDATES/unattended-upgrades.sh | 2 | ||||
-rwxr-xr-x | build-VM.sh | 2 | ||||
-rw-r--r-- | changelog.md | 6 | ||||
-rw-r--r-- | docker/lamp/Dockerfile | 2 | ||||
-rw-r--r-- | docker/nextcloudpi/Dockerfile | 2 | ||||
-rw-r--r-- | etc/ncp-config.d/nc-nextcloud.cfg | 2 | ||||
-rw-r--r-- | etc/ncp.cfg | 10 | ||||
-rwxr-xr-x | update.sh | 45 | ||||
-rw-r--r-- | updates/1.15.0.sh | 27 |
14 files changed, 189 insertions, 48 deletions
@@ -15,10 +15,10 @@ Find the full documentation at [docs.nextcloudpi.com](http://docs.nextcloudpi.co ## Features - * Debian/Raspbian 9 stretch - * Nextcloud 16.0.2 + * Debian/Raspbian 10 Buster + * Nextcloud 16.0.3 * Apache 2.4.25, with HTTP2 enabled - * PHP 7.2 + * PHP 7.3 * MariaDB 10 * Redis memory cache * ncp-config for easy setup ( RAM logs, USB drive and more ) diff --git a/Vagrantfile b/Vagrantfile index 2af828a1..61b45126 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -15,7 +15,7 @@ Vagrant.configure("2") do |config| vmname = "NCP Debian VM" release = ENV["DEB_RELEASE"] config.vm.box = "debian/#{release}64" - config.vm.box_check_update = false + config.vm.box_check_update = true config.vm.hostname = "ncp-vm" config.vm.synced_folder '.', '/vagrant', disabled: true diff --git a/bin/ncp-dist-upgrade b/bin/ncp-dist-upgrade new file mode 100755 index 00000000..47b8e10f --- /dev/null +++ b/bin/ncp-dist-upgrade @@ -0,0 +1,119 @@ +#!/bin/bash + +set -eu -o pipefail + +[[ -f /.dockerenv ]] && { echo "Not supported in Docker. Upgrade the container instead"; exit 0; } + +new_cfg=/usr/local/etc/ncp-recommended.cfg +[[ -f "${new_cfg}" ]] || { echo "Already on the lastest recommended distribution. Abort." >&2; exit 1; } + +APTINSTALL="apt-get install -y --no-install-recommends" +export DEBIAN_FRONTEND=noninteractive + +echo " +>>> ATTENTION <<< +This is a dangerous process that is only guaranteed to work properly if you +have not made manual changes in the system. Backup the SD card first and +proceed at your own risk. + +Note that this is not a requirement for NCP to continue working properly. +The current distribution will keep receiving updates for some time. + +Do you want to continue? [y/N]" + +read key +[[ "$key" == y ]] || exit 0 + +source /usr/local/etc/library.sh # sets NCPCFG RELEASE PHPVER +old_cfg="${NCPCFG}" + +trap "echo 'Something went wrong. Fix it and try again'" EXIT + +ncc maintenance:mode --on || true + +apt-get update +apt-get upgrade -y + +# remove old PHP version +set +e +apt-get purge -y php${PHPVER} php${PHPVER}-curl php${PHPVER}-gd php${PHPVER}-fpm php${PHPVER}-cli php${PHPVER}-opcache \ + php${PHPVER}-mbstring php${PHPVER}-xml php${PHPVER}-zip php${PHPVER}-fileinfo php${PHPVER}-ldap \ + php${PHPVER}-intl php${PHPVER}-bz2 php${PHPVER}-json +apt-get purge -y php${PHPVER}-mysql +apt-get purge -y php${PHPVER}-redis +apt-get purge -y php${PHPVER}-exif +apt-get purge -y php${PHPVER}-imagick +set -e + +# update sources +sed -i 's/stretch/buster/g' /etc/apt/sources.list +rm -f /etc/apt/sources.list.d/php.list + +# install latest distro +apt-get update +apt-get dist-upgrade -y + +# install latest PHP version +release_new=$(jq -r '.release' < "${new_cfg}") +php_ver_new=$(jq -r '.php_version' < "${new_cfg}") + +$APTINSTALL -t ${release_new} php${php_ver_new} php${php_ver_new}-curl php${php_ver_new}-gd php${php_ver_new}-fpm php${php_ver_new}-cli php${php_ver_new}-opcache \ + php${php_ver_new}-mbstring php${php_ver_new}-xml php${php_ver_new}-zip php${php_ver_new}-fileinfo php${php_ver_new}-ldap \ + php${php_ver_new}-intl php${php_ver_new}-bz2 php${php_ver_new}-json + +$APTINSTALL php${php_ver_new}-mysql +$APTINSTALL -t ${release_new} php${php_ver_new}-redis + +$APTINSTALL -t ${release_new} php${php_ver_new}-exif +#$APTINSTALL -t ${release_new} imagemagick php${php_ver_new}-imagick ghostscript + +apt-get autoremove -y +apt-get clean + +# configure latest PHP version +cat > /etc/php/${php_ver_new}/mods-available/opcache.ini <<EOF +zend_extension=opcache.so +opcache.enable=1 +opcache.enable_cli=1 +opcache.fast_shutdown=1 +opcache.interned_strings_buffer=8 +opcache.max_accelerated_files=10000 +opcache.memory_consumption=128 +opcache.save_comments=1 +opcache.revalidate_freq=1 +opcache.file_cache=/tmp; +EOF + +cat > /etc/php/${php_ver_new}/fpm/conf.d/90-ncp.ini <<EOF +; disable .user.ini files for performance and workaround NC update bugs +user_ini.filename = + +; from Nextcloud .user.ini +upload_max_filesize=10G +post_max_size=10G +memory_limit=768M +mbstring.func_overload=0 +always_populate_raw_post_data=-1 +default_charset='UTF-8' +output_buffering=0 + +; slow transfers will be killed after this time +max_execution_time=3600 +max_input_time=3600 +EOF + +# restart services +service php${php_ver_new}-fpm restart +a2enconf php${php_ver_new}-fpm +service apache2 restart + +is_active_app unattended-upgrades && run_app unattended-upgrades || true + +# mark as successful +mv "${new_cfg}" "${old_cfg}" + +run_app nc-limits +ncc maintenance:mode --off || true + +echo "Upgrade to ${release_new} successful" +trap '' EXIT diff --git a/bin/ncp/CONFIG/nc-limits.sh b/bin/ncp/CONFIG/nc-limits.sh index 8c527401..925796db 100644 --- a/bin/ncp/CONFIG/nc-limits.sh +++ b/bin/ncp/CONFIG/nc-limits.sh @@ -25,9 +25,9 @@ configure() local CONF=/etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini local CURRENT_PHP_MEM="$( grep "^memory_limit" "$CONF" | sed 's|.*=||' )" [[ "$MEMORYLIMIT" == "0" ]] && MEMORYLIMIT=$AUTOMEM && echo "Using ${AUTOMEM}B for PHP" - sed -i "s/^post_max_size=.*/post_max_size=$MAXFILESIZE/" "$CONF" - sed -i "s/^upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE/" "$CONF" - sed -i "s/^memory_limit=.*/memory_limit=$MEMORYLIMIT/" "$CONF" + sed -i "s/^post_max_size=.*/post_max_size=$MAXFILESIZE/" "$CONF" + sed -i "s/^upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE/" "$CONF" + sed -i "s/^memory_limit=.*/memory_limit=$MEMORYLIMIT/" "$CONF" # MAX PHP THREADS local CONF=/etc/php/${PHPVER}/fpm/pool.d/www.conf diff --git a/bin/ncp/CONFIG/nc-nextcloud.sh b/bin/ncp/CONFIG/nc-nextcloud.sh index b88c9f15..37c8bc0e 100644 --- a/bin/ncp/CONFIG/nc-nextcloud.sh +++ b/bin/ncp/CONFIG/nc-nextcloud.sh @@ -26,7 +26,7 @@ install() $APTINSTALL lbzip2 iputils-ping jq $APTINSTALL -t $RELEASE php-smbclient exfat-fuse exfat-utils # for external storage $APTINSTALL -t $RELEASE php${PHPVER}-exif # for gallery - #$APTINSTALL -t imagemagick php${PHPVER}-imagick # for gallery + #$APTINSTALL -t imagemagick php${PHPVER}-imagick ghostscript # for gallery # POSTFIX @@ -139,11 +139,11 @@ configure() mkdir -p $OPCACHEDIR chown -R www-data:www-data $OPCACHEDIR - ## RE-CREATE DATABASE TABLE + ## RE-CREATE DATABASE TABLE # launch mariadb if not already running (for docker build) if ! pgrep -c mysqld &>/dev/null; then echo "Starting mariaDB" - mysqld & + mysqld & fi # wait for mariadb diff --git a/bin/ncp/UPDATES/unattended-upgrades.sh b/bin/ncp/UPDATES/unattended-upgrades.sh index 2466f203..594e4969 100644 --- a/bin/ncp/UPDATES/unattended-upgrades.sh +++ b/bin/ncp/UPDATES/unattended-upgrades.sh @@ -18,7 +18,7 @@ install() configure() { - source etc/library.sh # sets RELEASE + source /usr/local/etc/library.sh # sets RELEASE [[ $ACTIVE == "yes" ]] && local AUTOUPGRADE=1 || local AUTOUPGRADE=0 [[ $AUTOREBOOT == "yes" ]] && local AUTOREBOOT=true || local AUTOREBOOT=false diff --git a/build-VM.sh b/build-VM.sh index c96cde08..a0bcbdbc 100755 --- a/build-VM.sh +++ b/build-VM.sh @@ -41,7 +41,7 @@ sudo chown "$USER" "$VM" sudo cp -a --reflink=auto --sparse=auto "$VM" "$IMG" ## pack - + TAR=output/"$( basename "$IMG" .img ).tar.bz2" pack_image "$IMG" "$TAR" diff --git a/changelog.md b/changelog.md index f42af447..f686896d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,9 @@ -[v1.14.3](https://github.com/nextcloud/nextcloudpi/commit/6a78953) (2019-07-06) nc-snapshot-sync: update btrfs-sync +[v1.15.0](https://github.com/nextcloud/nextcloudpi/commit/f6e76e7) (2019-07-08) move to buster/PHP7.3 -[v1.14.2](https://github.com/nextcloud/nextcloudpi/commit/53d02fe) (2019-07-06) nc-hdd-monitor: fix detection +[v1.14.3 ](https://github.com/nextcloud/nextcloudpi/commit/85ebb39) (2019-07-06) nc-snapshot-sync: update btrfs-sync + +[v1.14.2 ](https://github.com/nextcloud/nextcloudpi/commit/53d02fe) (2019-07-06) nc-hdd-monitor: fix detection [v1.14.0 ](https://github.com/nextcloud/nextcloudpi/commit/fa9ddca) (2019-07-05) upgrade to NC16.0.2 diff --git a/docker/lamp/Dockerfile b/docker/lamp/Dockerfile index 393a4736..4023fdb9 100644 --- a/docker/lamp/Dockerfile +++ b/docker/lamp/Dockerfile @@ -30,7 +30,7 @@ mkdir -p /data-ro /data; \ mv /var/lib/mysql /data-ro/database; \ sed -i "s|^datadir.*|datadir = /data-ro/database|" /etc/mysql/mariadb.conf.d/90-ncp.cnf; \ -# package cleanup +# package cleanup apt-get autoremove -y; \ apt-get clean; \ find /var/lib/apt/lists -type f | xargs rm; \ diff --git a/docker/nextcloudpi/Dockerfile b/docker/nextcloudpi/Dockerfile index 5f6e2ea0..a218992c 100644 --- a/docker/nextcloudpi/Dockerfile +++ b/docker/nextcloudpi/Dockerfile @@ -33,7 +33,7 @@ touch /.docker-image; \ apt-get update; \ apt-get install --no-install-recommends -y wget ca-certificates; \ - + # install nextcloudpi source /usr/local/etc/library.sh; \ set +x; \ diff --git a/etc/ncp-config.d/nc-nextcloud.cfg b/etc/ncp-config.d/nc-nextcloud.cfg index cd4f5a35..13d45297 100644 --- a/etc/ncp-config.d/nc-nextcloud.cfg +++ b/etc/ncp-config.d/nc-nextcloud.cfg @@ -9,7 +9,7 @@ { "id": "VER", "name": "Version", - "value": "16.0.2" + "value": "16.0.3" }, { "id": "BETA", diff --git a/etc/ncp.cfg b/etc/ncp.cfg index 7fc3138a..5adf74ae 100644 --- a/etc/ncp.cfg +++ b/etc/ncp.cfg @@ -1,9 +1,9 @@ { - "nextcloud_version": "16.0.2", - "php_version": "7.2", - "release": "stretch", + "nextcloud_version": "16.0.3", + "php_version": "7.3", + "release": "buster", "release_issue": [ - "Debian GNU/Linux 9", - "Raspbian GNU/Linux 9" + "Debian GNU/Linux 10", + "Raspbian GNU/Linux 10" ] } @@ -62,6 +62,19 @@ mkdir -p "$CONFDIR" # copy all files in bin and etc cp -r bin/* /usr/local/bin/ find etc -maxdepth 1 -type f ! -path etc/ncp.cfg -exec cp '{}' /usr/local/etc \; + +# set initial config # TODO remove me after next NCP release +[[ -f "${NCPCFG}" ]] || cat > /usr/local/etc/ncp.cfg <<EOF +{ + "nextcloud_version": "16.0.2", + "php_version": "7.2", + "release": "stretch", + "release_issue": [ + "Debian GNU/Linux 9", + "Raspbian GNU/Linux 9" + ] +} +EOF cp -n etc/ncp.cfg /usr/local/etc # update NCVER in ncp.cfg and nc-nextcloud.cfg (for nc-autoupdate-nc and nc-update-nextcloud) @@ -140,28 +153,39 @@ chown -R www-data: /var/www/nextcloud/apps/nextcloudpi cp docker/{lamp/010lamp,nextcloud/020nextcloud,nextcloudpi/000ncp} /etc/services-enabled.d } -# update old images -./run_update_history.sh "$UPDATESDIR" +# update old images, only live updates +[[ ! -f /.ncp-image ]] && ./run_update_history.sh "$UPDATESDIR" # update to the latest NC version is_active_app nc-autoupdate-nc && run_app nc-autoupdate-nc # check dist-upgrade check_distro "$NCPCFG" || check_distro etc/ncp.cfg && { - php_ver_new=$(jq '.php_version' < etc/ncp.cfg) - release_new=$(jq '.release' < etc/ncp.cfg) - issue_new=$( jq '.release_issue' < etc/ncp.cfg) - - echo "Migrating to distro $release_new" + php_ver_new=$(jq -r '.php_version' < etc/ncp.cfg) + release_new=$(jq -r '.release' < etc/ncp.cfg) + issue_new=$( jq -r '.release_issue' < etc/ncp.cfg) cfg="$(jq '.' "$NCPCFG")" cfg="$(jq '.php_version = "'$php_ver_new'"' <<<"$cfg")" cfg="$(jq '.release = "'$release_new'"' <<<"$cfg")" cfg="$(jq '.release_issue = '"$issue_new" <<<"$cfg")" - echo "$cfg" > "$NCPCFG" + echo "$cfg" > /usr/local/etc/ncp-recommended.cfg + + [[ -f /.dockerenv ]] && \ + msg="Update to $release_new available. Get the latest container to upgrade" || \ + msg="Update to $release_new available. Type 'sudo ncp-dist-upgrade' to upgrade" + echo "${msg}" + ncc notification:generate "ncp" "New distribution available" -l "${msg}" + wall "${msg}" + cat > /etc/update-motd.d/30ncp-dist-upgrade <<EOF +#!/bin/bash +new_cfg=/usr/local/etc/ncp-recommended.cfg +[[ -f "\${new_cfg}" ]] || exit 0 +echo -e "${msg}" +EOF +chmod +x /etc/update-motd.d/30ncp-dist-upgrade +} - is_active_app unattended-upgrades && run_app unattended-upgrades -} exit 0 @@ -181,4 +205,3 @@ exit 0 # along with this script; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA - diff --git a/updates/1.15.0.sh b/updates/1.15.0.sh index 8d79e30d..ab39d8af 100644 --- a/updates/1.15.0.sh +++ b/updates/1.15.0.sh @@ -6,20 +6,17 @@ set -e source /usr/local/etc/library.sh -# not for image builds, only live updates -[[ ! -f /.ncp-image ]] && { - - # docker images only - [[ -f /.docker-image ]] && { - : - } - - # for non docker images - [[ ! -f /.docker-image ]] && { - # Update btrfs-sync - wget -q https://raw.githubusercontent.com/nachoparker/btrfs-sync/master/btrfs-sync -O /usr/local/bin/btrfs-sync - } - -} # end - only live updates +# all images + +# docker images only +[[ -f /.docker-image ]] && { +: +} + +# for non docker images +[[ ! -f /.docker-image ]] && { +# Update btrfs-sync +wget -q https://raw.githubusercontent.com/nachoparker/btrfs-sync/master/btrfs-sync -O /usr/local/bin/btrfs-sync +} exit 0 |