mirror of
https://github.com/casjaysdevdocker/nodejs
synced 2026-06-23 20:01:02 -04:00
72bd7b6dce
Migrate nodejs Docker image to the new build-time config architecture.
- rootfs/root/docker/setup/03-files.sh: rewrite to canonical form with /tmp/bin, /tmp/var, /tmp/etc, /tmp/usr handlers; remove template-files copy block
- rootfs/usr/local/etc/docker/functions/entrypoint.sh: update to latest template with __init_service_conf, __find_php_ini, __find_php_bin helpers
- rootfs/usr/local/etc/docker/init.d/*.sh: fix $(basename) UUOC → ${var##*/}; move inline comments above code lines; remove commented-out dead code
- rootfs/usr/local/share/template-files/: delete entire directory; config files now deployed via /tmp/etc/ at build time
rootfs/root/docker/setup/03-files.sh
rootfs/usr/local/etc/docker/functions/entrypoint.sh
rootfs/usr/local/etc/docker/init.d/mongodb
rootfs/usr/local/etc/docker/init.d/nodejs
rootfs/usr/local/share/template-files/config/env/default.sample
rootfs/usr/local/share/template-files/config/env/examples/00-directory.sh
rootfs/usr/local/share/template-files/config/env/examples/addresses.sh
rootfs/usr/local/share/template-files/config/env/examples/certbot.sh
rootfs/usr/local/share/template-files/config/env/examples/couchdb.sh
rootfs/usr/local/share/template-files/config/env/examples/dockerd.sh
rootfs/usr/local/share/template-files/config/env/examples/global.sh
rootfs/usr/local/share/template-files/config/env/examples/healthcheck.sh
rootfs/usr/local/share/template-files/config/env/examples/mariadb.sh
rootfs/usr/local/share/template-files/config/env/examples/mongodb.sh
rootfs/usr/local/share/template-files/config/env/examples/networking.sh
rootfs/usr/local/share/template-files/config/env/examples/other.sh
rootfs/usr/local/share/template-files/config/env/examples/php.sh
rootfs/usr/local/share/template-files/config/env/examples/postgres.sh
rootfs/usr/local/share/template-files/config/env/examples/redis.sh
rootfs/usr/local/share/template-files/config/env/examples/services.sh
rootfs/usr/local/share/template-files/config/env/examples/ssl.sh
rootfs/usr/local/share/template-files/config/env/examples/supabase.sh
rootfs/usr/local/share/template-files/config/env/examples/webservers.sh
rootfs/usr/local/share/template-files/config/env/examples/zz-entrypoint.sh
rootfs/usr/local/share/template-files/config/.gitkeep
rootfs/usr/local/share/template-files/data/.gitkeep
rootfs/usr/local/share/template-files/defaults/.gitkeep
98 lines
3.6 KiB
Bash
Executable File
98 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
##@Version : 202601290255-git
|
|
# @@Author : CasjaysDev
|
|
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
|
# @@License : MIT
|
|
# @@ReadME :
|
|
# @@Copyright : Copyright 2025 CasjaysDev
|
|
# @@Created : Wed Jan 29 02:55:00 AM EST 2026
|
|
# @@File : mongodb
|
|
# @@Description : MongoDB initialization script
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# shellcheck disable=SC2016
|
|
# shellcheck disable=SC2031
|
|
# shellcheck disable=SC2120
|
|
# shellcheck disable=SC2155
|
|
# shellcheck disable=SC2199
|
|
# shellcheck disable=SC2317
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
APPNAME="${0##*/}"
|
|
VERSION="202601290255-git"
|
|
HOME="${USER_HOME:-$HOME}"
|
|
USER="${SUDO_USER:-$USER}"
|
|
RUN_USER="${SUDO_USER:-$USER}"
|
|
SCRIPT_SRC_DIR="${BASH_SOURCE%/*}"
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# Set bash options
|
|
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -o pipefail -x$DEBUGGER_OPTIONS || set -o pipefail
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# check for command
|
|
__cmd_exists() { command -v "$1" >/dev/null 2>&1 || return 1; }
|
|
__function_exists() { builtin type -t "${1:-404}" 2>/dev/null | grep -q 'function' || return 1; }
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# Make sure mongod is installed
|
|
if ! __cmd_exists mongod; then
|
|
echo "MongoDB is not installed"
|
|
exit 0
|
|
fi
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# Set variables
|
|
MONGODB_DATA_DIR="${MONGODB_DATA_DIR:-${DATABASE_DIR_MONGODB:-/data/db/mongodb}}"
|
|
MONGODB_LOG_DIR="${MONGODB_LOG_DIR:-/var/log/mongodb}"
|
|
MONGODB_LOG_FILE="${MONGODB_LOG_FILE:-$MONGODB_LOG_DIR/mongod.log}"
|
|
MONGODB_PORT="${MONGODB_PORT:-27017}"
|
|
MONGODB_BIND_IP="${MONGODB_BIND_IP:-0.0.0.0}"
|
|
MONGODB_USER="${MONGODB_USER:-mongodb}"
|
|
MONGODB_CONFIG_FILE="${MONGODB_CONFIG_FILE:-/etc/mongod.conf}"
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# Ensure directories exist
|
|
mkdir -p "$MONGODB_DATA_DIR" "$MONGODB_LOG_DIR"
|
|
touch "$MONGODB_LOG_FILE"
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# Set permissions
|
|
if id "$MONGODB_USER" >/dev/null 2>&1; then
|
|
chown -Rf "$MONGODB_USER:$MONGODB_USER" "$MONGODB_DATA_DIR" "$MONGODB_LOG_DIR" 2>/dev/null
|
|
chmod -Rf 755 "$MONGODB_DATA_DIR" "$MONGODB_LOG_DIR" 2>/dev/null
|
|
fi
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# Create basic config if it doesn't exist
|
|
if [ ! -f "$MONGODB_CONFIG_FILE" ]; then
|
|
cat <<EOF >"$MONGODB_CONFIG_FILE"
|
|
# MongoDB configuration file
|
|
storage:
|
|
dbPath: $MONGODB_DATA_DIR
|
|
journal:
|
|
enabled: true
|
|
|
|
systemLog:
|
|
destination: file
|
|
logAppend: true
|
|
path: $MONGODB_LOG_FILE
|
|
|
|
net:
|
|
port: $MONGODB_PORT
|
|
bindIp: $MONGODB_BIND_IP
|
|
|
|
processManagement:
|
|
timeZoneInfo: /usr/share/zoneinfo
|
|
EOF
|
|
fi
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
echo "Starting MongoDB on port $MONGODB_PORT"
|
|
echo "Data directory: $MONGODB_DATA_DIR"
|
|
echo "Log file: $MONGODB_LOG_FILE"
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# Start MongoDB in background
|
|
if [ -f "$MONGODB_CONFIG_FILE" ]; then
|
|
mongod --config "$MONGODB_CONFIG_FILE" &
|
|
else
|
|
mongod --dbpath "$MONGODB_DATA_DIR" --logpath "$MONGODB_LOG_FILE" --port "$MONGODB_PORT" --bind_ip "$MONGODB_BIND_IP" &
|
|
fi
|
|
# Wait a moment for MongoDB to start
|
|
sleep 2
|
|
echo "MongoDB started"
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# End script
|