Cleanup and initial commit

This commit is contained in:
2024-01-10 17:15:41 -06:00
parent 736f325590
commit bde7e8eca7
14 changed files with 422 additions and 1 deletions

View File

@@ -0,0 +1,69 @@
#!/usr/bin/with-contenv bash
source ContainerTools
SNAME=${BASH_SOURCE##*/}
# If DBHOST value is present, pause boot until target container is up.
if [ -n "$DBHOST" ]; then
log "Waiting for SQL at $DBHOST:${DBPORT:=3306}"
if wait-for-it $DBHOST:$DBPORT -q -t ${TESTTIME:=30}; then
log "SQL found, continuing"
else
log "SQL could not be reached! Exiting..."
exit 1
fi
fi
# If REDISHOST value is present, pause boot until target container is up.
if [ -n "$REDISHOST" ]; then
log "Waiting for Redis at $REDISHOST:${REDISPORT:=6379}"
if wait-for-it $REDISHOST:$REDISPORT -q -t ${TESTTIME:=30}; then
log "Redis found, continuing"
else
log "Redis could not be reached! Exiting..."
exit 1
fi
fi
# Check for persistent storage directory, create file structure if not present.
if [ ! -d "/config/storage" ]; then
log "Creating storage directory"
cat .storage.tmpl | while read line; do
mkdir -p "/config/${line}"
done
fi
# Check for persistent logging directory, create file path if not present.
if [ ! -d "/config/log/nginx" ]; then
log "Creating log directory."
mkdir -p "/config/log/nginx"
fi
# Check for config file, create template if not present.
if [ ! -e /config/pterodactyl.conf ]; then
log "Config file does not exist, creating template"
log "[WARN] Connect to container and finish setup process"
cp .env.example /config/pterodactyl.conf
log "Generating unique Pterodactyl key"
log "$(php artisan key:generate --force --no-interaction)"
fi
# Clear views and autogenerated configs on launch. This is necessary for updates, and doesn't affect non-update launches.
log "$(php artisan view:clear)"
log "$(php artisan config:clear)"
log "Checking for database updates, preparing cache"
log "[NOTE] This will fail if the database connection has not yet been configured"
log "$(php artisan migrate --seed --force)"
chown -R nginx:nginx /config/
# Load selected Nginx conf.
if [ "$HTTPS" == "true" ]; then
if [ ! -e "/etc/nginx/http.d/pterodactyl.conf" ]; then
log "Symlinking Nginx config file for HTTPS"
ln -s /defaults/nginx/https.conf /etc/nginx/http.d/pterodactyl.conf
fi
else
if [ ! -e "/etc/nginx/http.d/pterodactyl.conf" ]; then
log "Symlinking Nginx config file for HTTP"
ln -s /defaults/nginx/http.conf /etc/nginx/http.d/pterodactyl.conf
fi
fi

1
root/etc/crontabs/nginx Normal file
View File

@@ -0,0 +1 @@
* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1

44
root/etc/nginx/nginx.conf Normal file
View File

@@ -0,0 +1,44 @@
user nginx;
worker_processes auto;
pcre_jit on;
error_log /var/log/nginx/error.log warn;
include /etc/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
client_max_body_size 1m;
sendfile on;
tcp_nopush on;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:2m;
ssl_session_timeout 5M;
ssl_session_tickets off;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
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;
include /etc/nginx/http.d/*.conf;
}

View File

@@ -0,0 +1,5 @@
[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php/error.log
log_level = warning
include=/etc/php/php-fpm.d/*.conf

View File

@@ -0,0 +1,17 @@
[nginx]
user = nginx
group = nginx
listen = /run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0750
pm = ondemand
pm.max_children = 9
pm.process_idle_timeout = 10s
pm.max_requests = 200
slowlog = /dev/stdout
request_slowlog_timeout = 60s
catch_workers_output = yes

View File

@@ -0,0 +1,2 @@
#!/usr/bin/execlineb -P
/usr/sbin/crond -fL /dev/null

View File

@@ -0,0 +1,2 @@
#!/usr/bin/execlineb -P
/usr/sbin/nginx -g "daemon off;"

View File

@@ -0,0 +1,2 @@
#!/usr/bin/execlineb -P
/usr/sbin/php-fpm -Fc /etc/php

View File

@@ -0,0 +1,3 @@
#!/usr/bin/execlineb -P
s6-setuidgid nginx
/usr/bin/php /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3