mirror of
https://github.com/casjaysdevdocker/ddns
synced 2026-10-14 08:12:58 -04:00
🗃️ Committing everything that changed 🗃️
This commit is contained in:
51 files changed
+973
-339
No files matched your search
+90
-30
@@ -1,37 +1,97 @@
|
||||
FROM casjaysdevdocker/alpine:latest as ddnsbase
|
||||
LABEL author="CasjaysDev" \
|
||||
email="<docker-admin@casjaysdev.com>" \
|
||||
version="1.0.0" \
|
||||
description="dynamic-dns server"
|
||||
FROM casjaysdevdocker/nginx:latest AS build
|
||||
|
||||
RUN apk update --no-cache && apk add --no-cache dhcp-server-vanilla radvd bind bash php8 tftp-hpa tor torsocks
|
||||
RUN rm -Rf /var/cache/apk/* /etc/named* /etc/bind* /etc/dhcpd* /etc/radvd* /etc/tor* /bin/ash
|
||||
RUN ln -sf /bin/bash /bin/ash
|
||||
ARG ALPINE_VERSION="v3.16"
|
||||
|
||||
FROM ddnsbase
|
||||
ARG BUILD_DATE="$(date +'%Y-%m-%d %H:%M')"
|
||||
ARG DEFAULT_DATA_DIR="/usr/local/share/template-files/data" \
|
||||
DEFAULT_CONF_DIR="/usr/local/share/template-files/config" \
|
||||
DEFAULT_TEMPLATE_DIR="/usr/local/share/template-files/defaults"
|
||||
|
||||
LABEL \
|
||||
org.label-schema.name="ddns" \
|
||||
org.label-schema.description="My Dynamic DNS server" \
|
||||
org.label-schema.url="https://hub.docker.com/r/casjaysdevdocker/ddns" \
|
||||
org.label-schema.vcs-url="https://github.com/casjaysdevdocker/ddns" \
|
||||
org.label-schema.build-date=$BUILD_DATE \
|
||||
org.label-schema.version=$BUILD_DATE \
|
||||
org.label-schema.vcs-ref=$BUILD_DATE \
|
||||
org.label-schema.license="WTFPL" \
|
||||
org.label-schema.vcs-type="Git" \
|
||||
org.label-schema.schema-version="1.0" \
|
||||
org.label-schema.vendor="CasjaysDev" \
|
||||
maintainer="CasjaysDev <docker-admin@casjaysdev.com>"
|
||||
ARG PACK_LIST="dhcp-server-vanilla radvd bind tftp-hpa tor torsocks"
|
||||
|
||||
ENV HOSTNAME ddns
|
||||
EXPOSE 53 53/udp 67 67/udp 69 69/udp 80 546 546/udp 8053 8053/udp 9050 9050/udp
|
||||
ENV LANG=en_US.utf8 \
|
||||
ENV=ENV=~/.bashrc \
|
||||
TZ="America/New_York" \
|
||||
SHELL="/bin/sh" \
|
||||
TERM="xterm-256color" \
|
||||
TIMEZONE="${TZ:-$TIMEZONE}" \
|
||||
HOSTNAME="casjaysdev-ddns"
|
||||
|
||||
COPY ./files /var/lib/ddns
|
||||
COPY ./bin/entrypoint.sh /usr/local/bin/entrypoint-ddns.sh
|
||||
COPY ./rootfs/. /
|
||||
|
||||
VOLUME ["/data", "/config"]
|
||||
RUN set -ex; \
|
||||
rm -Rf "/etc/apk/repositories"; \
|
||||
mkdir -p "${DEFAULT_DATA_DIR}" "${DEFAULT_CONF_DIR}" "${DEFAULT_TEMPLATE_DIR}"; \
|
||||
echo "http://dl-cdn.alpinelinux.org/alpine/${ALPINE_VERSION}/main" >>"/etc/apk/repositories"; \
|
||||
echo "http://dl-cdn.alpinelinux.org/alpine/${ALPINE_VERSION}/community" >>"/etc/apk/repositories"; \
|
||||
if [ "${ALPINE_VERSION}" = "edge" ]; then echo "http://dl-cdn.alpinelinux.org/alpine/${ALPINE_VERSION}/testing" >>"/etc/apk/repositories" ; fi ; \
|
||||
apk update --update-cache && apk add --no-cache ${PACK_LIST} && \
|
||||
if [ -f "/bin/ash" ]; then ln -sf /bin/bash /bin/ash ; fi && \
|
||||
cp -Rf "${DEFAULT_CONF_DIR}/." "/etc/"
|
||||
|
||||
HEALTHCHECK --interval=15s --timeout=3s CMD ["/usr/local/bin/entrypoint-ddns.sh","--health"]
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint-ddns.sh"]
|
||||
RUN echo 'Running cleanup' ; \
|
||||
rm -Rf /etc/named* /etc/bind* /etc/dhcpd* /etc/radvd* /etc/tor* /bin/ash; \
|
||||
rm -Rf /usr/share/doc/* /usr/share/info/* /tmp/* /var/tmp/* ; \
|
||||
rm -Rf /usr/local/bin/.gitkeep /usr/local/bin/.gitkeep /config /data /var/cache/apk/* ; \
|
||||
rm -rf /lib/systemd/system/multi-user.target.wants/* ; \
|
||||
rm -rf /etc/systemd/system/*.wants/* ; \
|
||||
rm -rf /lib/systemd/system/local-fs.target.wants/* ; \
|
||||
rm -rf /lib/systemd/system/sockets.target.wants/*udev* ; \
|
||||
rm -rf /lib/systemd/system/sockets.target.wants/*initctl* ; \
|
||||
rm -rf /lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* ; \
|
||||
rm -rf /lib/systemd/system/systemd-update-utmp* ; \
|
||||
if [ -d "/lib/systemd/system/sysinit.target.wants" ]; then cd "/lib/systemd/system/sysinit.target.wants" && rm $(ls | grep -v systemd-tmpfiles-setup) ; fi
|
||||
|
||||
FROM scratch
|
||||
|
||||
ARG \
|
||||
SERVICE_PORT="80" \
|
||||
EXPOSE_PORTS="53/tcp 53/udp 67/tcp 67/udp 69/tcp 69/udp 80/tcp 546/tcp 546/udp 8053/tcp 8053/udp 9050/tcp 9050/udp" \
|
||||
PHP_SERVER="ddns" \
|
||||
NODE_VERSION="system" \
|
||||
NODE_MANAGER="system" \
|
||||
BUILD_VERSION="latest" \
|
||||
LICENSE="MIT" \
|
||||
IMAGE_NAME="ddns" \
|
||||
BUILD_DATE="Thu Oct 20 07:09:33 PM EDT 2022" \
|
||||
TIMEZONE="America/New_York"
|
||||
|
||||
LABEL maintainer="CasjaysDev <docker-admin@casjaysdev.com>" \
|
||||
org.opencontainers.image.vendor="CasjaysDev" \
|
||||
org.opencontainers.image.authors="CasjaysDev" \
|
||||
org.opencontainers.image.vcs-type="Git" \
|
||||
org.opencontainers.image.name="${IMAGE_NAME}" \
|
||||
org.opencontainers.image.base.name="${IMAGE_NAME}" \
|
||||
org.opencontainers.image.license="${LICENSE}" \
|
||||
org.opencontainers.image.vcs-ref="${BUILD_VERSION}" \
|
||||
org.opencontainers.image.build-date="${BUILD_DATE}" \
|
||||
org.opencontainers.image.version="${BUILD_VERSION}" \
|
||||
org.opencontainers.image.schema-version="${BUILD_VERSION}" \
|
||||
org.opencontainers.image.url="https://hub.docker.com/r/casjaysdevdocker/${IMAGE_NAME}" \
|
||||
org.opencontainers.image.vcs-url="https://github.com/casjaysdevdocker/${IMAGE_NAME}" \
|
||||
org.opencontainers.image.url.source="https://github.com/casjaysdevdocker/${IMAGE_NAME}" \
|
||||
org.opencontainers.image.documentation="https://hub.docker.com/r/casjaysdevdocker/${IMAGE_NAME}" \
|
||||
org.opencontainers.image.description="Containerized version of ${IMAGE_NAME}"
|
||||
|
||||
ENV LANG=en_US.utf8 \
|
||||
ENV=~/.bashrc \
|
||||
SHELL="/bin/bash" \
|
||||
PORT="${SERVICE_PORT}" \
|
||||
TERM="xterm-256color" \
|
||||
PHP_SERVER="${PHP_SERVER}" \
|
||||
CONTAINER_NAME="${IMAGE_NAME}" \
|
||||
TZ="${TZ:-America/New_York}" \
|
||||
TIMEZONE="${TZ:-$TIMEZONE}" \
|
||||
HOSTNAME="casjaysdev-${IMAGE_NAME}"
|
||||
|
||||
COPY --from=build /. /
|
||||
|
||||
USER root
|
||||
WORKDIR /root
|
||||
|
||||
VOLUME [ "/config","/data" ]
|
||||
|
||||
EXPOSE $EXPOSE_PORTS
|
||||
|
||||
#CMD [ "" ]
|
||||
ENTRYPOINT [ "tini", "-p", "SIGTERM", "--", "/usr/local/bin/entrypoint.sh" ]
|
||||
HEALTHCHECK --start-period=1m --interval=2m --timeout=3s CMD [ "/usr/local/bin/entrypoint.sh", "healthcheck" ]
|
||||
@@ -1,10 +1,36 @@
|
||||
<h1 align=center>
|
||||
👋 Welcome to ddns 👋
|
||||
</h1>
|
||||
<p align=center>
|
||||
StartDocumentationHere
|
||||
</p>
|
||||
|
||||
## Author
|
||||
## 👋 Welcome to ddns 🚀
|
||||
|
||||
👤 **Jason Hempstead**
|
||||
ddns README
|
||||
|
||||
|
||||
## Install my system scripts
|
||||
|
||||
```shell
|
||||
sudo bash -c "$(curl -q -LSsf "https://github.com/systemmgr/installer/raw/main/install.sh")"
|
||||
sudo systemmgr --config && sudo systemmgr install scripts
|
||||
```
|
||||
|
||||
## Get source files
|
||||
|
||||
```shell
|
||||
dockermgr download src ddns
|
||||
```
|
||||
|
||||
OR
|
||||
|
||||
```shell
|
||||
git clone "https://github.com/casjaysdevdocker/ddns" "$HOME/Projects/github/casjaysdevdocker/ddns"
|
||||
```
|
||||
|
||||
## Build container
|
||||
|
||||
```shell
|
||||
cd "$HOME/Projects/github/casjaysdevdocker/ddns"
|
||||
buildx
|
||||
```
|
||||
|
||||
## Authors
|
||||
|
||||
🤖 casjay: [Github](https://github.com/casjay) [Docker](https://hub.docker.com/r/casjay) 🤖
|
||||
📽 dockermgr: [Github](https://github.com/dockermgr) [Docker](https://hub.docker.com/r/dockermgr) 📽
|
||||
⛵ CasjaysDev Docker: [Github](https://github.com/casjaysdevdocker) [Docker](https://hub.docker.com/r/casjaysdevdocker) ⛵
|
||||
@@ -1,284 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
##@Version : 202112111512-git
|
||||
# @Author : Jason Hempstead
|
||||
# @Contact : jason@casjaysdev.com
|
||||
# @License : WTFPL
|
||||
# @ReadME : entrypoint.sh --help
|
||||
# @Copyright : Copyright: (c) 2021 Jason Hempstead, Casjays Developments
|
||||
# @Created : Saturday, Dec 11, 2021 15:12 EST
|
||||
# @File : entrypoint.sh
|
||||
# @Description :
|
||||
# @TODO :
|
||||
# @Other :
|
||||
# @Resource :
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set bash options
|
||||
[ -n "$DEBUG" ] && set -x
|
||||
set -o pipefail
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
APPNAME="$(basename "$0" 2>/dev/null)"
|
||||
VERSION="202112111512-git"
|
||||
USER="${SUDO_USER:-${USER}}"
|
||||
HOME="${USER_HOME:-${HOME}}"
|
||||
SRC_DIR="${BASH_SOURCE%/*}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
|
||||
# Set functions
|
||||
__help() {
|
||||
echo 'docker entry point script
|
||||
options are:
|
||||
'$APPNAME' --help
|
||||
'$APPNAME' --version
|
||||
'$APPNAME' --shell
|
||||
'$APPNAME' --help
|
||||
'$APPNAME' --health
|
||||
'$APPNAME' --status
|
||||
'
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__list_options() { echo "${1:-$ARRAY}" | sed 's|:||g;s|'$2'| '$3'|g' 2>/dev/null; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional functions
|
||||
__run_dns() {
|
||||
named-checkconf -z /etc/named.conf
|
||||
named -c /etc/named.conf
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Check for needed applications
|
||||
type -P bash &>/dev/null || { echo "Missing: bash" && exit 1; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set variables
|
||||
exitCode=0
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Application Folders
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Show warn message if variables are missing
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set options
|
||||
SETARGS="$*"
|
||||
SHORTOPTS=""
|
||||
LONGOPTS="options,version,help,shell,health,status"
|
||||
ARRAY=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Setup application options
|
||||
setopts=$(getopt -o "$SHORTOPTS" --long "$LONGOPTS" -a -n "$APPNAME" -- "$@" 2>/dev/null)
|
||||
eval set -- "${setopts[@]}" 2>/dev/null
|
||||
while :; do
|
||||
case $1 in
|
||||
--options)
|
||||
shift 1
|
||||
[ -n "$1" ] || printf 'Current options for %s\n' "${PROG:-$APPNAME}"
|
||||
[ -z "$SHORTOPTS" ] || __list_options "Short Options" "-$SHORTOPTS" ',' '-'
|
||||
[ -z "$LONGOPTS" ] || __list_options "Long Options" "--$LONGOPTS" ',' '--'
|
||||
[ -z "$ARRAY" ] || __list_options "Base Options" "$ARRAY" ',' ''
|
||||
exit $?
|
||||
;;
|
||||
--help)
|
||||
shift 1
|
||||
__help
|
||||
exit
|
||||
;;
|
||||
--version)
|
||||
shift 1
|
||||
printf "$APPNAME Version: $VERSION\n"
|
||||
exit
|
||||
;;
|
||||
--shell)
|
||||
shift 1
|
||||
bash -s /root/.profile -l
|
||||
exit $?
|
||||
;;
|
||||
--health)
|
||||
shift 1
|
||||
exitCode=0
|
||||
for proc in named tor tftp named dhcp radvd php; do
|
||||
ps aux | grep -Ev 'grep|tail' | grep -q "$proc" && echo "$proc" || exitCode+=1
|
||||
done
|
||||
exit ${exitCode:-$?}
|
||||
;;
|
||||
--status)
|
||||
shift 1
|
||||
netstat -taupln | grep -E '^udp|LISTEN'
|
||||
exit ${exitCode:-$?}
|
||||
;;
|
||||
--)
|
||||
shift 1
|
||||
ARGS="$1"
|
||||
set --
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
[[ -f "/run/ddns.pid" ]] && echo "PID file exists" && exit 1
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional variables
|
||||
[[ -f "/root/.bashrc" ]] || printf "source /etc/profile\ncd %s\n" "$HOME" >"/root/.bashrc"
|
||||
[[ -f "/root/.bashrc" ]] && source "/root/.bashrc"
|
||||
[[ -f "/config/env" ]] && source "/config/env"
|
||||
DATE="$(date +%Y%m%d)01"
|
||||
OLD_DATE="${OLD_DATE:-2018020901}"
|
||||
NETDEV="$(ip route 2>/dev/null | grep default | sed -e "s/^.*dev.//" -e "s/.proto.*//" | awk '{print $1}')"
|
||||
IPV4_ADDR="$(ifconfig $NETDEV 2>/dev/null | grep -E "venet|inet" | grep -v "127.0.0." | grep 'inet' | grep -v inet6 | awk '{print $2}' | sed s/addr://g | head -n1 | grep '^' || echo '')"
|
||||
IPV6_ADDR="$(ifconfig "$NETDEV" 2>/dev/null | grep -E "venet|inet" | grep 'inet6' | grep -i global | awk '{print $2}' | head -n1 | grep '^' || echo '')"
|
||||
IPV4_ADDR_GATEWAY="$(ip route show default | awk '/default/ {print $3}' | head -n1 | grep '^' || echo '')"
|
||||
IPV4_ADDR="${IPV4_ADDR:-10.0.0.2}"
|
||||
IPV4_ADDR_SUBNET="${IPV4_ADDR_SUBNET:-10.0.0.0}"
|
||||
IPV4_ADDR_START="${IPV4_ADDR_START:-10.0.100.1}"
|
||||
IPV4_ADDR_END="${IPV4_ADDR_END:-10.0.100.254}"
|
||||
IPV4_ADDR_NETMASK="${IPV4_ADDR_NETMASK:-255.255.0.0}"
|
||||
IPV4_ADDR_GATEWAY="${IPV4_ADDR_GATEWAY:-10.0.0.1}"
|
||||
IPV6_ADDR="${IP6_ADDR:-2001:0db8:edfa:1234::2}"
|
||||
IPV6_ADDR_SUBNET="${IPV6_ADDR_SUBNET:-2001:0db8:edfa:1234::}"
|
||||
IPV6_ADDR_START="${IPV6_ADDR_START:-2001:0db8:edfa:1234:5678::1}"
|
||||
IPV6_ADDR_END="${IPV6_ADDR_END:-2001:0db8:edfa:1234:5678::ffff}"
|
||||
IPV6_ADDR_NETMASK="${IPV6_ADDR_NETMASK:-64}"
|
||||
IPV6_ADDR_GATEWAY="${IPV6_ADDR_GATEWAY:-2001:0db8:edfa:1234::1}"
|
||||
|
||||
DOMAIN_NAME="${DOMAIN_NAME:-test}"
|
||||
HOSTNAME="$(hostname -s).${DOMAIN_NAME}"
|
||||
[[ "$DOMAIN_NAME" == "local" ]] && DOMAIN_NAME="test"
|
||||
###############################################################################
|
||||
[[ -f "/config/env" ]] && source "/config/env"
|
||||
{
|
||||
echo 'Starting dynamic DNS server...'
|
||||
touch /run/ddns.pid
|
||||
date '+%Y-%m-%d %H:%M'
|
||||
echo "Setting hostname to $HOSTNAME"
|
||||
} &>/data/log/entrypoint.log
|
||||
[[ -d "/data/log" ]] && rm -Rf /data/log/* || mkdir -p "/data/log"
|
||||
[[ -f "/etc/profile" ]] && [[ ! -f "/root/.profile" ]] && cp -Rf "/etc/profile" "/root/.profile"
|
||||
|
||||
if [[ -f "/config/rndc.key" ]]; then
|
||||
RNDC_KEY="$(cat /config/rndc.key | grep secret | awk '{print $2}' | sed 's|;||g;s|"||g')"
|
||||
else
|
||||
rndc-confgen -a -c /etc/rndc.key &>>/data/log/named.log
|
||||
RNDC_KEY="$(cat /etc/rndc.key | grep secret | awk '{print $2}' | sed 's|;||g;s|"||g')"
|
||||
[[ -f "/config/rndc.key" ]] || cp -Rf "/etc/rndc.key" "/config/rndc.key" &>>/data/log/entrypoint.log
|
||||
[[ -f "/config/rndc.conf" ]] || { [[ -f "/etc/rndc.conf" ]] && cp -Rf "/etc/rndc.conf" "/config/rndc.conf" &>>/data/log/entrypoint.log; }
|
||||
fi
|
||||
[[ -d "/run/tor" ]] || mkdir -p "/run/tor" &>>/data/log/entrypoint.log
|
||||
[[ -d "/etc/dhcp" ]] || mkdir -p "/etc/dhcp" &>>/data/log/entrypoint.log
|
||||
[[ -d "/run/dhcp" ]] || mkdir -p "/run/dhcp" &>>/data/log/entrypoint.log
|
||||
[[ -d "/var/tftpboot" ]] && [[ ! -d "/data/tftp" ]] && mv -f "/var/tftpboot" "/data/tftp" &>>/data/log/entrypoint.log
|
||||
[[ -d "/var/lib/dhcp" ]] || mkdir -p "/var/lib/dhcp" &>>/data/log/entrypoint.log
|
||||
[[ -d "/data/tor" ]] || cp -Rf "/var/lib/tor" "/data/tor" &>>/data/log/entrypoint.log
|
||||
[[ -d "/data/web" ]] || cp -Rf "/var/lib/ddns/data/web" "/data/web" &>>/data/log/entrypoint.log
|
||||
[[ -d "/data/named" ]] || cp -Rf "/var/lib/ddns/data/named" "/data/named" &>>/data/log/entrypoint.log
|
||||
[[ -d "/config/tor" ]] || cp -Rf "/var/lib/ddns/config/tor" "/config/tor" &>>/data/log/entrypoint.log
|
||||
[[ -d "/config/dhcp" ]] || cp -Rf "/var/lib/ddns/config/dhcp" "/config/dhcp" &>>/data/log/entrypoint.log
|
||||
[[ -d "/config/named" ]] || cp -Rf "/var/lib/ddns/config/named" "/config/named" &>>/data/log/entrypoint.log
|
||||
[[ -f "/config/radvd.conf" ]] || cp -Rf "/var/lib/ddns/config/radvd.conf" "/config/radvd.conf" &>>/data/log/entrypoint.log
|
||||
[[ -f "/config/named.conf" ]] || cp -Rf "/var/lib/ddns/config/named.conf" "/config/named.conf" &>>/data/log/entrypoint.log
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Main application
|
||||
find "/config" "/data" -type f -exec sed -i 's|'${OLD_DATE:-2018020901}'|'$DATE'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_DOMAIN|'$DOMAIN_NAME'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_WITH_RNDC_KEY|'$RNDC_KEY'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_ADDRESS|'$IPV4_ADDR'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_ADDR_START|'$IPV4_ADDR_START'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_ADDR_END|'$IPV4_ADDR_END'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_SUBNET|'$IPV4_ADDR_SUBNET'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_NETMASK|'$IPV4_ADDR_NETMASK'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_GATEWAY|'$IPV4_ADDR_GATEWAY'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_ADDRESS|'$IPV6_ADDR'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_ADDR_START|'$IPV6_ADDR_START'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_ADDR_END|'$IPV6_ADDR_END'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_SUBNET|'$IPV6_ADDR_SUBNET'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_NETMASK|'$IPV6_ADDR_NETMASK'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_GATEWAY|'$IPV6_ADDR_GATEWAY'|g' {} \;
|
||||
|
||||
if [ ! -f "/confiv/env" ]; then
|
||||
echo "Creating file: /config/env" &>>/data/log/entrypoint.log
|
||||
cat <<EOF >/config/env
|
||||
RNDC_KEY="${RNDC_KEY:-}"
|
||||
OLD_DATE="${OLD_DATE:-2018020901}"
|
||||
NETDEV="$(ip route 2>/dev/null | grep default | sed -e "s/^.*dev.//" -e "s/.proto.*//" | awk '{print $1}')"
|
||||
IPV4_ADDR="$(ifconfig $NETDEV 2>/dev/null | grep -E "venet|inet" | grep -v "127.0.0." | grep 'inet' | grep -v inet6 | awk '{print $2}' | sed s/addr://g | head -n1 | grep '^' || echo '')"
|
||||
IPV6_ADDR="$(ifconfig "$NETDEV" 2>/dev/null | grep -E "venet|inet" | grep 'inet6' | grep -i global | awk '{print $2}' | head -n1 | grep '^' || echo '')"
|
||||
IPV4_ADDR="${IPV4_ADDR:-10.0.0.2}"
|
||||
IPV4_ADDR_SUBNET="${IPV4_ADDR_SUBNET:-10.0.0.0}"
|
||||
IPV4_ADDR_START="${IPV4_ADDR_START:-10.0.100.1}"
|
||||
IPV4_ADDR_END="${IPV4_ADDR_END:-10.0.100.254}"
|
||||
IPV4_ADDR_NETMASK="${IPV4_ADDR_NETMASK:-255.255.0.0}"
|
||||
IPV4_ADDR_GATEWAY="${IPV4_ADDR_GATEWAY:-10.0.0.1}"
|
||||
IPV6_ADDR="${IP6_ADDR:-2001:0db8:edfa:1234::2}"
|
||||
IPV6_ADDR_SUBNET="${IPV6_ADDR_SUBNET:-2001:0db8:edfa:1234::}"
|
||||
IPV6_ADDR_START="${IPV6_ADDR_START:-2001:0db8:edfa:1234:5678::1}"
|
||||
IPV6_ADDR_END="${IPV6_ADDR_END:-2001:0db8:edfa:1234:5678::ffff}"
|
||||
IPV6_ADDR_NETMASK="${IPV6_ADDR_NETMASK:-64}"
|
||||
IPV6_ADDR_GATEWAY="${IPV6_ADDR_GATEWAY:-2001:0db8:edfa:1234::1}"
|
||||
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [[ -f "/config/named.conf" ]]; then
|
||||
echo "Initializing named" &>>/data/log/entrypoint.log
|
||||
rm -R /data/log/dns/* &>>/data/log/entrypoint.log
|
||||
cp -Rf "/config/named.conf" "/etc/named.conf"
|
||||
[[ -d "/data/log/dns" ]] || mkdir -p "/data/log/dns"
|
||||
[[ -d "/data/named" ]] && cp -Rf "/data/named" "/var/named"
|
||||
[[ -d "/config/named" ]] && cp -Rf "/config/named" "/etc/named"
|
||||
[[ -f "/config/rndc.key" ]] && cp -Rf "/config/rndc.key" "/etc/rndc.key"
|
||||
[[ -f "/config/rndc.conf" ]] && cp -Rf "/config/rndc.conf" "/etc/rndc.conf"
|
||||
chmod -f 777 "/data/log/dns"
|
||||
__run_dns &>>/data/log/named.log &
|
||||
sleep .5
|
||||
fi
|
||||
|
||||
if [[ -n "$IP6_ADDR" ]]; then
|
||||
if [[ -f "/config/dhcp/dhcpd6.conf" ]]; then
|
||||
echo "Initializing dhcpd6" &>>/data/log/entrypoint.log
|
||||
cp -Rf "/config/dhcp/dhcpd6.conf" "/etc/dhcp/dhcpd6.conf"
|
||||
touch /var/lib/dhcp/dhcpd6.leases
|
||||
dhcpd -6 -cf /etc/dhcp/dhcpd6.conf &>>/data/log/dhcpd6.log &
|
||||
sleep .5
|
||||
fi
|
||||
if [[ -f "/config/radvd.conf" ]]; then
|
||||
echo "Initializing radvd" &>>/data/log/entrypoint.log
|
||||
cp -Rf "/config/radvd.conf" "/etc/radvd.conf"
|
||||
radvd -C /etc/radvd.conf &>>/data/log/radvd.log &
|
||||
sleep .5
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f "/config/dhcp/dhcpd4.conf" ]]; then
|
||||
echo "Initializing dhcpd4" &>>/data/log/entrypoint.log
|
||||
cp -Rf "/config/dhcp/dhcpd4.conf" "/etc/dhcp/dhcpd4.conf"
|
||||
touch /var/lib/dhcp/dhcpd.leases
|
||||
dhcpd -4 -cf /etc/dhcp/dhcpd4.conf &>>/data/log/dhcpd4.log &
|
||||
sleep .5
|
||||
fi
|
||||
|
||||
if [[ -d "/config/tor" ]]; then
|
||||
echo "Initializing tor" &>>/data/log/entrypoint.log
|
||||
[[ -d "/config/tor" ]] && cp -Rf "/config/tor" "/etc/tor"
|
||||
chown -Rf root:root "/var/lib/tor"
|
||||
chmod 700 "/run/tor"
|
||||
tor -f "/etc/tor/torrc" &>>/data/log/tor.log &
|
||||
fi
|
||||
if [[ -d "/data/tftp" ]]; then
|
||||
echo "Initializing tftp" &>>/data/log/entrypoint.log
|
||||
rm -Rf "/var/tftpboot"
|
||||
ln -sf "/data/tftp" "/var/tftpboot"
|
||||
in.tftpd -vv -L /var/tftpboot &>/data/log/tftpd.log &
|
||||
fi
|
||||
if [[ -f "/data/web/index.php" ]]; then
|
||||
php_bin="$(command -v php || command -v php8 || false)"
|
||||
if [[ -n "$php_bin" ]]; then
|
||||
echo "Initializing web on $IP_ADDR" &>>/data/log/entrypoint.log
|
||||
$php_bin -S 0.0.0.0:80 -t "/data/web" &>>/data/log/php.log &
|
||||
sleep .5
|
||||
fi
|
||||
fi
|
||||
sleep 5
|
||||
date +'%Y-%m-%d %H:%M' >/data/log/entrypoint.log
|
||||
echo "Initializing completed" &>>/data/log/entrypoint.log
|
||||
tail -n 1000 -f /data/log/*.log
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
exit ${exitCode:-$?}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# end
|
||||
File renamed without changes.
Executable
+332
@@ -0,0 +1,332 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
##@Version : 202210201909-git
|
||||
# @@Author : Jason Hempstead
|
||||
# @@Contact : jason@casjaysdev.com
|
||||
# @@License : LICENSE.md
|
||||
# @@ReadME : entrypoint.sh --help
|
||||
# @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
|
||||
# @@Created : Thursday, Oct 20, 2022 19:09 EDT
|
||||
# @@File : entrypoint.sh
|
||||
# @@Description : entrypoint point for ddns
|
||||
# @@Changelog : New script
|
||||
# @@TODO : Better documentation
|
||||
# @@Other :
|
||||
# @@Resource :
|
||||
# @@Terminal App : no
|
||||
# @@sudo/root : no
|
||||
# @@Template : other/docker-entrypoint
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set bash options
|
||||
[ -n "$DEBUG" ] && set -x
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set functions
|
||||
__exec_command() {
|
||||
local exitCode=0
|
||||
local cmd="${*:-bash -l}"
|
||||
echo "${exec_message:-Executing command: $cmd}"
|
||||
$cmd || exitCode=1
|
||||
[ "$exitCode" = 0 ] || exitCode=10
|
||||
return ${exitCode:-$?}
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__pcheck() { [ -n "$(which pgrep 2>/dev/null)" ] && pgrep -x "$1" || return 1; }
|
||||
__find() { find "$1" -mindepth 1 -type ${2:-f,d} 2>/dev/null | grep '^' || return 10; }
|
||||
__curl() { curl -q -LSsf -o /dev/null -s -w "200" "$@" 2>/dev/null || return 10; }
|
||||
__pgrep() { __pcheck "${1:-$SERVICE_NAME}" || ps aux 2>/dev/null | grep -Fw " ${1:-$SERVICE_NAME}" | grep -qv ' grep' || return 10; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__certbot() {
|
||||
[ -n "$DOMANNAME" ] && [ -n "$CERT_BOT_MAIL" ] || { echo "The variables DOMANNAME and CERT_BOT_MAIL are set" && exit 1; }
|
||||
[ "$SSL_CERT_BOT" = "true" ] && type -P certbot &>/dev/null || { export SSL_CERT_BOT="" && return 10; }
|
||||
certbot $1 --agree-tos -m $CERT_BOT_MAIL certonly --webroot -w "${WWW_ROOT_DIR:-/data/htdocs/www}" -d $DOMAINNAME -d $DOMAINNAME \
|
||||
--put-all-related-files-into "$SSL_DIR" -key-path "$SSL_KEY" -fullchain-path "$SSL_CERT"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__heath_check() {
|
||||
status=0 health="Good"
|
||||
__pgrep ${1:-} || status=$((status + 1))
|
||||
#__curl "https://1.1.1.1" || status=$((status + 1))
|
||||
#__curl "http://localhost:$HTTP_PORT/server-health" || status=$((status + 1))
|
||||
[ "$status" -eq 0 ] || health="Errors reported see docker logs --follow $CONTAINER_NAME"
|
||||
echo "$(uname -s) $(uname -m) is running and the health is: $health"
|
||||
return ${status:-$?}
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__start_all_services() {
|
||||
echo "$service_message"
|
||||
start-ddns.sh
|
||||
return $?
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional functions
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# export functions
|
||||
export -f __exec_command __pcheck __pgrep __find __curl __heath_check __certbot __start_all_services
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Define default variables - do not change these - redefine with -e or set under Additional
|
||||
DISPLAY="${DISPLAY:-}"
|
||||
LANG="${LANG:-C.UTF-8}"
|
||||
DOMAINNAME="${DOMAINNAME:-}"
|
||||
TZ="${TZ:-America/New_York}"
|
||||
HTTP_PORT="${HTTP_PORT:-80}"
|
||||
HTTPS_PORT="${HTTPS_PORT:-}"
|
||||
SERVICE_PORT="${SERVICE_PORT:-}"
|
||||
SERVICE_NAME="${CONTAINER_NAME:-}"
|
||||
HOSTNAME="${HOSTNAME:-casjaysdev-ddns}"
|
||||
HOSTADMIN="${HOSTADMIN:-root@${DOMAINNAME:-$HOSTNAME}}"
|
||||
CERT_BOT_MAIL="${CERT_BOT_MAIL:-certbot-mail@casjay.net}"
|
||||
SSL_CERT_BOT="${SSL_CERT_BOT:-false}"
|
||||
SSL_ENABLED="${SSL_ENABLED:-false}"
|
||||
SSL_DIR="${SSL_DIR:-/config/ssl}"
|
||||
SSL_CA="${SSL_CA:-$SSL_DIR/ca.crt}"
|
||||
SSL_KEY="${SSL_KEY:-$SSL_DIR/server.key}"
|
||||
SSL_CERT="${SSL_CERT:-$SSL_DIR/server.crt}"
|
||||
SSL_CONTAINER_DIR="${SSL_CONTAINER_DIR:-/etc/ssl/CA}"
|
||||
WWW_ROOT_DIR="${WWW_ROOT_DIR:-/data/htdocs}"
|
||||
LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
|
||||
DEFAULT_DATA_DIR="${DEFAULT_DATA_DIR:-/usr/local/share/template-files/data}"
|
||||
DEFAULT_CONF_DIR="${DEFAULT_CONF_DIR:-/usr/local/share/template-files/config}"
|
||||
DEFAULT_TEMPLATE_DIR="${DEFAULT_TEMPLATE_DIR:-/usr/local/share/template-files/defaults}"
|
||||
CONTAINER_IP_ADDRESS="$(ip a 2>/dev/null | grep 'inet' | grep -v '127.0.0.1' | awk '{print $2}' | sed 's|/.*||g')"
|
||||
[ -n "$HTTP_PORT" ] || [ -n "$HTTPS_PORT" ] || HTTP_PORT="$SERVICE_PORT"
|
||||
[ "$HTTPS_PORT" = "443" ] && HTTP_PORT="$HTTPS_PORT" && SSL_ENABLED="true"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional variables and variable overrides
|
||||
#SERVICE_NAME=""
|
||||
export service_message="Starting $CONTAINER_NAME"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
DATE="$(date +%Y%m%d)01"
|
||||
OLD_DATE="${OLD_DATE:-2018020901}"
|
||||
NETDEV="$(ip route 2>/dev/null | grep default | sed -e "s/^.*dev.//" -e "s/.proto.*//" | awk '{print $1}')"
|
||||
IPV4_ADDR="$(ifconfig $NETDEV 2>/dev/null | grep -E "venet|inet" | grep -v "127.0.0." | grep 'inet' | grep -v inet6 | awk '{print $2}' | sed s/addr://g | head -n1 | grep '^' || echo '')"
|
||||
IPV6_ADDR="$(ifconfig "$NETDEV" 2>/dev/null | grep -E "venet|inet" | grep 'inet6' | grep -i global | awk '{print $2}' | head -n1 | grep '^' || echo '')"
|
||||
IPV4_ADDR_GATEWAY="$(ip route show default | awk '/default/ {print $3}' | head -n1 | grep '^' || echo '')"
|
||||
HOSTNAME="$(hostname -s).${DOMAIN_NAME}"
|
||||
export IPV4_ADDR="${IPV4_ADDR:-10.0.0.2}"
|
||||
export IPV4_ADDR_SUBNET="${IPV4_ADDR_SUBNET:-10.0.0.0}"
|
||||
export IPV4_ADDR_START="${IPV4_ADDR_START:-10.0.100.1}"
|
||||
export IPV4_ADDR_END="${IPV4_ADDR_END:-10.0.100.254}"
|
||||
export IPV4_ADDR_NETMASK="${IPV4_ADDR_NETMASK:-255.255.0.0}"
|
||||
export IPV4_ADDR_GATEWAY="${IPV4_ADDR_GATEWAY:-10.0.0.1}"
|
||||
export IPV6_ADDR="${IP6_ADDR:-2001:0db8:edfa:1234::2}"
|
||||
export IPV6_ADDR_SUBNET="${IPV6_ADDR_SUBNET:-2001:0db8:edfa:1234::}"
|
||||
export IPV6_ADDR_START="${IPV6_ADDR_START:-2001:0db8:edfa:1234:5678::1}"
|
||||
export IPV6_ADDR_END="${IPV6_ADDR_END:-2001:0db8:edfa:1234:5678::ffff}"
|
||||
export IPV6_ADDR_NETMASK="${IPV6_ADDR_NETMASK:-64}"
|
||||
export IPV6_ADDR_GATEWAY="${IPV6_ADDR_GATEWAY:-2001:0db8:edfa:1234::1}"
|
||||
export DOMAIN_NAME="${DOMAIN_NAME:-test}"
|
||||
[ "$DOMAIN_NAME" == "local" ] && DOMAIN_NAME="test"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Check if this is a new container
|
||||
[ -f "/data/.docker_has_run" ] && DATA_DIR_INITIALIZED="true" || DATA_DIR_INITIALIZED="false"
|
||||
[ -f "/config/.docker_has_run" ] && CONFIG_DIR_INITIALIZED="true" || CONFIG_DIR_INITIALIZED="false"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# export variables
|
||||
export DATE OLD_DATE NETDEV IPV4_ADDR IPV6_ADDR IPV4_ADDR_GATEWAY DOMAIN_NAME
|
||||
export LANG TZ DOMAINNAME HOSTNAME HOSTADMIN SSL_ENABLED SSL_DIR SSL_CA SSL_KEY SERVICE_NAME
|
||||
export SSL_DIR HTTP_PORT HTTPS_PORT LOCAL_BIN_DIR DEFAULT_CONF_DIR CONTAINER_IP_ADDRESS
|
||||
export SSL_CONTAINER_DIR SSL_CERT_BOT DISPLAY CONFIG_DIR_INITIALIZED DATA_DIR_INITIALIZED
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# import variables from file
|
||||
[ -f "/root/env.sh" ] && . "/root/env.sh"
|
||||
[ -f "/config/env.sh" ] && "/config/env.sh"
|
||||
[ -f "/config/.env.sh" ] && . "/config/.env.sh"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set timezone
|
||||
[ -n "$TZ" ] && echo "$TZ" >"/etc/timezone"
|
||||
[ -f "/usr/share/zoneinfo/$TZ" ] && ln -sf "/usr/share/zoneinfo/$TZ" "/etc/localtime"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set hostname
|
||||
if [ -n "$HOSTNAME" ]; then
|
||||
echo "$HOSTNAME" >"/etc/hostname"
|
||||
echo "127.0.0.1 $HOSTNAME localhost $HOSTNAME.local" >"/etc/hosts"
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Add domain to hosts file
|
||||
if [ -n "$DOMAINNAME" ]; then
|
||||
echo "$HOSTNAME.${DOMAINNAME:-local}" >"/etc/hostname"
|
||||
echo "127.0.0.1 $HOSTNAME localhost $HOSTNAME.local" >"/etc/hosts"
|
||||
echo "${CONTAINER_IP_ADDRESS:-127.0.0.1} $HOSTNAME.$DOMAINNAME" >>"/etc/hosts"
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Delete any gitkeep files
|
||||
[ -d "/data" ] && rm -Rf "/data/.gitkeep" "/data"/*/*.gitkeep
|
||||
[ -d "/config" ] && rm -Rf "/config/.gitkeep" "/data"/*/*.gitkeep
|
||||
[ -f "/usr/local/bin/.gitkeep" ] && rm -Rf "/usr/local/bin/.gitkeep"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create directories
|
||||
[ -d "/data/log" ] || mkdir -p "/data/log"
|
||||
[ -d "/etc/ssl" ] || mkdir -p "$SSL_CONTAINER_DIR"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create files
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create symlinks
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
if [ "$SSL_ENABLED" = "true" ] || [ "$SSL_ENABLED" = "yes" ]; then
|
||||
if [ -f "/config/ssl/server.crt" ] && [ -f "/config/ssl/server.key" ]; then
|
||||
export SSL_ENABLED="true"
|
||||
if [ -n "$SSL_CA" ] && [ -f "$SSL_CA" ]; then
|
||||
mkdir -p "$SSL_CONTAINER_DIR/certs"
|
||||
cat "$SSL_CA" >>"/etc/ssl/certs/ca-certificates.crt"
|
||||
cp -Rf "/config/ssl/." "$SSL_CONTAINER_DIR/"
|
||||
fi
|
||||
else
|
||||
[ -d "$SSL_DIR" ] || mkdir -p "$SSL_DIR"
|
||||
create-ssl-cert
|
||||
fi
|
||||
type update-ca-certificates &>/dev/null && update-ca-certificates
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
[ -f "$SSL_CA" ] && cp -Rfv "$SSL_CA" "$SSL_CONTAINER_DIR/ca.crt"
|
||||
[ -f "$SSL_KEY" ] && cp -Rfv "$SSL_KEY" "$SSL_CONTAINER_DIR/server.key"
|
||||
[ -f "$SSL_CERT" ] && cp -Rfv "$SSL_CERT" "$SSL_CONTAINER_DIR/server.crt"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Setup bin directory
|
||||
SET_USR_BIN=""
|
||||
[ -d "/data/bin" ] && SET_USR_BIN+="$(__find /data/bin f) "
|
||||
[ -d "/config/bin" ] && SET_USR_BIN+="$(__find /config/bin f) "
|
||||
if [ -n "$SET_USR_BIN" ]; then
|
||||
echo "Setting up bin"
|
||||
for create_bin in $SET_USR_BIN; do
|
||||
create_bin_name="$(basename "$create_bin")"
|
||||
ln -sf "$create_bin" "$LOCAL_BIN_DIR/$create_bin_name"
|
||||
done
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create default config
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
|
||||
echo "Copying default config files"
|
||||
if [ -n "$DEFAULT_TEMPLATE_DIR" ] && [ -d "$DEFAULT_TEMPLATE_DIR" ]; then
|
||||
for create_template in "$DEFAULT_TEMPLATE_DIR"/*; do
|
||||
create_template_name="$(basename "$create_template")"
|
||||
cp -Rf "$create_template" "/config/$create_template_name" 2>/dev/null
|
||||
done
|
||||
fi
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy custom config files
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
|
||||
echo "Copying custom config files"
|
||||
for create_config in "$DEFAULT_CONF_DIR"/*; do
|
||||
create_config_name="$(basename "$create_config")"
|
||||
cp -Rf "$create_config" "/config/$create_config_name" 2>/dev/null
|
||||
done
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy custom data files
|
||||
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -d "/data" ]; then
|
||||
echo "Copying data files"
|
||||
for create_data in "$DEFAULT_DATA_DIR"/*; do
|
||||
create_data_name="$(basename "$create_data")"
|
||||
cp -Rf "$create_data" "/data/$create_data_name" 2>/dev/null
|
||||
done
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy /config to /etc
|
||||
if [ -d "/config" ]; then
|
||||
echo "Copying /config to /etc"
|
||||
for create_conf in /config/*; do
|
||||
if [ -n "$create_conf" ]; then
|
||||
create_conf_name="$(basename "$create_conf")"
|
||||
if [ -e "/etc/$create_conf_name" ]; then
|
||||
if [ -d "/etc/$create_conf_name" ]; then
|
||||
cp -Rf "$create_conf/." "/etc/$create_conf_name/" 2>/dev/null
|
||||
else
|
||||
cp -Rf "$create_conf" "/etc/$create_conf_name" 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Unset unneeded variables
|
||||
unset SET_USR_BIN create_bin create_bin_name create_template create_template_name
|
||||
unset create_data create_data_name create_config create_config_name create_conf create_conf_name
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
[ -f "/data/.docker_has_run" ] || { [ -d "/data" ] && echo "Initialized on: $(date)" >"/data/.docker_has_run"; }
|
||||
[ -f "/config/.docker_has_run" ] || { [ -d "/config" ] && echo "Initialized on: $(date)" >"/config/.docker_has_run"; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional commands
|
||||
if [ ! -f "/config/env" ]; then
|
||||
echo "Creating file: /config/env" &>>/data/log/entrypoint.log
|
||||
cat <<EOF >/config/env
|
||||
export RNDC_KEY="${RNDC_KEY:-}"
|
||||
export OLD_DATE="${OLD_DATE:-2018020901}"
|
||||
export NETDEV="$(ip route 2>/dev/null | grep default | sed -e "s/^.*dev.//" -e "s/.proto.*//" | awk '{print $1}')"
|
||||
export IPV4_ADDR="$(ifconfig $NETDEV 2>/dev/null | grep -E "venet|inet" | grep -v "127.0.0." | grep 'inet' | grep -v inet6 | awk '{print $2}' | sed s/addr://g | head -n1 | grep '^' || echo '')"
|
||||
export IPV6_ADDR="$(ifconfig "$NETDEV" 2>/dev/null | grep -E "venet|inet" | grep 'inet6' | grep -i global | awk '{print $2}' | head -n1 | grep '^' || echo '')"
|
||||
export IPV4_ADDR="${IPV4_ADDR:-10.0.0.2}"
|
||||
export IPV4_ADDR_SUBNET="${IPV4_ADDR_SUBNET:-10.0.0.0}"
|
||||
export IPV4_ADDR_START="${IPV4_ADDR_START:-10.0.100.1}"
|
||||
export IPV4_ADDR_END="${IPV4_ADDR_END:-10.0.100.254}"
|
||||
export IPV4_ADDR_NETMASK="${IPV4_ADDR_NETMASK:-255.255.0.0}"
|
||||
export IPV4_ADDR_GATEWAY="${IPV4_ADDR_GATEWAY:-10.0.0.1}"
|
||||
export IPV6_ADDR="${IP6_ADDR:-2001:0db8:edfa:1234::2}"
|
||||
export IPV6_ADDR_SUBNET="${IPV6_ADDR_SUBNET:-2001:0db8:edfa:1234::}"
|
||||
export IPV6_ADDR_START="${IPV6_ADDR_START:-2001:0db8:edfa:1234:5678::1}"
|
||||
export IPV6_ADDR_END="${IPV6_ADDR_END:-2001:0db8:edfa:1234:5678::ffff}"
|
||||
export IPV6_ADDR_NETMASK="${IPV6_ADDR_NETMASK:-64}"
|
||||
export IPV6_ADDR_GATEWAY="${IPV6_ADDR_GATEWAY:-2001:0db8:edfa:1234::1}"
|
||||
|
||||
EOF
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
[ -f "/root/.bashrc" ] || printf "source /etc/profile\ncd %s\n" "$HOME" >"/root/.bashrc"
|
||||
[ -f "/root/.bashrc" ] && source "/root/.bashrc"
|
||||
[ -f "/config/env" ] && source "/config/env"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Show message
|
||||
echo "Container ip address is: $CONTAINER_IP_ADDRESS"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case "$1" in
|
||||
--help) # Help message
|
||||
echo 'Docker container for '$APPNAME''
|
||||
echo "Usage: $APPNAME [healthcheck, bash, command]"
|
||||
echo "Failed command will have exit code 10"
|
||||
echo ""
|
||||
exit ${exitCode:-$?}
|
||||
;;
|
||||
|
||||
healthcheck) # Docker healthcheck
|
||||
__heath_check "${1:-$SERVICE_NAME}" || exitCode=10
|
||||
exit ${exitCode:-$?}
|
||||
;;
|
||||
|
||||
*/bin/sh | */bin/bash | bash | shell | sh) # Launch shell
|
||||
shift 1
|
||||
__exec_command "${@:-/bin/bash}"
|
||||
exit ${exitCode:-$?}
|
||||
;;
|
||||
|
||||
certbot)
|
||||
shift 1
|
||||
SSL_CERT_BOT="true"
|
||||
if [ "$1" = "create" ]; then
|
||||
shift 1
|
||||
__certbot
|
||||
elif [ "$1" = "renew" ]; then
|
||||
shift 1
|
||||
__certbot "renew certonly --force-renew"
|
||||
else
|
||||
__exec_command "certbot" "$@"
|
||||
fi
|
||||
;;
|
||||
|
||||
*) # Execute primary command
|
||||
if [ $# -eq 0 ]; then
|
||||
__start_all_services
|
||||
exit ${exitCode:-$?}
|
||||
else
|
||||
__exec_command "$@"
|
||||
exitCode=$?
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# end of entrypoint
|
||||
exit ${exitCode:-$?}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Executable
+269
@@ -0,0 +1,269 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
##@Version : 202210201909-git
|
||||
# @@Author : Jason Hempstead
|
||||
# @@Contact : jason@casjaysdev.com
|
||||
# @@License : LICENSE.md
|
||||
# @@ReadME : start-ddns.sh --help
|
||||
# @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
|
||||
# @@Created : Thursday, Oct 20, 2022 19:09 EDT
|
||||
# @@File : start-ddns.sh
|
||||
# @@Description : script to start ddns
|
||||
# @@Changelog : New script
|
||||
# @@TODO : Better documentation
|
||||
# @@Other :
|
||||
# @@Resource :
|
||||
# @@Terminal App : no
|
||||
# @@sudo/root : no
|
||||
# @@Template : other/start-service
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set functions
|
||||
__pcheck() { [ -n "$(which pgrep 2>/dev/null)" ] && pgrep -x "$1" || return 1; }
|
||||
__find() { find "$1" -mindepth 1 -type ${2:-f,d} 2>/dev/null | grep '^' || return 10; }
|
||||
__curl() { curl -q -LSsf -o /dev/null -s -w "200" "$@" 2>/dev/null || return 10; }
|
||||
__pgrep() { __pcheck "$1" || ps aux 2>/dev/null | grep -Fw " $1" | grep -qv ' grep' || return 10; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__certbot() {
|
||||
[ -n "$DOMANNAME" ] && [ -n "$CERT_BOT_MAIL" ] || { echo "The variables DOMANNAME and CERT_BOT_MAIL are set" && exit 1; }
|
||||
[ "$SSL_CERT_BOT" = "true" ] && type -P certbot &>/dev/null || { export SSL_CERT_BOT="" && return 10; }
|
||||
certbot $1 --agree-tos -m $CERT_BOT_MAIL certonly --webroot -w "${WWW_ROOT_DIR:-/data/htdocs/www}" -d $DOMAINNAME -d $DOMAINNAME \
|
||||
--put-all-related-files-into "$SSL_DIR" -key-path "$SSL_KEY" -fullchain-path "$SSL_CERT"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__heath_check() {
|
||||
status=0 health="Good"
|
||||
for proc in named tor tftp named dhcp radvd nginx; do
|
||||
ps aux | __pgrep "$proc" && echo "$proc" || status=$((status + 1))
|
||||
done
|
||||
#__curl "http://localhost:$HTTP_PORT/server-health" || status=$((status + 1))
|
||||
[ "$status" -eq 0 ] || health="Errors reported see docker logs --follow $CONTAINER_NAME"
|
||||
echo "$(uname -s) $(uname -m) is running and the health is: $health"
|
||||
return ${status:-$?}
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__run_dns() { named-checkconf -z /etc/named.conf && named -c /etc/named.conf || return 1; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set variables
|
||||
DISPLAY="${DISPLAY:-}"
|
||||
LANG="${LANG:-C.UTF-8}"
|
||||
DOMAINNAME="${DOMAINNAME:-}"
|
||||
TZ="${TZ:-America/New_York}"
|
||||
HTTP_PORT="${HTTP_PORT:-80}"
|
||||
HTTPS_PORT="${HTTPS_PORT:-}"
|
||||
SERVICE_PORT="${SERVICE_PORT:-$HTTP_PORT}"
|
||||
SERVICE_NAME="${CONTAINER_NAME:-}"
|
||||
HOSTNAME="${HOSTNAME:-casjaysdev-ddns}"
|
||||
HOSTADMIN="${HOSTADMIN:-root@${DOMAINNAME:-$HOSTNAME}}"
|
||||
SSL_CERT_BOT="${SSL_CERT_BOT:-false}"
|
||||
SSL_ENABLED="${SSL_ENABLED:-false}"
|
||||
SSL_DIR="${SSL_DIR:-/config/ssl}"
|
||||
SSL_CA="${SSL_CA:-$SSL_DIR/ca.crt}"
|
||||
SSL_KEY="${SSL_KEY:-$SSL_DIR/server.key}"
|
||||
SSL_CERT="${SSL_CERT:-$SSL_DIR/server.crt}"
|
||||
SSL_CONTAINER_DIR="${SSL_CONTAINER_DIR:-/etc/ssl/CA}"
|
||||
WWW_ROOT_DIR="${WWW_ROOT_DIR:-/data/htdocs}"
|
||||
LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
|
||||
DATA_DIR_INITIALIZED="${DATA_DIR_INITIALIZED:-}"
|
||||
CONFIG_DIR_INITIALIZED="${CONFIG_DIR_INITIALIZED:-}"
|
||||
DEFAULT_DATA_DIR="${DEFAULT_DATA_DIR:-/usr/local/share/template-files/data}"
|
||||
DEFAULT_CONF_DIR="${DEFAULT_CONF_DIR:-/usr/local/share/template-files/config}"
|
||||
DEFAULT_TEMPLATE_DIR="${DEFAULT_TEMPLATE_DIR:-/usr/local/share/template-files/defaults}"
|
||||
CONTAINER_IP_ADDRESS="$(ip a 2>/dev/null | grep 'inet' | grep -v '127.0.0.1' | awk '{print $2}' | sed 's|/.*||g')"
|
||||
[ -n "$HTTP_PORT" ] || [ -n "$HTTPS_PORT" ] || HTTP_PORT="$SERVICE_PORT"
|
||||
[ "$HTTPS_PORT" = "443" ] && HTTP_PORT="$HTTPS_PORT" && SSL_ENABLED="true"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Overwrite variables
|
||||
#SERVICE_PORT=""
|
||||
SERVICE_NAME="ddns"
|
||||
SERVICE_COMMAND="$SERVICE_NAME"
|
||||
export exec_message="Starting $SERVICE_NAME on $CONTAINER_IP_ADDRESS:$SERVICE_PORT"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Pre copy commands
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Check if this is a new container
|
||||
[ -z "$DATA_DIR_INITIALIZED" ] && [ -f "/data/.docker_has_run" ] && DATA_DIR_INITIALIZED="true"
|
||||
[ -z "$CONFIG_DIR_INITIALIZED" ] && [ -f "/config/.docker_has_run" ] && CONFIG_DIR_INITIALIZED="true"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create default config
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_TEMPLATE_DIR" ]; then
|
||||
[ -d "/config" ] && cp -Rf "$DEFAULT_TEMPLATE_DIR/." "/config/" 2>/dev/null
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy custom config files
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_CONF_DIR" ]; then
|
||||
[ -d "/config" ] && cp -Rf "$DEFAULT_CONF_DIR/." "/config/" 2>/dev/null
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy custom data files
|
||||
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_DATA_DIR" ]; then
|
||||
[ -d "/data" ] && cp -Rf "$DEFAULT_DATA_DIR/." "/data/" 2>/dev/null
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy html files
|
||||
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -d "$DEFAULT_DATA_DIR/data/htdocs" ]; then
|
||||
[ -d "/data" ] && cp -Rf "$DEFAULT_DATA_DIR/data/htdocs/." "$WWW_ROOT_DIR/" 2>/dev/null
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Post copy commands
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Initialized
|
||||
[ -d "/data" ] && touch "/data/.docker_has_run"
|
||||
[ -d "/config" ] && touch "/config/.docker_has_run"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# APP Variables overrides
|
||||
[ -f "/root/env.sh" ] && . "/root/env.sh"
|
||||
[ -f "/config/env.sh" ] && "/config/env.sh"
|
||||
[ -f "/config/.env.sh" ] && . "/config/.env.sh"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Actions based on env
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# begin main app
|
||||
case "$1" in
|
||||
healthcheck)
|
||||
shift 1
|
||||
__heath_check "${SERVICE_NAME:-bash}"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
certbot)
|
||||
shift 1
|
||||
SSL_CERT_BOT="true"
|
||||
if [ "$1" = "create" ]; then
|
||||
shift 1
|
||||
__certbot
|
||||
elif [ "$1" = "renew" ]; then
|
||||
shift 1
|
||||
__certbot "renew certonly --force-renew"
|
||||
else
|
||||
__exec_command "certbot" "$@"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if __pgrep "$SERVICE_NAME" && [ ! -f "/tmp/$SERVICE_NAME.pid" ]; then
|
||||
echo "$SERVICE_NAME is running"
|
||||
else
|
||||
touch "/tmp/$SERVICE_NAME.pid"
|
||||
{
|
||||
echo 'Starting dynamic DNS server...'
|
||||
date '+%Y-%m-%d %H:%M'
|
||||
echo "Setting hostname to $HOSTNAME"
|
||||
} &>/data/log/entrypoint.log
|
||||
[ -d "/data/log" ] && rm -Rf /data/log/* || mkdir -p "/data/log"
|
||||
[ -f "/etc/profile" ] && [ ! -f "/root/.profile" ] && cp -Rf "/etc/profile" "/root/.profile"
|
||||
|
||||
if [ -f "/config/rndc.key" ]; then
|
||||
RNDC_KEY="$(cat /config/rndc.key | grep secret | awk '{print $2}' | sed 's|;||g;s|"||g')"
|
||||
else
|
||||
rndc-confgen -a -c /etc/rndc.key &>>/data/log/named.log
|
||||
RNDC_KEY="$(cat /etc/rndc.key | grep secret | awk '{print $2}' | sed 's|;||g;s|"||g')"
|
||||
[ -f "/config/rndc.key" ] || cp -Rf "/etc/rndc.key" "/config/rndc.key" &>>/data/log/entrypoint.log
|
||||
[ -f "/config/rndc.conf" ] || { [ -f "/etc/rndc.conf" ] && cp -Rf "/etc/rndc.conf" "/config/rndc.conf" &>>/data/log/entrypoint.log; }
|
||||
fi
|
||||
[ -d "/run/tor" ] || mkdir -p "/run/tor" &>>/data/log/entrypoint.log
|
||||
[ -d "/etc/dhcp" ] || mkdir -p "/etc/dhcp" &>>/data/log/entrypoint.log
|
||||
[ -d "/run/dhcp" ] || mkdir -p "/run/dhcp" &>>/data/log/entrypoint.log
|
||||
[ -d "/var/tftpboot" ] && [ ! -d "/data/tftp" ] && mv -f "/var/tftpboot" "/data/tftp" &>>/data/log/entrypoint.log
|
||||
[ -d "/var/lib/dhcp" ] || mkdir -p "/var/lib/dhcp" &>>/data/log/entrypoint.log
|
||||
[ -d "/data/tor" ] || cp -Rf "/var/lib/tor" "/data/tor" &>>/data/log/entrypoint.log
|
||||
[ -d "/data/htdocs/www" ] || cp -Rf "/var/lib/ddns/data/htdocs/www" "/data/htdocs/www" &>>/data/log/entrypoint.log
|
||||
[ -d "/data/named" ] || cp -Rf "/var/lib/ddns/data/named" "/data/named" &>>/data/log/entrypoint.log
|
||||
[ -d "/config/tor" ] || cp -Rf "/var/lib/ddns/config/tor" "/config/tor" &>>/data/log/entrypoint.log
|
||||
[ -d "/config/dhcp" ] || cp -Rf "/var/lib/ddns/config/dhcp" "/config/dhcp" &>>/data/log/entrypoint.log
|
||||
[ -d "/config/named" ] || cp -Rf "/var/lib/ddns/config/named" "/config/named" &>>/data/log/entrypoint.log
|
||||
[ -f "/config/radvd.conf" ] || cp -Rf "/var/lib/ddns/config/radvd.conf" "/config/radvd.conf" &>>/data/log/entrypoint.log
|
||||
[ -f "/config/named.conf" ] || cp -Rf "/var/lib/ddns/config/named.conf" "/config/named.conf" &>>/data/log/entrypoint.log
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
find "/config" "/data" -type f -exec sed -i 's|'${OLD_DATE:-2018020901}'|'$DATE'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_DOMAIN|'$DOMAIN_NAME'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_WITH_RNDC_KEY|'$RNDC_KEY'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_ADDRESS|'$IPV4_ADDR'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_ADDR_START|'$IPV4_ADDR_START'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_ADDR_END|'$IPV4_ADDR_END'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_SUBNET|'$IPV4_ADDR_SUBNET'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_NETMASK|'$IPV4_ADDR_NETMASK'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV4_GATEWAY|'$IPV4_ADDR_GATEWAY'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_ADDRESS|'$IPV6_ADDR'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_ADDR_START|'$IPV6_ADDR_START'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_ADDR_END|'$IPV6_ADDR_END'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_SUBNET|'$IPV6_ADDR_SUBNET'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_NETMASK|'$IPV6_ADDR_NETMASK'|g' {} \;
|
||||
find "/config" "/data" -type f -exec sed -i 's|REPLACE_IPV6_GATEWAY|'$IPV6_ADDR_GATEWAY'|g' {} \;
|
||||
|
||||
if [ -f "/config/named.conf" ]; then
|
||||
echo "Initializing named" &>>/data/log/entrypoint.log
|
||||
rm -R /data/log/dns/* &>>/data/log/entrypoint.log
|
||||
cp -Rf "/config/named.conf" "/etc/named.conf"
|
||||
[ -d "/data/log/dns" ] || mkdir -p "/data/log/dns"
|
||||
[ -d "/data/named" ] && cp -Rf "/data/named" "/var/named"
|
||||
[ -d "/config/named" ] && cp -Rf "/config/named" "/etc/named"
|
||||
[ -f "/config/rndc.key" ] && cp -Rf "/config/rndc.key" "/etc/rndc.key"
|
||||
[ -f "/config/rndc.conf" ] && cp -Rf "/config/rndc.conf" "/etc/rndc.conf"
|
||||
chmod -f 777 "/data/log/dns"
|
||||
__run_dns &>>/data/log/named.log &
|
||||
sleep .5
|
||||
fi
|
||||
|
||||
if [ -n "$IP6_ADDR" ]; then
|
||||
if [ -f "/config/dhcp/dhcpd6.conf" ]; then
|
||||
echo "Initializing dhcpd6" &>>/data/log/entrypoint.log
|
||||
cp -Rf "/config/dhcp/dhcpd6.conf" "/etc/dhcp/dhcpd6.conf"
|
||||
touch /var/lib/dhcp/dhcpd6.leases
|
||||
dhcpd -6 -cf /etc/dhcp/dhcpd6.conf &>>/data/log/dhcpd6.log &
|
||||
sleep .5
|
||||
fi
|
||||
if [ -f "/config/radvd.conf" ]; then
|
||||
echo "Initializing radvd" &>>/data/log/entrypoint.log
|
||||
cp -Rf "/config/radvd.conf" "/etc/radvd.conf"
|
||||
radvd -C /etc/radvd.conf &>>/data/log/radvd.log &
|
||||
sleep .5
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "/config/dhcp/dhcpd4.conf" ]; then
|
||||
echo "Initializing dhcpd4" &>>/data/log/entrypoint.log
|
||||
cp -Rf "/config/dhcp/dhcpd4.conf" "/etc/dhcp/dhcpd4.conf"
|
||||
touch /var/lib/dhcp/dhcpd.leases
|
||||
dhcpd -4 -cf /etc/dhcp/dhcpd4.conf &>>/data/log/dhcpd4.log &
|
||||
sleep .5
|
||||
fi
|
||||
|
||||
if [ -d "/config/tor" ]; then
|
||||
echo "Initializing tor" &>>/data/log/entrypoint.log
|
||||
[ -d "/config/tor" ] && cp -Rf "/config/tor" "/etc/tor"
|
||||
chown -Rf root:root "/var/lib/tor"
|
||||
chmod 700 "/run/tor"
|
||||
tor -f "/etc/tor/torrc" &>>/data/log/tor.log &
|
||||
fi
|
||||
if [ -d "/data/tftp" ]; then
|
||||
echo "Initializing tftp" &>>/data/log/entrypoint.log
|
||||
rm -Rf "/var/tftpboot"
|
||||
ln -sf "/data/tftp" "/var/tftpboot"
|
||||
in.tftpd -vv -L /var/tftpboot &>/data/log/tftpd.log &
|
||||
fi
|
||||
if [ -f "/data/htdocs/www/index.php" ]; then
|
||||
echo "Initializing web on $IP_ADDR" &>>/data/log/entrypoint.log
|
||||
nginx -c "/etc/nginx/nginx.conf" &>>/data/log/php.log &
|
||||
sleep .5
|
||||
fi
|
||||
sleep 5
|
||||
date +'%Y-%m-%d %H:%M' >/data/log/entrypoint.log
|
||||
echo "Initializing completed" &>>/data/log/entrypoint.log
|
||||
tail -n 1000 -f /data/log/*.log
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set exit code
|
||||
exitCode="${exitCode:-$?}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# End application
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# lets exit with code
|
||||
exit ${exitCode:-$?}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# end
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,99 @@
|
||||
|
||||
types {
|
||||
text/html html htm shtml;
|
||||
text/css css;
|
||||
text/xml xml;
|
||||
image/gif gif;
|
||||
image/jpeg jpeg jpg;
|
||||
application/javascript js;
|
||||
application/atom+xml atom;
|
||||
application/rss+xml rss;
|
||||
|
||||
text/mathml mml;
|
||||
text/plain txt;
|
||||
text/vnd.sun.j2me.app-descriptor jad;
|
||||
text/vnd.wap.wml wml;
|
||||
text/x-component htc;
|
||||
|
||||
image/avif avif;
|
||||
image/png png;
|
||||
image/svg+xml svg svgz;
|
||||
image/tiff tif tiff;
|
||||
image/vnd.wap.wbmp wbmp;
|
||||
image/webp webp;
|
||||
image/x-icon ico;
|
||||
image/x-jng jng;
|
||||
image/x-ms-bmp bmp;
|
||||
|
||||
font/woff woff;
|
||||
font/woff2 woff2;
|
||||
|
||||
application/java-archive jar war ear;
|
||||
application/json json;
|
||||
application/mac-binhex40 hqx;
|
||||
application/msword doc;
|
||||
application/pdf pdf;
|
||||
application/postscript ps eps ai;
|
||||
application/rtf rtf;
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
application/vnd.google-earth.kml+xml kml;
|
||||
application/vnd.google-earth.kmz kmz;
|
||||
application/vnd.ms-excel xls;
|
||||
application/vnd.ms-fontobject eot;
|
||||
application/vnd.ms-powerpoint ppt;
|
||||
application/vnd.oasis.opendocument.graphics odg;
|
||||
application/vnd.oasis.opendocument.presentation odp;
|
||||
application/vnd.oasis.opendocument.spreadsheet ods;
|
||||
application/vnd.oasis.opendocument.text odt;
|
||||
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
||||
pptx;
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
xlsx;
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||
docx;
|
||||
application/vnd.wap.wmlc wmlc;
|
||||
application/wasm wasm;
|
||||
application/x-7z-compressed 7z;
|
||||
application/x-cocoa cco;
|
||||
application/x-java-archive-diff jardiff;
|
||||
application/x-java-jnlp-file jnlp;
|
||||
application/x-makeself run;
|
||||
application/x-perl pl pm;
|
||||
application/x-pilot prc pdb;
|
||||
application/x-rar-compressed rar;
|
||||
application/x-redhat-package-manager rpm;
|
||||
application/x-sea sea;
|
||||
application/x-shockwave-flash swf;
|
||||
application/x-stuffit sit;
|
||||
application/x-tcl tcl tk;
|
||||
application/x-x509-ca-cert der pem crt;
|
||||
application/x-xpinstall xpi;
|
||||
application/xhtml+xml xhtml;
|
||||
application/xspf+xml xspf;
|
||||
application/zip zip;
|
||||
|
||||
application/octet-stream bin exe dll;
|
||||
application/octet-stream deb;
|
||||
application/octet-stream dmg;
|
||||
application/octet-stream iso img;
|
||||
application/octet-stream msi msp msm;
|
||||
|
||||
audio/midi mid midi kar;
|
||||
audio/mpeg mp3;
|
||||
audio/ogg ogg;
|
||||
audio/x-m4a m4a;
|
||||
audio/x-realaudio ra;
|
||||
|
||||
video/3gpp 3gpp 3gp;
|
||||
video/mp2t ts;
|
||||
video/mp4 mp4;
|
||||
video/mpeg mpeg mpg;
|
||||
video/quicktime mov;
|
||||
video/webm webm;
|
||||
video/x-flv flv;
|
||||
video/x-m4v m4v;
|
||||
video/x-mng mng;
|
||||
video/x-ms-asf asx asf;
|
||||
video/x-ms-wmv wmv;
|
||||
video/x-msvideo avi;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
# Default nginx configuration
|
||||
user root;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /dev/stderr warn;
|
||||
pid /tmp/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
gzip on;
|
||||
map $http_upgrade $connection_upgrade { default upgrade; '' close; }
|
||||
|
||||
server {
|
||||
listen SERVER_PORT;
|
||||
root /data/htdocs/www;
|
||||
index index.html index.php index.cgi index.pl index.aspx awstats.pl index.unknown.php index.default.php index.txt index.json;
|
||||
proxy_intercept_errors off;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header Content-Security-Policy "script-src 'self' 'unsafe-inline' 'unsafe-eval' *; frame-src 'self' *; object-src 'self'" always;
|
||||
|
||||
location = /favicon.ico {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location /nginx_status {
|
||||
stub_status;
|
||||
}
|
||||
|
||||
location /health {
|
||||
default_type text/html;
|
||||
allow all;
|
||||
access_log off;
|
||||
return 200 'OK';
|
||||
}
|
||||
|
||||
location /health.json {
|
||||
default_type application/json;
|
||||
allow all;
|
||||
access_log off;
|
||||
return 200 '{"status":"OK"}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
# Default nginx configuration
|
||||
user root;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /dev/stderr warn;
|
||||
pid /tmp/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
gzip on;
|
||||
map $http_upgrade $connection_upgrade { default upgrade; '' close; }
|
||||
|
||||
server
|
||||
listen SERVER_PORT ssl http2 default_server;
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log info;
|
||||
keepalive_timeout 75 75;
|
||||
root /data/htdocs/www;
|
||||
index index.html index.php index.cgi index.pl index.aspx awstats.pl index.unknown.php index.default.php index.txt index.json;
|
||||
proxy_intercept_errors off;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header Content-Security-Policy "script-src 'self' 'unsafe-inline' 'unsafe-eval' *; frame-src 'self' *; object-src 'self'" always;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_prefer_server_ciphers off;
|
||||
ssl_certificate /config/ssl/localhost.crt;
|
||||
ssl_certificate_key /config/ssl/localhost.key;
|
||||
|
||||
location = /favicon.ico {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location /nginx_status {
|
||||
stub_status;
|
||||
}
|
||||
|
||||
location /health {
|
||||
default_type text/html;
|
||||
allow all;
|
||||
access_log off;
|
||||
return 200 'OK';
|
||||
}
|
||||
|
||||
location /health.json {
|
||||
default_type application/json;
|
||||
allow all;
|
||||
access_log off;
|
||||
return 200 '{"status":"OK"}';
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -10,7 +10,7 @@ SOCKSPolicy accept *
|
||||
RunAsDaemon 0
|
||||
DataDirectory /var/lib/tor
|
||||
ControlPort 9051
|
||||
Log notice stderr
|
||||
Log error stderr
|
||||
#HashedControlPassword 16:kfhkajdsfhkjadhfiuhfhdjcahsf
|
||||
|
||||
############### dnsforwarder
|
||||
File renamed without changes.
File renamed without changes.
+9
-15
@@ -2,7 +2,6 @@
|
||||
<html lang="en-US">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset='utf-8'>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
@@ -10,35 +9,30 @@
|
||||
<meta name="Description" content="Created By Casjays Developments">
|
||||
<meta name="generator" content="CasjaysDev">
|
||||
<link rel="shortcut icon" href="https://static.casjay.net/favicon.ico" />
|
||||
|
||||
<link rel="stylesheet" href="https://static.casjay.net/default-css/github-ribbon.css" />
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.5.0/darkly/bootstrap.min.css" integrity="sha384-Bo21yfmmZuXwcN/9vKrA5jPUMhr7znVBBeLxT9MA4r2BchhusfJ6+n8TLGUcRAtL" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="https:///static.casjay.net/default-css/casjaysdev.css">
|
||||
<script src="htps://static.casjay.net/default-js/errorpages/isup.js"></script>
|
||||
<script src="https://static.casjay.net/default-js/errorpages/homepage.js"></script>
|
||||
<script src="https://static.casjay.net/default-js/errorpages/loaddomain.js"></script>
|
||||
<script src="htps://static.casjay.net/default-js/errorpages/isup.js" async defer></script>
|
||||
<script src="https://static.casjay.net/default-js/errorpages/homepage.js" async defer></script>
|
||||
<script src="https://static.casjay.net/default-js/errorpages/loaddomain.js" async defer></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async defer></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" async defer></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" async defer></script>
|
||||
|
||||
<!-- Begin Main Site -->
|
||||
<title>Dynamic DNS Server</title>
|
||||
|
||||
</head>
|
||||
|
||||
<!-- Begin Body -->
|
||||
|
||||
<body>
|
||||
<!-- Begin Main Body -->
|
||||
<div class="container pt-3">
|
||||
<h1>Welcome</h1>
|
||||
Your dynamic dns server has been setup<br />
|
||||
Your config files can be found in the /config directory.<br />
|
||||
Your data files can be found in the /data directory.<br />
|
||||
Your web files can be found in the /data/web directory.<br />
|
||||
and your log files can be found in /data/logs<br />
|
||||
Your dynamic dns server has been setup<br />
|
||||
Your config files can be found in the /config directory.<br />
|
||||
Your data files can be found in the /data directory.<br />
|
||||
Your web files can be found in the /data/htdocs/www directory.<br />
|
||||
and your log files can be found in /data/logs<br />
|
||||
</div>
|
||||
|
||||
<!-- End Main End Body -->
|
||||
|
||||
<br />
|
||||
@@ -48,7 +42,7 @@ and your log files can be found in /data/logs<br />
|
||||
<!-- Begin Casjays Developments Footer -->
|
||||
Copyright 1999 - 2021
|
||||
<br />
|
||||
<a href="https://casjay.net" target="_blank">Casjays Developments</a> and <a href="https://jason.malaks.us" target="_blank">Jason M. Hempstead-Malak</a><br />
|
||||
<a href="https://casjay.net" target="_blank">Casjays Developments</a> and <a href="https://malaks-us.github.com/jason" target="_blank">Jason M. Hempstead-Malak</a><br />
|
||||
Hosting by <a href="https://casjay.net/hosting" target="_blank">Casjays Developments: Hosting</a><br />
|
||||
and powered by <a href="https://casjaysdev.com" target="_blank">CasjaysDev.com</a>
|
||||
<br />
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Whitespace-only changes.
Reference in new issue
Block a user