more adaptations to docker build

This commit is contained in:
nachoparker 2017-09-21 22:18:47 +02:00
parent c14198995c
commit 78feb74170
6 changed files with 141 additions and 4 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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

View File

@ -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; }

View File

@ -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
#

View File

@ -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