🗃️ Committing everything that changed 🗃️

This commit is contained in:
casjay 2022-10-10 22:32:35 -04:00
parent ca8b3000be
commit e6835d122c
No known key found for this signature in database
GPG Key ID: 4F765975C1F0EE5F
4 changed files with 136 additions and 34 deletions

View File

@ -1,5 +1,7 @@
FROM casjaysdevdocker/python2:latest AS build
ARG PORTS="80 443"
WORKDIR /tmp/build
RUN apk -U upgrade && \
@ -55,9 +57,9 @@ COPY ./config/. /usr/local/share/template-files/config/
ENV PHP_SERVER=cherokee
WORKDIR /data/htdocs
WORKDIR /data/htdocs/www
EXPOSE 19070 19071
EXPOSE $PORTS
VOLUME [ "/data", "/config" ]

View File

@ -16,7 +16,7 @@ fi
[ -d "/usr/local/share/cherokee/icons" ] && [ ! -d "/config/cherokee/icons" ] && cp -Rf "/usr/local/share/cherokee/icons/." "/config/cherokee/icons/"
[ -d "/usr/local/share/cherokee/themes" ] && [ ! -d "/config/cherokee/themes" ] && cp -Rf "/usr/local/share/cherokee/themes/." "/config/cherokee/themes/"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ ! -f "/config/ssl/key.pem" ] || [ ! -f "/etc/ssl/crt.pem" ]; then
if [ ! -f "/config/ssl//localhost.crt" ] || [ ! -f "/config/ssl//localhost.key" ]; then
create-ssl-cert
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -1,41 +1,141 @@
#!/usr/bin/env bash
export TZ="${TZ:-America/New_York}"
export HOSTNAME="${HOSTNAME:-casjaysdev-cherokee}"
[ -n "${TZ}" ] && echo "${TZ}" >/etc/timezone
[ -n "${HOSTNAME}" ] && echo "${HOSTNAME}" >/etc/hostname
[ -n "${HOSTNAME}" ] && echo "127.0.0.1 $HOSTNAME localhost" >/etc/hosts
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202210102226-git
# @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.com
# @@License : LICENSE.md
# @@ReadME : entrypoint-cherokee.sh --help
# @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
# @@Created : Monday, Oct 10, 2022 22:26 EDT
# @@File : entrypoint-cherokee.sh
# @@Description :
# @@Changelog : New script
# @@TODO : Better documentation
# @@Other :
# @@Resource :
# @@Terminal App : no
# @@sudo/root : no
# @@Template : other/docker-entrypoint
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APPNAME="$(basename "$0" 2>/dev/null)"
VERSION="202210102226-git"
HOME="${USER_HOME:-$HOME}"
USER="${SUDO_USER:-$USER}"
RUN_USER="${SUDO_USER:-$USER}"
SCRIPT_SRC_DIR="${BASH_SOURCE%/*}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
[ "$1" == "--debug" ] && set -xo pipefail && export SCRIPT_OPTS="--debug" && export _DEBUG="on"
[ "$1" == "--raw" ] && export SHOW_RAW="true"
set -o pipefail
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set functions
__version() { echo -e ${GREEN:-}"$VERSION"${NC:-}; }
__find() { ls -A "$*" 2>/dev/null; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# colorization
[ -n "$SHOW_RAW" ] || printf_color() { echo -e '\t\t'${2:-}"${1:-}${NC}"; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__exec_command() {
local cmd="${*:-/bin/bash -l}"
local exitCode=0
echo "Executing command: $cmd"
eval "$cmd" || exitCode=10
return ${exitCode:-$?}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Functions
__heath_check() {
local status=0
#curl -q -LSsf -o /dev/null -s -w "200" "http://localhost/server-health" || status=$(($status + 1))
return ${status:-$?}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Define default variables - don not change these
TZ="${TZ:-America/New_York}"
LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
HOSTNAME="${HOSTNAME:-casjaysdev-bin}"
TEMPLATE_DATA_DIR="$(__find /usr/local/share/template-files/data/ 2>/dev/null | grep '^' || echo '')"
TEMPLATE_CONFIG_DIR="$(__find /usr/local/share/template-files/config/ 2>/dev/null | grep '^' || echo '')"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional variables and variable overrides
SSL="true"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 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"
if [[ ! -f "/config/ssl/key.pem" ]] || [[ ! -f "/etc/ssl/crt.pem" ]]; then
openssl req \
-new \
-newkey rsa:4096 \
-days 365 \
-nodes \
-x509 \
-subj "/C=US/ST=CA/L=Manhattan\ Beach/O=Managed\ Kaos/OU=Cherokee\ SSL/CN=localhost" \
-keyout /etc/ssl/server.pem \
-out /etc/ssl/server.pem
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set hostname
if [ -n "${HOSTNAME}" ]; then
echo "${HOSTNAME}" >"/etc/hostname"
echo "127.0.0.1 ${HOSTNAME} localhost ${HOSTNAME}.local" >"/etc/hosts"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Delete any gitkeep files
if [ "$SSL" = "true" ] || [ "$SSL" = "yes" ]; then
if [ -f "/config/ssl/server.crt" ] && [ -f "/config/ssl/server.key" ]; then
SSL="on"
SSL_CERT="/config/ssl/server.crt"
SSL_KEY="/config/ssl/server.key"
if [ -f "/config/ssl/ca.crt" ]; then
mkdir -p "/etc/ssl/certs"
cat "/config/ssl/ca.crt" >>"/etc/ssl/certs/ca-certificates.crt"
fi
else
[ -d "/config/ssl" ] || mkdir -p "/config/ssl"
export SSL_DIR="/config/ssl"
create-ssl-cert
fi
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Update ssl certificates
[ -f "/config/ssl/ca.crt" ] && cat "/config/ssl/ca.crt" >>"/etc/ssl/certs/ca-certificates.crt"
type update-ca-certificates &>/dev/null && update-ca-certificates
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Export variables
export TZ HOSTNAME
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional commands
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case "$1" in
healthcheck)
CH_PORT="$(netstat -lnt | grep -q "80" && echo "OK" || false)"
[ -n "$CH_PORT" ] && exit 0 || exit 1
--help) # Help message
echo 'Docker container for '$APPNAME''
echo "Usage: $APPNAME [healthcheck, bash, command]"
echo "Failed command will have exit code 10"
echo
exitCode=$?
;;
bash)
healthcheck) # Docker healthcheck
__heath_check || exit 10
echo "$(uname -s) $(uname -m) is running"
exitCode=$?
;;
*/bin/sh | */bin/bash | bash | shell | sh) # Launch shell
shift 1
exec /bin/bash "$@"
exit
__exec_command "${@:-/bin/bash}"
exitCode=$?
;;
*)
/usr/sbin/cherokee-admin -b -p 19070 -c /config/cherokee.conf &
exec /usr/sbin/cherokee -c /config/cherokee.conf
*) # Execute primary command
if [ $# -eq 0 ]; then
cherokee-server
exitCode=$?
else
__exec_command "$@"
exitCode=$?
fi
;;
esac
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# end of entrypoint
exit ${exitCode:-$?}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -40,8 +40,8 @@ vserver!1!rule!2!match!directory = /cherokee_icons
vserver!1!rule!1!handler = common
vserver!1!rule!1!handler!iocache = 1
vserver!1!rule!1!match = default
vserver!1!ssl_certificate_file = /config/ssl/server.pem
vserver!1!ssl_certificate_key_file = /config/ssl/server.pem
vserver!1!ssl_certificate_file = /config/ssl//localhost.crt
vserver!1!ssl_certificate_key_file = /config/ssl//localhost.key
icons!default = page_white.png
icons!directory = folder.png
icons!file!bomb.png = core