diff --git a/bin/dev b/bin/dev index 2cf218f..8f99d36 100755 --- a/bin/dev +++ b/bin/dev @@ -14,4 +14,4 @@ export PANEL_VERSION export DAEMON_VERSION # Just pass everything to compose -docker-compose -f docker-compose.panel.yml -f docker-compose.daemon.yml -f ./manifest/docker-compose.dev.yml $@ \ No newline at end of file +docker-compose -f docker-compose.yml -f ./manifest/docker-compose.dev.yml $@ diff --git a/bin/init b/bin/init index 2b58eb3..5edb7a8 100755 --- a/bin/init +++ b/bin/init @@ -14,6 +14,7 @@ enable_service_panel="" enable_service_node="" enable_service_db="" enable_service_le="" +enable_sftp_daemon="" #Database Options @@ -37,6 +38,8 @@ function _return_help { echo " --enable-db - adds mysql database" echo " --enable-daemon - adds daemon" echo " --enable-letsencrypt - adds letsencrypt" + echo " --db-address" + echo " --daemon-dir" echo "" } @@ -54,6 +57,7 @@ function build_config { combine_args=$combine_args" ./manifest/compose/db.yml" fi if [ "$enable_service_le" == "x" ]; then + echo "enabled" if [ "$le_panel" == "true" ]; then combine_args=$combine_args" ./manifest/compose/le.panel.yml" else @@ -62,7 +66,16 @@ function build_config { fi IFS=" " - bin/yq merge -a ${combine_args} > docker-compose.yml + bin/yq merge -a ${combine_args} | bin/yq read --stripComments - > docker-compose.yml + + # Modifiers for compose file + if [ ! "$node_directory" == "" ] && [ "$enable_service_node" == "x" ]; then + bin/yq write -i docker-compose.yml "services.daemon.volumes[0]" "$node_directory:$node_directory" + fi + + if [ ! "$database_ip_address" == "" ] && [ "$enable_service_db" == "x" ]; then + bin/yq write -i docker-compose.yml "services.mysql.ports[0]" "$database_ip_address:3306" + fi if ! [ -d "conf.d" ]; then mkdir conf.d @@ -80,11 +93,6 @@ if [[ -z "$_COMPOSE_EXE" ]]; then exit 2 fi -if [ -e "docker-compose.yml" ]; then - echo "docker-compose.yml already exists. Please delete or change this file before running this script." - exit -fi - cd "$(dirname $0)/../" # Split our arguements into seperate sections @@ -96,6 +104,7 @@ for ((i=1; i<=$#; i++)); do _return_help exit ;; + # Enable Services --enable-daemon) # Enables wings enable_service_node="x" ;; @@ -108,6 +117,15 @@ for ((i=1; i<=$#; i++)); do --enable-letsencrypt) # Enable Let's Encrypt enable_service_le="x" ;; + # Modify Certain runtime options + --daemon-dir) + ((i++)) + node_directory="${!i}" + ;; + --db-address) + ((i++)) + database_ip_address="${!i}" + ;; esac else _command+=("${!i}") diff --git a/manifest/compose/daemon.yml b/manifest/compose/daemon.yml index 6af68b8..48a4fab 100644 --- a/manifest/compose/daemon.yml +++ b/manifest/compose/daemon.yml @@ -1,6 +1,10 @@ version: '2.1' services: daemon: + ## + # --Pterodactyl Daemon-- + # This service provides the wings runtime. + ## image: ccarney16/pterodactyl-daemon:latest ports: - 2022:2022 diff --git a/manifest/compose/db.yml b/manifest/compose/db.yml index d5ad38e..c0fa06c 100644 --- a/manifest/compose/db.yml +++ b/manifest/compose/db.yml @@ -1,17 +1,26 @@ ### -# Optional ProjectDependencies for Pterodactyl +# Optional Project Dependencies for Pterodactyl # # This compose file provides the required dependencies for # Pterodactyl, such as MariaDB and Redis. ## version: '2.1' services: + ## + # --MariaDB-- + # Required for the control panel to work. + # Stores Server/User information + ## mysql: image: mariadb:10.4 env_file: ./conf.d/mariadb.env restart: always volumes: - ./data/db:/var/lib/mysql + ## + # --Redis-- + # Handles Session Data + ## redis: image: redis:alpine restart: always diff --git a/manifest/compose/panel.yml b/manifest/compose/panel.yml index 40334e6..dad592d 100644 --- a/manifest/compose/panel.yml +++ b/manifest/compose/panel.yml @@ -1,13 +1,5 @@ -### -# Pterodactyl Panel docker-compose file -# -# This File contains the main panel runtime along with -# workers, to enable this file, add the filename to -# "COMPOSE_FILE" within .env -### version: '2.1' services: - ## # --Pterodactyl Panel-- # This is the container that provides the main web interface. @@ -21,14 +13,12 @@ services: restart: always volumes: - ./data/panel:/data - # Enable Let's Encrypt Support - ./conf.d/letsencrypt:/etc/letsencrypt:ro - ./conf.d/webroot/.well-known:/var/www/html/public/.well-known:ro - ./conf.d/certs:/etc/certs:ro - ## - # --Worker and Cron tasks-- + # --Worker-- # These are required for schedules and other misc tasks to # function correctly. ## @@ -39,10 +29,15 @@ services: restart: always volumes_from: - panel + ## + # --Cron-- + # These are required for schedules and other misc tasks to + # function correctly. + ## cron: command: p:cron env_file: ./conf.d/panel.env image: ccarney16/pterodactyl-panel:latest restart: always - volumes_from: + volumes_from: - panel diff --git a/manifest/panel/Dockerfile b/manifest/panel/Dockerfile index 8963fef..2e56af7 100644 --- a/manifest/panel/Dockerfile +++ b/manifest/panel/Dockerfile @@ -48,7 +48,8 @@ RUN \ RUN \ yarn install --production; \ yarn add cross-env; \ - yarn run build:production; + yarn run build:production; \ + rm -rf node_modules; # Final Production phase of the controller diff --git a/manifest/panel/entrypoint.sh b/manifest/panel/entrypoint.sh index 09d975b..cedd354 100755 --- a/manifest/panel/entrypoint.sh +++ b/manifest/panel/entrypoint.sh @@ -12,14 +12,14 @@ function init { cat .storage.tmpl | while read line; do mkdir -p "/data/${line}" done - chown -R nginx:nginx /data/storage fi if [ ! -d /data/cache ]; then mkdir -p /data/cache - chown -R nginx:nginx /data/cache fi + chown -R nginx:nginx /data/ + # destroy links (or files) and recreate them rm -rf storage ln -s /data/storage storage @@ -34,9 +34,22 @@ function init { # Runs the initial configuration on every startup function startServer { + printf "Pre-start: Waiting for database connection..." + i=0 + until [ nc -z -v -w30 $DB_HOST $DB_PORT ]; do + printf "." + # wait for 5 seconds before check again + sleep 5 + ((i++)) + if ((i=5)); then + echo "Database Connection Timeout (Is MySQL Running?)" + exit + fi + done + # Initial setup if [ ! -e /data/pterodactyl.conf ]; then - echo "Running first time setup..." + echo "Setup: Running first time setup..." # Generate base template touch /data/pterodactyl.conf @@ -53,12 +66,12 @@ function startServer { sleep 5 echo "" - echo "Generating key..." + echo "Setup: Generating key..." sleep 1 php artisan key:generate --force --no-interaction echo "" - echo "Creating & seeding database..." + echo "Setup: Creating & seeding database..." sleep 1 php artisan migrate --force php artisan db:seed --force @@ -79,7 +92,7 @@ function startServer { envsubst '${SSL_CERT},${SSL_CERT_KEY}' \ < /etc/nginx/templates/https.conf > /etc/nginx/conf.d/default.conf else - echo "[Warning] Disabling HTTPS" + echo "Warning: Disabling HTTPS" cat /etc/nginx/templates/http.conf > /etc/nginx/conf.d/default.conf fi diff --git a/manifest/sftp/Dockerfile b/manifest/sftp/Dockerfile deleted file mode 100644 index 04ca492..0000000 --- a/manifest/sftp/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM alpine:latest - -ARG VERSION - -ENV SFTP_VERSION=${VERSION} \ - UID=500 - -RUN mkdir /srv/daemon -p; \ - wget -P /srv/daemon https://github.com/pterodactyl/sftp-server/releases/download/${SFTP_VERSION}/sftp-server; \ - chmod +x /srv/daemon/sftp-server; \ - addgroup -S -g ${UID} pterodactyl && adduser -S -D -H -G pterodactyl -u ${UID} -s /bin/false pterodactyl - -EXPOSE 2022 - -WORKDIR /srv/daemon -ENTRYPOINT [ "./sftp-server" ] -CMD [ "-port", "2022" ] \ No newline at end of file