docker-webserver-nginx/rootfs/app/entrypoint.sh

38 lines
1.0 KiB
Bash
Raw Normal View History

2024-12-13 09:00:45 +00:00
#!/bin/sh
2024-12-13 10:34:16 +00:00
WEBROOT=/data/www
2024-12-13 09:00:45 +00:00
PHP=${PHP:-none}
USERNAME=${USERNAME:-theuser}
2024-12-13 09:45:43 +00:00
RANDOMPWD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13)
2024-12-13 10:34:16 +00:00
adduser -DH -h "${WEBROOT}" -G "nginx" -u "1000" "${USERNAME}"
printf '%s\n%s' "${RANDOMPWD}" "${RANDOMPWD}" | passwd "${USERNAME}"
echo "password for the user \"${USERNAME}\" is: ${RANDOMPWD}"
2024-12-13 09:00:45 +00:00
chown "${USERNAME}:nginx" "${WEBROOT}" -R
find "${WEBROOT}" -type d -exec chmod 0755 {} \;
find "${WEBROOT}" -type f -exec chmod 0644 {} \;
envsubst < /app/nginx.conf.tpl > /etc/nginx/http.d/default.conf
2024-12-13 10:34:16 +00:00
# start php
2024-12-13 09:00:45 +00:00
case "${PHP}" in
"php84") /usr/sbin/php-fpm84 -D ;;
"php83") /usr/sbin/php-fpm83 -D ;;
"php82") /usr/sbin/php-fpm82 -D ;;
*) ;;
esac
2024-12-13 10:34:16 +00:00
# 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
2024-12-13 09:00:45 +00:00
nginx