diff options
author | nachoparker <nacho@ownyourbits.com> | 2020-08-28 18:52:02 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2020-11-28 00:54:34 +0300 |
commit | 92156694f683d490a6bc2426e20dd356789d913b (patch) | |
tree | 3b53f52550b4a0f5657112c474e1dcaebe547c2a | |
parent | ab9184cadd91ff3fbacf4e82aa582edccd5a7fc6 (diff) |
pre-initialize docker image
Signed-off-by: nachoparker <nacho@ownyourbits.com>
-rw-r--r-- | bin/ncp/CONFIG/nc-init.sh | 14 | ||||
-rw-r--r-- | bin/ncp/NETWORKING/dnsmasq.sh | 8 | ||||
-rwxr-xr-x | docker/lamp/010lamp | 3 | ||||
-rwxr-xr-x | docker/nextcloud/020nextcloud | 8 | ||||
-rw-r--r-- | docker/nextcloud/Dockerfile | 6 | ||||
-rw-r--r-- | docker/nextcloudpi/Dockerfile | 8 |
6 files changed, 17 insertions, 30 deletions
diff --git a/bin/ncp/CONFIG/nc-init.sh b/bin/ncp/CONFIG/nc-init.sh index e7a7b808..629e88ac 100644 --- a/bin/ncp/CONFIG/nc-init.sh +++ b/bin/ncp/CONFIG/nc-init.sh @@ -30,13 +30,11 @@ configure() fi # wait for mariadb - pgrep -x mysqld &>/dev/null || { - echo "mariaDB process not found. Waiting..." - while :; do - [[ -S /run/mysqld/mysqld.sock ]] && break - sleep 0.5 - done - } + while :; do + [[ -S /run/mysqld/mysqld.sock ]] && break + sleep 0.5 + done + sleep 1 # workaround to emulate DROP USER IF EXISTS ..;) local DBPASSWD=$( grep password /root/.my.cnf | sed 's|password=||' ) @@ -159,8 +157,8 @@ EOF # ncp-previewgenerator cp -r /var/www/ncp-previewgenerator /var/www/nextcloud/apps/previewgenerator - ncc app:enable previewgenerator chown www-data:www-data /var/www/nextcloud/apps/previewgenerator + ncc app:enable previewgenerator # previews ncc config:app:set previewgenerator squareSizes --value="32 256" diff --git a/bin/ncp/NETWORKING/dnsmasq.sh b/bin/ncp/NETWORKING/dnsmasq.sh index 4ef1234e..9f38baac 100644 --- a/bin/ncp/NETWORKING/dnsmasq.sh +++ b/bin/ncp/NETWORKING/dnsmasq.sh @@ -1,6 +1,6 @@ #!/bin/bash -# dnsmasq DNS server with cache installation on Raspbian +# dnsmasq DNS server with cache 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! @@ -41,7 +41,7 @@ EOF configure() { - [[ $ACTIVE != "yes" ]] && { + [[ $ACTIVE != "yes" ]] && { service dnsmasq stop update-rc.d dnsmasq disable echo "dnmasq disabled" @@ -53,14 +53,14 @@ configure() [[ "$IP" == "" ]] && IP=$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) [[ "$IP" == "" ]] && { echo "could not detect IP"; return 1; } - + cat > /etc/dnsmasq.conf <<EOF interface=$IFACE domain-needed # Never forward plain names (without a dot or domain part) bogus-priv # Never forward addresses in the non-routed address spaces. no-poll # Don't poll for changes in /etc/resolv.conf no-resolv # Don't use /etc/resolv.conf or any other file -cache-size=$CACHESIZE +cache-size=$CACHESIZE server=$DNSSERVER address=/$DOMAIN/$IP # This is optional if we add it to /etc/hosts EOF diff --git a/docker/lamp/010lamp b/docker/lamp/010lamp index fb8f8320..ca55dd6e 100755 --- a/docker/lamp/010lamp +++ b/docker/lamp/010lamp @@ -33,8 +33,9 @@ mysqld & # wait for mariadb while :; do - [[ -S /var/run/mysqld/mysqld.sock ]] && break + [[ -S /run/mysqld/mysqld.sock ]] && break sleep 0.5 done +sleep 1 exit 0 diff --git a/docker/nextcloud/020nextcloud b/docker/nextcloud/020nextcloud index 17f8d92c..8ab9f3dc 100755 --- a/docker/nextcloud/020nextcloud +++ b/docker/nextcloud/020nextcloud @@ -33,14 +33,6 @@ cron echo "Starting Postfix" postfix start -# INIT DATABASE AND NEXTCLOUD CONFIG (first run) -test -f /data/nextcloud/config/config.php || { - echo "Uninitialized instance, running nc-init..." - source /usr/local/etc/library.sh - run_app_unsafe /nc-init.sh - mv /index.php /var/www/nextcloud/ # restore this file after init -} - # Better do real provisioning at the end, as it can restart PHP asynchronously sed -i "s|'password'.*|'password' => 'default',|" /data/nextcloud/config/config.php sed -i "s|'dbpassword' =>.*|'dbpassword' => 'default',|" /data/nextcloud/config/config.php diff --git a/docker/nextcloud/Dockerfile b/docker/nextcloud/Dockerfile index bd27aec4..f33b431e 100644 --- a/docker/nextcloud/Dockerfile +++ b/docker/nextcloud/Dockerfile @@ -48,9 +48,3 @@ rm /.ncp-image; COPY docker/nextcloud/020nextcloud /etc/services-enabled.d/ COPY bin/ncp-provisioning.sh /usr/local/bin/ - -# display message until first run initialization is complete -COPY docker/nextcloud/ncp-wait-msg.html /data-ro/nextcloud -RUN \ -mv /data-ro/nextcloud/index.php /; \ -mv /data-ro/nextcloud/ncp-wait-msg.html /data-ro/nextcloud/index.php; diff --git a/docker/nextcloudpi/Dockerfile b/docker/nextcloudpi/Dockerfile index 1aaf8a5b..efc48000 100644 --- a/docker/nextcloudpi/Dockerfile +++ b/docker/nextcloudpi/Dockerfile @@ -20,6 +20,7 @@ COPY ncp-web /tmp/ncp-build/ncp-web/ COPY ncp-app /tmp/ncp-build/ncp-app/ COPY ncp-previewgenerator /tmp/ncp-build/ncp-previewgenerator/ COPY docker /tmp/ncp-build/docker/ +COPY etc/ncp-config.d/nc-init.cfg /usr/local/etc/ncp-config.d/nc-init-copy.cfg RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ @@ -37,16 +38,19 @@ apt-get install --no-install-recommends -y wget ca-certificates; \ # install nextcloudpi source /usr/local/etc/library.sh; \ -set +x; \ cd /tmp/ncp-build/; \ install_app ncp.sh; \ +mv /usr/local/etc/ncp-config.d/nc-init-copy.cfg /usr/local/etc/ncp-config.d/nc-init.cfg; \ +run_app_unsafe bin/ncp/CONFIG/nc-init.sh; \ + # fix default paths sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.cfg; \ sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup-auto.cfg; \ # specific cleanup cd /; rm -r /tmp/ncp-build; \ +rm /usr/local/etc/ncp-config.d/nc-init.cfg; \ rm /.ncp-image; \ # cleanup all NCP extras @@ -67,5 +71,3 @@ rm /var/cache/debconf/*-old; \ echo "${ncp_ver}" > /usr/local/etc/ncp-version COPY docker/nextcloudpi/000ncp /etc/services-enabled.d/ -COPY bin/ncp/CONFIG/nc-init.sh / -COPY etc/ncp-config.d/nc-init.cfg /usr/local/etc/ncp-config.d/ |