diff options
author | nachoparker <nacho@ownyourbits.com> | 2019-07-02 04:15:46 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2019-07-06 06:43:54 +0300 |
commit | 35526ab9fcfc538b68a10bbf449d6b1fe5ea7d6d (patch) | |
tree | bf5f7762937f0fd38bb7463041e25726cc74bd16 | |
parent | 88da901eddff125b3e71d9706fbe02edffc659b3 (diff) |
build: use a system wide config file. Remove sury sources
Signed-off-by: nachoparker <nacho@ownyourbits.com>
-rw-r--r-- | Vagrantfile | 4 | ||||
-rw-r--r-- | armbian.sh | 12 | ||||
-rw-r--r-- | bin/ncp-suggestions | 4 | ||||
-rw-r--r-- | bin/ncp/BACKUPS/nc-restore.sh | 9 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-datadir.sh | 5 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-init.sh | 3 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-limits.sh | 5 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-nextcloud.sh | 9 | ||||
-rw-r--r-- | bin/ncp/NETWORKING/no-ip.sh | 9 | ||||
-rw-r--r-- | bin/ncp/UPDATES/nc-autoupdate-nc.sh | 11 | ||||
-rw-r--r-- | bin/ncp/UPDATES/nc-update-nextcloud.sh | 3 | ||||
-rwxr-xr-x | build-SD-armbian.sh | 4 | ||||
-rwxr-xr-x | build-SD-rpi.sh | 16 | ||||
-rwxr-xr-x | build-VM.sh | 1 | ||||
-rwxr-xr-x | build-docker.sh | 34 | ||||
-rw-r--r-- | docker/debian-ncp/Dockerfile | 7 | ||||
-rwxr-xr-x | docker/lamp/010lamp | 4 | ||||
-rw-r--r-- | docker/lamp/Dockerfile | 5 | ||||
-rw-r--r-- | docker/nextcloudpi/Dockerfile | 7 | ||||
-rw-r--r-- | etc/library.sh | 24 | ||||
-rw-r--r-- | etc/ncp.cfg | 9 | ||||
-rw-r--r-- | install.sh | 24 | ||||
-rw-r--r-- | lamp.sh | 28 | ||||
-rwxr-xr-x | update.sh | 15 | ||||
-rw-r--r-- | updates/1.13.6.sh | 3 |
25 files changed, 155 insertions, 100 deletions
diff --git a/Vagrantfile b/Vagrantfile index 07467283..2af828a1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,7 +13,8 @@ Vagrant.configure("2") do |config| vmname = "NCP Debian VM" - config.vm.box = "debian/stretch64" + release = ENV["DEB_RELEASE"] + config.vm.box = "debian/#{release}64" config.vm.box_check_update = false config.vm.hostname = "ncp-vm" @@ -21,6 +22,7 @@ Vagrant.configure("2") do |config| $script = <<-SHELL sudo su + set -e BRANCH=master #BRANCH=devel # uncomment to install devel apt-get update @@ -12,12 +12,16 @@ set -e -RELEASE=$1 +ARMBIAN_RELEASE=$1 LINUXFAMILY=$2 BOARD=$3 BUILD_DESKTOP=$4 -[[ "$RELEASE" != "stretch" ]] && { echo "Only stretch is supported by NextCloudPi" >&2; exit 1; } +cd /tmp/overlay +NCPCFG=etc/ncp.cfg +source etc/library.sh # sets RELEASE + +[[ "$ARMBIAN_RELEASE" != "$RELEASE" ]] && { echo "Only $RELEASE is supported by NextCloudPi" >&2; exit 1; } # need sudo access that does not expire during build chage -d -1 root @@ -26,12 +30,12 @@ chage -d -1 root touch /.ncp-image # install NCP -cd /tmp/overlay echo -e "\nInstalling NextCloudPi" -source etc/library.sh mkdir -p /usr/local/etc/ncp-config.d/ cp etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/ +cp etc/library.sh /usr/local/etc/ +cp etc/ncp.cfg /usr/local/etc/ install_app lamp.sh install_app bin/ncp/CONFIG/nc-nextcloud.sh diff --git a/bin/ncp-suggestions b/bin/ncp-suggestions index 5f20bd85..39f2ceda 100644 --- a/bin/ncp-suggestions +++ b/bin/ncp-suggestions @@ -16,8 +16,8 @@ OUT="$@" source /usr/local/etc/library.sh -grep -q "distribution|.*bian GNU/Linux 9,*" <<<"$OUT" || \ - echo -e "You are using an unsupported distro release. Please upgrade to latest Debian/Raspbian" +check_distro || \ + echo -e "You are using an outdated distro release. You should upgrade to latest Debian/Raspbian" is_active_app dnsmasq && \ grep -q "NAT loopback|no" <<<"$OUT" && \ diff --git a/bin/ncp/BACKUPS/nc-restore.sh b/bin/ncp/BACKUPS/nc-restore.sh index f94d6478..278a6ade 100644 --- a/bin/ncp/BACKUPS/nc-restore.sh +++ b/bin/ncp/BACKUPS/nc-restore.sh @@ -10,7 +10,7 @@ # install() -{ +{ cat > /usr/local/bin/ncp-restore <<'EOF' #!/bin/bash set -eE @@ -19,7 +19,8 @@ BACKUPFILE="$1" DBADMIN=ncadmin DBPASSWD="$( grep password /root/.my.cnf | sed 's|password=||' )" -PHPVER=7.2 + +source /usr/local/etc/library.sh # sets PHPVER DIR="$( cd "$( dirname "$BACKUPFILE" )" &>/dev/null && pwd )" #abspath @@ -123,7 +124,7 @@ if [[ $( ls "$TMPDIR" | wc -l ) -eq $NUMFILES ]]; then ### INCLUDEDATA=no situation -else +else echo "no datadir found in backup" DATADIR="$NCDIR"/data @@ -138,7 +139,7 @@ fi sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$DATADIR/.opcache|" /etc/php/${PHPVER}/mods-available/opcache.ini # tmp upload dir -mkdir -p "$DATADIR/tmp" +mkdir -p "$DATADIR/tmp" chown www-data:www-data "$DATADIR/tmp" sed -i "s|^;\?upload_tmp_dir =.*$|upload_tmp_dir = $DATADIR/tmp|" /etc/php/${PHPVER}/cli/php.ini sed -i "s|^;\?upload_tmp_dir =.*$|upload_tmp_dir = $DATADIR/tmp|" /etc/php/${PHPVER}/fpm/php.ini diff --git a/bin/ncp/CONFIG/nc-datadir.sh b/bin/ncp/CONFIG/nc-datadir.sh index 6731399a..8f087c54 100644 --- a/bin/ncp/CONFIG/nc-datadir.sh +++ b/bin/ncp/CONFIG/nc-datadir.sh @@ -8,9 +8,6 @@ # More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/ # - -PHPVER=7.2 - is_active() { local SRCDIR @@ -26,6 +23,8 @@ install() configure() { + source /usr/local/etc/library.sh # sets PHPVER + ## CHECKS local SRCDIR SRCDIR=$( cd /var/www/nextcloud; sudo -u www-data php occ config:system:get datadirectory ) || { diff --git a/bin/ncp/CONFIG/nc-init.sh b/bin/ncp/CONFIG/nc-init.sh index 2f940477..486c7dea 100644 --- a/bin/ncp/CONFIG/nc-init.sh +++ b/bin/ncp/CONFIG/nc-init.sh @@ -9,10 +9,11 @@ # DBADMIN=ncadmin -PHPVER=7.2 configure() { + source /usr/local/etc/library.sh # sets PHPVER + echo "Setting up a clean Nextcloud instance... wait until message 'NC init done'" # checks diff --git a/bin/ncp/CONFIG/nc-limits.sh b/bin/ncp/CONFIG/nc-limits.sh index b16bd06d..8c527401 100644 --- a/bin/ncp/CONFIG/nc-limits.sh +++ b/bin/ncp/CONFIG/nc-limits.sh @@ -8,11 +8,10 @@ # More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/ # -PHPVER=7.2 - - configure() { + source /usr/local/etc/library.sh # sets PHPVER + # Set auto memory limit to 75% of the total memory local TOTAL_MEM="$( free -b | sed -n 2p | awk '{ print $2 }' )" AUTOMEM=$(( TOTAL_MEM * 75 / 100 )) diff --git a/bin/ncp/CONFIG/nc-nextcloud.sh b/bin/ncp/CONFIG/nc-nextcloud.sh index 007cf478..fdbb5f32 100644 --- a/bin/ncp/CONFIG/nc-nextcloud.sh +++ b/bin/ncp/CONFIG/nc-nextcloud.sh @@ -10,7 +10,6 @@ DBADMIN=ncadmin REDIS_MEM=3gb -PHPVER=7.2 APTINSTALL="apt-get install -y --no-install-recommends" export DEBIAN_FRONTEND=noninteractive @@ -20,7 +19,7 @@ install() # During build, this step is run before ncp.sh. Avoid executing twice [[ -f /usr/lib/systemd/system/nc-provisioning.service ]] && return 0 - local RELEASE=stretch + source /usr/local/etc/library.sh # sets PHPVER RELEASE # Optional packets for Nextcloud and Apps apt-get update @@ -39,7 +38,7 @@ install() rm /usr/bin/newaliases mv /newaliases /usr/bin/newaliases } - + $APTINSTALL redis-server $APTINSTALL -t $RELEASE php${PHPVER}-redis @@ -59,7 +58,7 @@ install() service redis-server restart update-rc.d redis-server enable service php${PHPVER}-fpm restart - + # service to randomize passwords on first boot mkdir -p /usr/lib/systemd/system cat > /usr/lib/systemd/system/nc-provisioning.service <<'EOF' @@ -235,7 +234,7 @@ EOF echo "*/15 * * * * php -f /var/www/nextcloud/cron.php" > /tmp/crontab_http crontab -u www-data /tmp/crontab_http rm /tmp/crontab_http - + echo "Don't forget to run nc-init" } diff --git a/bin/ncp/NETWORKING/no-ip.sh b/bin/ncp/NETWORKING/no-ip.sh index 0948b3b1..6e1c910d 100644 --- a/bin/ncp/NETWORKING/no-ip.sh +++ b/bin/ncp/NETWORKING/no-ip.sh @@ -1,6 +1,6 @@ #!/bin/bash -# no-ip.org installation on Raspbian +# no-ip.org installation on NextCloudPi # # Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> # GPL licensed (see end of file) * Use at your own risk! @@ -72,7 +72,7 @@ EOF return 0 } -configure() +configure() { service noip2 stop [[ $ACTIVE != "yes" ]] && { update-rc.d noip2 disable; return 0; } @@ -94,10 +94,7 @@ configure() cleanup() { - # this uninstalls udiskie, commented out - # udiskie with these dependencies fixed in Buster - # apt-get purge -y make gcc libc-dev - : + apt-get purge -y make gcc libc-dev } # License diff --git a/bin/ncp/UPDATES/nc-autoupdate-nc.sh b/bin/ncp/UPDATES/nc-autoupdate-nc.sh index 148324d1..ee2a5669 100644 --- a/bin/ncp/UPDATES/nc-autoupdate-nc.sh +++ b/bin/ncp/UPDATES/nc-autoupdate-nc.sh @@ -8,13 +8,12 @@ # More at: https://ownyourbits.com # +# just change NCVER and re-activate in update.sh to upgrade users +source /usr/local/etc/library.sh # sets NCVER -# just change this value and re-activate in update.sh to upgrade users -VERSION=15.0.8 - -configure() +configure() { - [[ "$ACTIVE" != "yes" ]] && { + [[ "$ACTIVE" != "yes" ]] && { rm -f /etc/cron.daily/ncp-autoupdate-nc echo "automatic Nextcloud updates disabled" return 0 @@ -24,7 +23,7 @@ configure() #!/bin/bash echo -e "[ncp-update-nc]" >> /var/log/ncp.log -/usr/local/bin/ncp-update-nc "$VERSION" 2>&1 | tee -a /var/log/ncp.log +/usr/local/bin/ncp-update-nc "$NCVER" 2>&1 | tee -a /var/log/ncp.log if [[ \${PIPESTATUS[0]} -eq 0 ]]; then diff --git a/bin/ncp/UPDATES/nc-update-nextcloud.sh b/bin/ncp/UPDATES/nc-update-nextcloud.sh index ec1dd127..3f53fdaa 100644 --- a/bin/ncp/UPDATES/nc-update-nextcloud.sh +++ b/bin/ncp/UPDATES/nc-update-nextcloud.sh @@ -8,7 +8,8 @@ # More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ # -LATEST=15.0.8 +source /usr/local/etc/library.sh # sets NCVER +LATEST="$NCVER" configure() { diff --git a/build-SD-armbian.sh b/build-SD-armbian.sh index 4b95e9ef..6af6d872 100755 --- a/build-SD-armbian.sh +++ b/build-SD-armbian.sh @@ -11,12 +11,14 @@ #CLEAN=0 # Pass this envvar to avoid cleaning download cache BOARD="$1" BNAME="${2:-$1}" +NCPCFG=etc/ncp.cfg IMG="NextCloudPi_${BNAME}_$( date "+%m-%d-%y" ).img" IMG=tmp/"$IMG" set -e source buildlib.sh +source etc/library.sh # sets RELEASE prepare_dirs # tmp cache output @@ -36,7 +38,7 @@ rsync -Aax --delete --exclude-from .gitignore --exclude *.img --exclude *.bz2 . cat > armbian/config-docker-guest.conf <<EOF BOARD="$BOARD" BRANCH=default -RELEASE=stretch +RELEASE=$RELEASE KERNEL_ONLY=no KERNEL_CONFIGURE=no BUILD_DESKTOP=no diff --git a/build-SD-rpi.sh b/build-SD-rpi.sh index 1f8c5a5b..178913bc 100755 --- a/build-SD-rpi.sh +++ b/build-SD-rpi.sh @@ -43,12 +43,12 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ sudo chroot raspbian_root /bin/bash <<'EOFCHROOT' set -e + # avoid constant annoying spam due to qemu bug - ERROR: ld.so: object '/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so' from /etc/ld.so.preload + mv /etc/ld.so.preload / + # mark the image as an image build touch /.ncp-image - # update packages - apt-get update - # As of 10-2018 this upgrades raspi-kernel and messes up wifi and BTRFS #apt-get upgrade -y #apt-get dist-upgrade -y @@ -60,9 +60,11 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ # install everything cd /tmp/ncp-build || exit 1 - source etc/library.sh mkdir -p /usr/local/etc/ncp-config.d cp etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/ + cp etc/ncp.cfg /usr/local/etc/ + cp etc/library.sh /usr/local/etc/ + source etc/library.sh install_app lamp.sh install_app bin/ncp/CONFIG/nc-nextcloud.sh run_app_unsafe bin/ncp/CONFIG/nc-nextcloud.sh @@ -78,15 +80,17 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ cfg="$(jq '.params[1].value = "pi"' <<<"$cfg")" cfg="$(jq '.params[2].value = "raspberry"' <<<"$cfg")" cfg="$(jq '.params[3].value = "raspberry"' <<<"$cfg")" - echo "$cfg" > etc/ncp-config.d/SSH.cfg + echo "$cfg" > /usr/local/etc/ncp-config.d/SSH.cfg rm -rf /tmp/ncp-build + + mv /ld.so.preload /etc EOFCHROOT clean_chroot_raspbian ## pack - + TAR=output/"$( basename "$IMG" .img ).tar.bz2" pack_image "$IMG" "$TAR" diff --git a/build-VM.sh b/build-VM.sh index 5b53cfb8..c96cde08 100755 --- a/build-VM.sh +++ b/build-VM.sh @@ -30,6 +30,7 @@ prepare_dirs # tmp cache output ## BUILD NCP echo -e "\e[1m\n[ Build NCP ]\e[0m" +export DEB_RELEASE=$(jq -r .release < etc/ncp.cfg) vagrant destroy -f vagrant box update vagrant up --provider=libvirt --provision diff --git a/build-docker.sh b/build-docker.sh index 423d12bb..40fd70ce 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -8,29 +8,31 @@ set -e version=$(git describe --tags --always) version=${version%-*-*} +release=$(jq -r .release < etc/ncp.cfg) function docker_build() { DOCKER_BUILDKIT=1 docker build --progress=plain . "$@"; } function build_arch() { - local arch="${1}" - local arch_qemu="${2}" - local ncp_tag="${3:-$arch}" - - docker_build -f docker/debian-ncp/Dockerfile -t ownyourbits/debian-ncp-${arch}:latest --pull --build-arg arch=${arch} --build-arg arch_qemu=${arch_qemu} - docker_build -f docker/lamp/Dockerfile -t ownyourbits/lamp-${arch}:latest --build-arg arch=${arch} - docker_build -f docker/nextcloud/Dockerfile -t ownyourbits/nextcloud-${arch}:latest --build-arg arch=${arch} - docker_build -f docker/nextcloudpi/Dockerfile -t ownyourbits/nextcloudpi-${arch}:latest --build-arg arch=${arch} - - docker tag ownyourbits/debian-ncp-${arch}:latest ownyourbits/debian-ncp-${ncp_tag}:"${version}" - docker tag ownyourbits/lamp-${arch}:latest ownyourbits/lamp-${ncp_tag}:"${version}" - docker tag ownyourbits/nextcloud-${arch}:latest ownyourbits/nextcloud-${ncp_tag}:"${version}" - docker tag ownyourbits/nextcloudpi-${arch}:latest ownyourbits/nextcloudpi-${ncp_tag}:"${version}" + local release="${1}" + local arch="${2}" + local arch_qemu="${3}" + local ncp_tag="${4:-$arch}" + + docker_build -f docker/debian-ncp/Dockerfile -t ownyourbits/debian-ncp-${ncp_tag}:latest --pull --build-arg release=${release} --build-arg arch=${arch} --build-arg arch_qemu=${arch_qemu} + docker_build -f docker/lamp/Dockerfile -t ownyourbits/lamp-${ncp_tag}:latest --build-arg release=${release} --build-arg arch=${ncp_tag} + docker_build -f docker/nextcloud/Dockerfile --no-cache -t ownyourbits/nextcloud-${ncp_tag}:latest --build-arg release=${release} --build-arg arch=${ncp_tag} + docker_build -f docker/nextcloudpi/Dockerfile -t ownyourbits/nextcloudpi-${ncp_tag}:latest --build-arg release=${release} --build-arg arch=${ncp_tag} --build-arg ncp_ver=${version} + + docker tag ownyourbits/debian-ncp-${ncp_tag}:latest ownyourbits/debian-ncp-${ncp_tag}:"${version}" + docker tag ownyourbits/lamp-${ncp_tag}:latest ownyourbits/lamp-${ncp_tag}:"${version}" + docker tag ownyourbits/nextcloud-${ncp_tag}:latest ownyourbits/nextcloud-${ncp_tag}:"${version}" + docker tag ownyourbits/nextcloudpi-${ncp_tag}:latest ownyourbits/nextcloudpi-${ncp_tag}:"${version}" } -[[ "$@" =~ "x86" ]] && build_arch amd64 x86_64 x86 -[[ "$@" =~ "armhf" ]] && build_arch armhf arm -[[ "$@" =~ "arm64" ]] && build_arch arm64v8 aarch64 arm64 +[[ "$@" =~ "x86" ]] && build_arch "${release}" amd64 x86_64 x86 +[[ "$@" =~ "armhf" ]] && build_arch "${release}" arm32v7 arm armhf +[[ "$@" =~ "arm64" ]] && build_arch "${release}" arm64v8 aarch64 arm64 # License diff --git a/docker/debian-ncp/Dockerfile b/docker/debian-ncp/Dockerfile index 3d4e68bf..ff5717d0 100644 --- a/docker/debian-ncp/Dockerfile +++ b/docker/debian-ncp/Dockerfile @@ -1,10 +1,13 @@ ARG arch=armhf ARG arch_qemu=arm -FROM debian:stretch-slim AS qemu +ARG release=buster +FROM debian:${release}-slim AS qemu RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends qemu-user-static -FROM ${arch}/debian:stretch-slim +ARG release +ARG arch_qemu +FROM ${arch}/debian:${release}-slim ARG arch_qemu diff --git a/docker/lamp/010lamp b/docker/lamp/010lamp index 5bb2dbaa..fb8f8320 100755 --- a/docker/lamp/010lamp +++ b/docker/lamp/010lamp @@ -1,8 +1,6 @@ #!/bin/bash -source /usr/local/etc/library.sh - -PHPVER=7.2 +source /usr/local/etc/library.sh # sets PHPVER set -e diff --git a/docker/lamp/Dockerfile b/docker/lamp/Dockerfile index c0b9276f..393a4736 100644 --- a/docker/lamp/Dockerfile +++ b/docker/lamp/Dockerfile @@ -10,11 +10,14 @@ SHELL ["/bin/bash", "-c"] ENV DOCKERBUILD 1 -COPY etc/library.sh lamp.sh /usr/local/etc/ +COPY etc/ncp.cfg etc/library.sh lamp.sh /usr/local/etc/ RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ # installation +apt-get update; \ +apt-get install --no-install-recommends -y jq; \ + source /usr/local/etc/library.sh; \ set +x; \ install_app /usr/local/etc/lamp.sh; \ diff --git a/docker/nextcloudpi/Dockerfile b/docker/nextcloudpi/Dockerfile index 6ff91bb3..f41e08bd 100644 --- a/docker/nextcloudpi/Dockerfile +++ b/docker/nextcloudpi/Dockerfile @@ -4,6 +4,8 @@ ARG arch=armhf FROM ownyourbits/nextcloud-${arch} +ARG ncp_ver=v0.0.0 + LABEL maintainer="Ignacio Núñez Hernanz <nacho@ownyourbits.com>" SHELL ["/bin/bash", "-c"] @@ -62,7 +64,10 @@ find /var/log -type f -exec rm {} \; ; \ rm -rf /usr/share/man/*; \ rm -rf /usr/share/doc/*; \ rm -f /var/log/alternatives.log /var/log/apt/*; \ -rm /var/cache/debconf/*-old; +rm /var/cache/debconf/*-old; \ + +# set version +echo "${ncp_ver}" > /usr/local/etc/ncp-version COPY docker/nextcloudpi/000ncp /etc/services-enabled.d/ COPY bin/ncp/CONFIG/nc-init.sh / diff --git a/etc/library.sh b/etc/library.sh index d2ec12b6..3ddd4c7f 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -8,8 +8,21 @@ # More at ownyourbits.com # +NCPCFG=${NCPCFG:-/usr/local/etc/ncp.cfg} CFGDIR=/usr/local/etc/ncp-config.d BINDIR=/usr/local/bin/ncp +BINDIR=/usr/local/bin/ncp + +command -v jq &>/dev/null || { + apt-get update + apt-get install -y --no-install-recommends jq +} + +[[ -f "$NCPCFG" ]] && { + NCVER=$( jq -r .nextcloud_version < "$NCPCFG") + PHPVER=$( jq -r .php_version < "$NCPCFG") + RELEASE=$(jq -r .release < "$NCPCFG") +} function configure_app() { @@ -257,6 +270,17 @@ function is_more_recent_than() return 0 } +function check_distro() +{ + local cfg="${1:-$NCPCFG}" + local len="$(jq '.release_issue | length' < "$cfg")" + for i in $(seq 0 $((len-1))); do + local supported=$(jq -r .release_issue[$i] < "$cfg") + grep -q "$supported" /etc/issue && return 0 + done + return 1 +} + # License # # This script is free software; you can redistribute it and/or modify it diff --git a/etc/ncp.cfg b/etc/ncp.cfg new file mode 100644 index 00000000..2b721009 --- /dev/null +++ b/etc/ncp.cfg @@ -0,0 +1,9 @@ +{ + "nextcloud_version": "15.0.8", + "php_version": "7.2", + "release": "stretch", + "release_issue": [ + "Debian GNU/Linux 9", + "Raspbian GNU/Linux 9" + ] +} @@ -5,7 +5,7 @@ # Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> # GPL licensed (see end of file) * Use at your own risk! # -# Usage: ./install.sh +# Usage: ./install.sh # # more details at https://ownyourbits.com @@ -22,12 +22,6 @@ trap "rm -rf \"${TMPDIR}\" ; exit 0" 0 1 2 3 15 exit 1 } -# check_distro -grep -q -e "Debian GNU/Linux 9" -e "Raspbian GNU/Linux 9" /etc/issue || { - echo "distro not supported"; - exit 1; -} - # check installed software type mysqld &>/dev/null && echo ">>> WARNING: existing mysqld configuration will be changed <<<" @@ -37,17 +31,27 @@ apt-get update apt-get install --no-install-recommends -y wget ca-certificates sudo pushd "$TMPDIR" -wget -O- --content-disposition https://github.com/nextcloud/nextcloudpi/archive/"$BRANCH"/latest.tar.gz \ +wget -qO- --content-disposition https://github.com/nextcloud/nextcloudpi/archive/"$BRANCH"/latest.tar.gz \ | tar -xz \ || exit 1 cd - && cd "$TMPDIR"/nextcloudpi-"$BRANCH" # install NCP -echo -e "\nInstalling NextCloudPi" +echo -e "\nInstalling NextCloudPi..." source etc/library.sh +# check distro +check_distro etc/ncp.cfg || { + echo "ERROR: distro not supported:"; + cat /etc/issue + exit 1; +} + + mkdir -p /usr/local/etc/ncp-config.d/ cp etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/ +cp etc/library.sh /usr/local/etc/ +cp etc/ncp.cfg /usr/local/etc/ install_app lamp.sh install_app bin/ncp/CONFIG/nc-nextcloud.sh @@ -60,7 +64,7 @@ bash /usr/local/bin/ncp-provisioning.sh popd IFACE="$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )" -IP="$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 )" +IP="$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 )" echo "Done. @@ -1,12 +1,12 @@ #!/bin/bash -# Nextcloud LAMP base installation on Raspbian +# Nextcloud LAMP base installation on Raspbian # # Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> # GPL licensed (see end of file) * Use at your own risk! # # Usage: -# +# # ./installer.sh lamp.sh <IP> (<img>) # # See installer.sh instructions for details @@ -19,25 +19,13 @@ # More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ # -PHPVER=7.2 +source /usr/local/etc/library.sh # sets PHPVER RELEASE + APTINSTALL="apt-get install -y --no-install-recommends" export DEBIAN_FRONTEND=noninteractive install() { - # GET PHP 7.2 SOURCES - ########################################## - - local RELEASE=stretch - apt-get update - $APTINSTALL apt-transport-https gnupg2 wget ca-certificates - echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/php.list - wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add - - wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg - - # INSTALL - ########################################## - apt-get update $APTINSTALL apt-utils cron curl $APTINSTALL apache2 @@ -59,7 +47,7 @@ install() mkdir -p /run/mysqld chown mysql /run/mysqld - # CONFIGURE APACHE + # CONFIGURE APACHE ########################################## cat >/etc/apache2/conf-available/http2.conf <<EOF @@ -110,7 +98,7 @@ opcache.file_cache=/tmp; EOF a2enmod http2 - a2enconf http2 + a2enconf http2 a2enmod proxy_fcgi setenvif a2enconf php${PHPVER}-fpm a2enmod rewrite @@ -118,7 +106,7 @@ EOF a2enmod dir a2enmod mime a2enmod ssl - + echo "ServerName localhost" >> /etc/apache2/apache2.conf @@ -161,7 +149,7 @@ EOF # launch mariadb if not already running if ! pgrep -c mysqld &>/dev/null; then - mysqld & + mysqld & fi # wait for mariadb @@ -61,7 +61,18 @@ mkdir -p "$CONFDIR" # copy all files in bin and etc cp -r bin/* /usr/local/bin/ -find etc -maxdepth 1 -type f -exec cp '{}' /usr/local/etc \; +find etc -maxdepth 1 -type f ! -path etc/ncp.cfg -exec cp '{}' /usr/local/etc \; +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) +nc_version=$(jq -r .nextcloud_version < etc/ncp.cfg) +cfg="$(jq '.' /usr/local/etc/ncp.cfg)" +cfg="$(jq ".nextcloud_version = \"$nc_version\"" <<<"$cfg")" +echo "$cfg" > /usr/local/etc/ncp.cfg + +cfg="$(jq '.' etc/ncp-config.d/nc-nextcloud.cfg)" +cfg="$(jq ".params[0].value = \"$nc_version\"" <<<"$cfg")" +echo "$cfg" > /usr/local/etc/ncp-config.d/nc-nextcloud.cfg # install new entries of ncp-config and update others for file in etc/ncp-config.d/*; do @@ -125,6 +136,8 @@ cp -r ncp-app /var/www/ # update old images ./run_update_history.sh "$UPDATESDIR" + # update to the latest NC version + is_active_app nc-autoupdate-nc && run_app nc-autoupdate-nc } exit 0 diff --git a/updates/1.13.6.sh b/updates/1.13.6.sh index 0e9c49e4..8877e868 100644 --- a/updates/1.13.6.sh +++ b/updates/1.13.6.sh @@ -33,9 +33,6 @@ EOF 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 - # previews settings ncc config:app:set previewgenerator squareSizes --value="32" ncc config:app:set previewgenerator widthSizes --value="128 256 512" |