diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-09-21 23:18:47 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-09-21 23:18:47 +0300 |
commit | 78feb74170e998229e1f91f12038f8eee35e88c6 (patch) | |
tree | cb0811b7dd7e21950e5b076e1599e896e21cea79 | |
parent | c14198995c6b1f07f25da82d471f35cc44ef8bde (diff) |
more adaptations to docker build
-rw-r--r-- | etc/nextcloudpi-config.d/dnsmasq.sh | 22 | ||||
-rw-r--r-- | etc/nextcloudpi-config.d/fail2ban.sh | 22 | ||||
-rw-r--r-- | etc/nextcloudpi-config.d/letsencrypt.sh | 12 | ||||
-rw-r--r-- | etc/nextcloudpi-config.d/nc-nextcloud.sh | 2 | ||||
-rw-r--r-- | etc/nextcloudpi-config.d/no-ip.sh | 33 | ||||
-rwxr-xr-x | update.sh | 54 |
6 files changed, 141 insertions, 4 deletions
diff --git a/etc/nextcloudpi-config.d/dnsmasq.sh b/etc/nextcloudpi-config.d/dnsmasq.sh index 1528e4a6..47bbe6fe 100644 --- a/etc/nextcloudpi-config.d/dnsmasq.sh +++ b/etc/nextcloudpi-config.d/dnsmasq.sh @@ -26,6 +26,28 @@ install() apt-get update apt-get install --no-install-recommends -y dnsmasq update-rc.d dnsmasq disable + + [[ "$DOCKERBUILD" == 1 ]] && { + cat > /etc/cont-init.d/100-dnsmasq-run.sh <<EOF +#!/bin/bash + +source /usr/local/etc/library.sh + +[[ "$1" == "stop" ]] && { + echo "stopping dnsmasq..." + service dnsmasq stop + exit 0 +} + +persistent_cfgdir /etc/dnsmasq + +echo "Starting dnsmasq..." +service dnsmasq start + +exit 0 +EOF + chmod +x /etc/cont-init.d/100-dnsmasq-run.sh + } } configure() diff --git a/etc/nextcloudpi-config.d/fail2ban.sh b/etc/nextcloudpi-config.d/fail2ban.sh index 0ebdf90c..53dd186d 100644 --- a/etc/nextcloudpi-config.d/fail2ban.sh +++ b/etc/nextcloudpi-config.d/fail2ban.sh @@ -32,6 +32,28 @@ install() apt-get install --no-install-recommends -y fail2ban update-rc.d fail2ban disable rm -f /etc/fail2ban/jail.d/defaults-debian.conf + + [[ "$DOCKERBUILD" == 1 ]] && { + cat > /etc/cont-init.d/100-fail2ban-run.sh <<EOF +#!/bin/bash + +source /usr/local/etc/library.sh + +[[ "$1" == "stop" ]] && { + echo "stopping fail2ban..." + service fail2ban stop + exit 0 +} + +persistent_cfgdir /etc/fail2ban + +echo "Starting fail2ban..." +service fail2ban start + +exit 0 +EOF + chmod +x /etc/cont-init.d/100-fail2ban-run.sh + } } configure() diff --git a/etc/nextcloudpi-config.d/letsencrypt.sh b/etc/nextcloudpi-config.d/letsencrypt.sh index 7950e328..65820d7e 100644 --- a/etc/nextcloudpi-config.d/letsencrypt.sh +++ b/etc/nextcloudpi-config.d/letsencrypt.sh @@ -38,6 +38,18 @@ install() cd /etc || return 1 git clone https://github.com/letsencrypt/letsencrypt /etc/letsencrypt/letsencrypt-auto --help # do not actually run certbot, only install packages + + [[ "$DOCKERBUILD" == 1 ]] && { + cat > /etc/cont-init.d/100-letsencrypt-run.sh <<EOF +#!/bin/bash + +source /usr/local/etc/library.sh +persistent_cfgdir /etc/letsencrypt + +exit 0 +EOF + chmod +x /etc/cont-init.d/100-letsencrypt-run.sh + } } # tested with git version v0.11.0-71-g018a304 diff --git a/etc/nextcloudpi-config.d/nc-nextcloud.sh b/etc/nextcloudpi-config.d/nc-nextcloud.sh index 7c245cea..5a37caa1 100644 --- a/etc/nextcloudpi-config.d/nc-nextcloud.sh +++ b/etc/nextcloudpi-config.d/nc-nextcloud.sh @@ -45,7 +45,7 @@ configure() echo "Starting mariaDB" # launch mariadb if not already running (for docker build) - pgrep -x mysqld &>/dev/null || { mysqld & } + [[ "$DOCKERBUILD" == 1 ]] && { mysqld & } # wait for mariadb pgrep -x mysqld &>/dev/null || { echo "mariaDB process not found"; return 1; } diff --git a/etc/nextcloudpi-config.d/no-ip.sh b/etc/nextcloudpi-config.d/no-ip.sh index c263621f..0d4a421b 100644 --- a/etc/nextcloudpi-config.d/no-ip.sh +++ b/etc/nextcloudpi-config.d/no-ip.sh @@ -26,6 +26,8 @@ Internet access is required for this configuration to complete." install() { + apt-get update + apt-get install --no-install-recommends -y make mkdir /tmp/noip && cd /tmp/noip wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz tar vzxf noip-duc-linux.tar.gz @@ -55,6 +57,30 @@ EOF update-rc.d noip2 defaults update-rc.d noip2 disable + + mkdir -p /usr/local/etc/noip2 + + [[ "$DOCKERBUILD" == 1 ]] && { + cat > /etc/cont-init.d/100-noip-run.sh <<EOF +#!/bin/bash + +source /usr/local/etc/library.sh + +[[ "$1" == "stop" ]] && { + echo "stopping noip..." + service noip2 stop + exit 0 +} + +persistent_cfgdir /usr/local/etc/noip2 /data/etc/noip2 + +echo "Starting noip..." +service noip2 start + +exit 0 +EOF + chmod +x /etc/cont-init.d/100-noip-run.sh + } } configure() @@ -71,7 +97,12 @@ configure() sudo -u www-data php occ config:system:set overwrite.cli.url --value=https://"$DOMAIN_" } -cleanup() { :; } +cleanup() +{ + apt-get autoremove -y + apt-get clean + rm /var/lib/apt/lists/* -r +} # License # @@ -8,11 +8,54 @@ # More at https://ownyourbits.com/ # +CONFDIR=/usr/local/etc/nextcloudpi-config.d/ + +# don't make sense in a docker container +EXCL_DOCKER=" +nc-automount.sh +nc-format-USB.sh +nc-datadir.sh +nc-database.sh +nc-ramlogs.sh +nc-swapfile.sh +nc-static-IP.sh +nc-wifi.sh +nc-nextcloud.sh +nc-init.sh +" + +# better use a designated container +EXCL_DOCKER+=" +samba.sh +NFS.sh +" + +# TODO review systemd timers +EXCL_DOCKER+=" +nc-notify-updates.sh +nc-scan-auto.sh +nc-backup-auto.sh +freeDNS.sh +" + +# TODO think about updates +EXCL_DOCKER+=" +nc-update.sh +nc-autoupdate-ncp.sh +" cp etc/library.sh /usr/local/etc/ source /usr/local/etc/library.sh -pgrep -x mysqld &>/dev/null && { # skip docker build +# prevent installing some apt packages in the docker version +[[ "$DOCKERBUILD" == 1 ]] && { + mkdir -p $CONFDIR + for opt in $EXCL_DOCKER; do + touch $CONFDIR/$opt +done +} + +[[ "$DOCKERBUILD" != 1 ]] && { # fix automount, reinstall if its old version AMFILE=/usr/local/etc/nextcloudpi-config.d/nc-automount.sh test -e $AMFILE && { grep -q inotify-tools $AMFILE || rm $AMFILE; } @@ -59,9 +102,16 @@ cp -r ncp-web /var/www/ chown -R www-data:www-data /var/www/ncp-web chmod 770 /var/www/ncp-web +# remove unwanted packages for the docker version +[[ "$DOCKERBUILD" == 1 ]] && { + for opt in $EXCL_DOCKER; do + rm $CONFDIR/$opt +done +} + ## BACKWARD FIXES ( for older images ) -pgrep -x mysqld &>/dev/null && { # skip docker build +[[ "$DOCKERBUILD" != 1 ]] && { # force-fix unattended-upgrades cd /usr/local/etc/nextcloudpi-config.d/ || exit 1 |