docker-webserver-nginx/rootfs/app/entrypoint.sh
paspo aff9d897c7
All checks were successful
continuous-integration/drone/push Build is passing
fix index in php mode
2024-12-16 19:09:18 +01:00

55 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
WEBROOT=/data/www
PHP=${PHP:-none}
USERNAME=${USERNAME:-theuser}
PUID=${PUID:-1000}
GROUPNAME=${GROUPNAME:-thegroup}
PGID=${PGID:-1000}
RANDOMPWD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13)
addgroup -g "${PGID}" "${GROUPNAME}"
addgroup nginx "${GROUPNAME}"
adduser -DH -h "${WEBROOT}" -G "${GROUPNAME}" -u "${PUID}" "${USERNAME}"
printf '%s\n%s' "${RANDOMPWD}" "${RANDOMPWD}" | passwd "${USERNAME}"
echo "password for the user \"${USERNAME}\" is: ${RANDOMPWD}"
chown "${PUID}:${GROUPNAME}" "${WEBROOT}" -R
find "${WEBROOT}" -type d -exec chmod 0755 {} \;
find "${WEBROOT}" -type f -exec chmod 0644 {} \;
# start php
case "${PHP}" in
"php84")
cp /app/nginx/php84.conf /etc/nginx/custom.d/
cp /app/nginx/default_php.conf /etc/nginx/http.d/default.conf
/usr/sbin/php-fpm84 -D
;;
"php83")
cp /app/nginx/php83.conf /etc/nginx/custom.d/
cp /app/nginx/default_php.conf /etc/nginx/http.d/default.conf
/usr/sbin/php-fpm83 -D
;;
"php82")
cp /app/nginx/php82.conf /etc/nginx/custom.d/
cp /app/nginx/default_php.conf /etc/nginx/http.d/default.conf
/usr/sbin/php-fpm82 -D
;;
*)
cp /app/nginx/default_nophp.conf /etc/nginx/http.d/default.conf
;;
esac
# start ssh
for keytype in ecdsa rsa ed25519 ; do
if [ ! -r "/ssh/ssh_host_${keytype}_key" ] ; then
/usr/bin/ssh-keygen -t "${keytype}" -f "/ssh/ssh_host_${keytype}_key" -N ""
fi
chmod 0600 "/ssh/ssh_host_${keytype}_key"
chmod 0644 "/ssh/ssh_host_${keytype}_key.pub"
done
chmod 0700 "${WEBROOT}/.ssh"
/usr/sbin/sshd -e
# start nginx
nginx