diff options
-rw-r--r-- | bin/ncp/BACKUPS/nc-snapshot-sync.sh | 2 | ||||
-rw-r--r-- | build/armbian/armbian.sh | 3 | ||||
-rw-r--r-- | build/armbian/config-odroidc2.conf | 5 | ||||
-rw-r--r-- | build/armbian/config-odroidhc4.conf | 5 | ||||
-rw-r--r-- | build/armbian/config-odroidxu4.conf | 5 | ||||
-rw-r--r-- | build/armbian/config-orangepizeroplus2-h5.conf | 4 | ||||
-rwxr-xr-x | build/build-LXC.sh | 6 | ||||
-rwxr-xr-x | build/build-LXD.sh | 5 | ||||
-rwxr-xr-x | build/build-SD-armbian.sh | 7 | ||||
-rwxr-xr-x | build/build-SD-berryboot.sh | 2 | ||||
-rwxr-xr-x | build/build-SD-rpi.sh | 25 | ||||
-rwxr-xr-x | build/build-VM.sh | 3 | ||||
-rwxr-xr-x | build/build-docker.sh | 2 | ||||
-rw-r--r-- | build/buildlib.sh | 2 | ||||
-rw-r--r-- | install.sh | 4 | ||||
-rw-r--r-- | post-inst.sh | 16 |
16 files changed, 43 insertions, 53 deletions
diff --git a/bin/ncp/BACKUPS/nc-snapshot-sync.sh b/bin/ncp/BACKUPS/nc-snapshot-sync.sh index 2f965bd4..f27bf46a 100644 --- a/bin/ncp/BACKUPS/nc-snapshot-sync.sh +++ b/bin/ncp/BACKUPS/nc-snapshot-sync.sh @@ -15,7 +15,6 @@ install() apt-get install -y --no-install-recommends pv openssh-client wget https://raw.githubusercontent.com/nachoparker/btrfs-sync/master/btrfs-sync -O /usr/local/bin/btrfs-sync chmod +x /usr/local/bin/btrfs-sync - if ! [[ -f /root/.ssh/id_rsa ]]; then ssh-keygen -N "" -f /root/.ssh/id_rsa; fi } configure() @@ -29,6 +28,7 @@ configure() # checks [[ -d "$SNAPDIR" ]] || { echo "$SNAPDIR does not exist"; return 1; } + if ! [[ -f /root/.ssh/id_rsa ]]; then ssh-keygen -N "" -f /root/.ssh/id_rsa; fi [[ "$DESTINATION" =~ : ]] && { local NET="$( sed 's|:.*||' <<<"$DESTINATION" )" diff --git a/build/armbian/armbian.sh b/build/armbian/armbian.sh index 1401b022..85e5f742 100644 --- a/build/armbian/armbian.sh +++ b/build/armbian/armbian.sh @@ -26,9 +26,6 @@ source etc/library.sh # sets RELEASE # need sudo access that does not expire during build chage -d -1 root -# indicate that this will be an Armbian image build -touch /.ncp-image - # install NCP echo -e "\nInstalling NextCloudPi" diff --git a/build/armbian/config-odroidc2.conf b/build/armbian/config-odroidc2.conf deleted file mode 100644 index e3b8e8b5..00000000 --- a/build/armbian/config-odroidc2.conf +++ /dev/null @@ -1,5 +0,0 @@ -# -# Place here configuration options that differ from standard NCP build options -# - -#BRANCH=dev diff --git a/build/armbian/config-odroidhc4.conf b/build/armbian/config-odroidhc4.conf deleted file mode 100644 index e3b8e8b5..00000000 --- a/build/armbian/config-odroidhc4.conf +++ /dev/null @@ -1,5 +0,0 @@ -# -# Place here configuration options that differ from standard NCP build options -# - -#BRANCH=dev diff --git a/build/armbian/config-odroidxu4.conf b/build/armbian/config-odroidxu4.conf deleted file mode 100644 index e3b8e8b5..00000000 --- a/build/armbian/config-odroidxu4.conf +++ /dev/null @@ -1,5 +0,0 @@ -# -# Place here configuration options that differ from standard NCP build options -# - -#BRANCH=dev diff --git a/build/armbian/config-orangepizeroplus2-h5.conf b/build/armbian/config-orangepizeroplus2-h5.conf index 6d5ecaf2..8f7d3a22 100644 --- a/build/armbian/config-orangepizeroplus2-h5.conf +++ b/build/armbian/config-orangepizeroplus2-h5.conf @@ -1 +1,5 @@ +# +# Place here configuration options that differ from standard NCP build options +# + BRANCH=next diff --git a/build/build-LXC.sh b/build/build-LXC.sh index e909ff11..969e9ebb 100755 --- a/build/build-LXC.sh +++ b/build/build-LXC.sh @@ -11,6 +11,8 @@ set -e source build/buildlib.sh +echo -e "\e[1m\n[ Build NCP LXC ]\e[0m" + #CLEAN=0 # Pass this envvar to skip cleaning download cache IMG="NextCloudPi_LXC_$( date "+%m-%d-%y" ).img" IMG=tmp/"$IMG" @@ -29,15 +31,13 @@ prepare_dirs # tmp cache output ## BUILD NCP -echo -e "\e[1m\n[ Build NCP ]\e[0m" - # TODO sudo sudo lxc-destroy ncp -f sudo lxc-create -n ncp -t download -B btrfs -- --dist debian --release buster --arch amd64 # TODO vars for distro and stuff sudo cp lxc_config /var/lib/lxc/ncp/config sudo lxc-start -n ncp sudo lxc-attach -n ncp --clear-env -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' -sudo lxc-attach -n ncp --clear-env -- bash /build/install.sh +sudo lxc-attach -n ncp --clear-env -- CODE_DIR="$(pwd)" bash /build/install.sh sudo lxc-attach -n ncp --clear-env -- bash -c 'source /build/etc/library.sh; run_app_unsafe /build/post-inst.sh' sudo lxc-attach -n ncp --clear-env -- poweroff diff --git a/build/build-LXD.sh b/build/build-LXD.sh index b1cb2cf5..06f44dec 100755 --- a/build/build-LXD.sh +++ b/build/build-LXD.sh @@ -11,6 +11,8 @@ set -e source build/buildlib.sh +echo -e "\e[1m\n[ Build NCP LXD ]\e[0m" + #CLEAN=0 # Pass this envvar to skip cleaning download cache IMG="NextCloudPi_LXD_$( date "+%m-%d-%y" ).img" IMG=tmp/"$IMG" @@ -29,14 +31,13 @@ prepare_dirs # tmp cache output ## BUILD NCP -echo -e "\e[1m\n[ Build NCP ]\e[0m" - lxc delete -f ncp 2>/dev/null || true systemd-run --user --scope -p "Delegate=yes" lxc launch images:debian/buster ncp lxc config device add ncp buildcode disk source="$(pwd)" path=/build lxc exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' lxc exec ncp -- bash -c 'CODE_DIR=/build bash /build/install.sh' lxc exec ncp -- bash -c 'source /build/etc/library.sh; run_app_unsafe /build/post-inst.sh' +lxc stop ncp lxc config device remove ncp buildcode lxc publish ncp -f --alias ncp/"${version}" diff --git a/build/build-SD-armbian.sh b/build/build-SD-armbian.sh index 93069e53..f939dc06 100755 --- a/build/build-SD-armbian.sh +++ b/build/build-SD-armbian.sh @@ -8,17 +8,20 @@ # Usage: ./build-SD-armbian.sh <board_code> [<board_name>] # +set -e +source build/buildlib.sh + #CLEAN=0 # Pass this envvar to avoid cleaning download cache BOARD="$1" BNAME="${2:-$1}" NCPCFG=etc/ncp.cfg +echo -e "\e[1m\n[ Build NCP ${BNAME} ]\e[0m" + IMG="NextCloudPi_${BNAME}_$( date "+%m-%d-%y" ).img" IMG=tmp/"$IMG" TAR=output/"$( basename "$IMG" .img ).tar.bz2" -set -e -source build/buildlib.sh test -f "$TAR" && { echo "$TAR already exists. Skipping... "; exit 0; } diff --git a/build/build-SD-berryboot.sh b/build/build-SD-berryboot.sh index 115ed994..da2fba0f 100755 --- a/build/build-SD-berryboot.sh +++ b/build/build-SD-berryboot.sh @@ -11,6 +11,8 @@ set -e source build/buildlib.sh +echo -e "\e[1m\n[ Build NCP Berryboot ]\e[0m" + SRC="$1" IMG="NextCloudPi_RPi_Berryboot_$( date "+%m-%d-%y" ).img" TAR=output/"$( basename "$IMG" .img ).tar.bz2" diff --git a/build/build-SD-rpi.sh b/build/build-SD-rpi.sh index 7f7ccd46..3f1bae1e 100755 --- a/build/build-SD-rpi.sh +++ b/build/build-SD-rpi.sh @@ -11,8 +11,10 @@ set -e source build/buildlib.sh +echo -e "\e[1m\n[ Build NCP Raspberry Pi ]\e[0m" + URL="https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2020-08-24/2020-08-20-raspios-buster-arm64-lite.zip" -SIZE=3G # Raspbian image size +SIZE=4G # Raspbian image size #CLEAN=0 # Pass this envvar to skip cleaning download cache IMG="NextCloudPi_RPi_$( date "+%m-%d-%y" ).img" TAR=output/"$( basename "$IMG" .img ).tar.bz2" @@ -38,7 +40,6 @@ rm -f ncp-web/{wizard.cfg,ncp-web.cfg} ## BUILD NCP -echo -e "\e[1m\n[ Build NCP ]\e[0m" prepare_chroot_raspbian "$IMG" mkdir raspbian_root/tmp/ncp-build @@ -48,9 +49,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ sudo chroot raspbian_root /bin/bash <<'EOFCHROOT' set -e - # mark the image as an image build - touch /.ncp-image - # allow oldstable apt-get update --allow-releaseinfo-change @@ -63,20 +61,9 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ #$APTINSTALL rpi-update #echo -e "y\n" | PRUNE_MODULES=1 rpi-update - # install everything + # install NCP cd /tmp/ncp-build || 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/ncp.cfg /usr/local/etc/ - cp etc/library.sh /usr/local/etc/ - cp -r etc/ncp-templates /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 - install_app ncp.sh - run_app_unsafe bin/ncp/CONFIG/nc-init.sh - run_app_unsafe post-inst.sh + CODE_DIR="$(pwd)" bash install.sh # work around dhcpcd Raspbian bug # https://lb.raspberrypi.org/forums/viewtopic.php?t=230779 @@ -95,6 +82,8 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ cfg="$(jq '.params[3].value = "raspberry"' <<<"$cfg")" echo "$cfg" > /usr/local/etc/ncp-config.d/SSH.cfg + $ cleanup + source etc/library.sh && run_app_unsafe post-inst.sh rm -rf /tmp/ncp-build EOFCHROOT diff --git a/build/build-VM.sh b/build/build-VM.sh index 72cfa186..b730bb42 100755 --- a/build/build-VM.sh +++ b/build/build-VM.sh @@ -11,6 +11,8 @@ set -e source build/buildlib.sh +echo -e "\e[1m\n[ Build NCP VM ]\e[0m" + IP=${1:-192.168.0.145} # For QEMU automated testing (optional) SIZE=3G # Raspbian image size #CLEAN=0 # Pass this envvar to skip cleaning download cache @@ -32,7 +34,6 @@ 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) cd build/ vagrant destroy -f diff --git a/build/build-docker.sh b/build/build-docker.sh index 019026cf..e0709f31 100755 --- a/build/build-docker.sh +++ b/build/build-docker.sh @@ -18,6 +18,8 @@ function build_arch() local arch_qemu="${3}" local ncp_tag="${4:-$arch}" + echo -e "\e[1m\n[ Build NCP Docker ${arch} ]\e[0m" + docker_build -f build/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 build/docker/lamp/Dockerfile -t ownyourbits/lamp-${ncp_tag}:latest --build-arg release=${release} --build-arg arch=${ncp_tag} docker_build -f build/docker/nextcloud/Dockerfile -t ownyourbits/nextcloud-${ncp_tag}:latest --build-arg release=${release} --build-arg arch=${ncp_tag} diff --git a/build/buildlib.sh b/build/buildlib.sh index d589111f..875da0b6 100644 --- a/build/buildlib.sh +++ b/build/buildlib.sh @@ -222,7 +222,7 @@ EOF umount_raspbian } -function prepare_sshd() +function prepare_sshd_raspbian() { local IMG="$1" mount_raspbian_boot "$IMG" || return 1 @@ -66,9 +66,11 @@ rm /usr/local/etc/ncp-config.d/nc-nextcloud.cfg # armbian overlay is ro systemctl restart mysqld # TODO this shouldn't be necessary, but somehow it's needed in Debian 9.6. Fixme install_app ncp.sh run_app_unsafe bin/ncp/CONFIG/nc-init.sh -bash /usr/local/bin/ncp-provisioning.sh rm /.ncp-image +# skip on Armbian / Vagrant / LXD ... +[[ "${CODE_DIR}" != "" ]] || bash /usr/local/bin/ncp-provisioning.sh + cd - rm -rf "${TMPDIR}" diff --git a/post-inst.sh b/post-inst.sh index 2c07c604..b7b0cf60 100644 --- a/post-inst.sh +++ b/post-inst.sh @@ -10,12 +10,15 @@ configure() { - # stop mysqld and redis - mysqladmin -u root shutdown || true - kill $( cat /run/redis/redis-server.pid ) || true - [[ -f /run/crond.pid ]] && kill $( cat /run/crond.pid ) - pkill -f php-fpm || true - pkill -f notify_push || true +( + set +e + + # stop services + pkill -x redis-server + pgrep -x mysqld &>/dev/null && mysqladmin -u root shutdown + [[ -f /run/crond.pid ]] && kill "$(cat /run/crond.pid)" + pkill -f php-fpm + pkill -f notify_push # cleanup all NCP extras source /usr/local/etc/library.sh @@ -30,6 +33,7 @@ configure() # clean build flags rm -f /.ncp-image +) } # License |