Skip to content

Commit d66a8dd

Browse files
authored
Update egg-nginx.json
Fixes the problem that no php info file is created when not using Git and Wordpress. Replaced non-existing variable with a new one for the if query.
1 parent 4a6145b commit d66a8dd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

egg-nginx.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "PTDL_v2",
55
"update_url": null
66
},
7-
"exported_at": "2024-10-03T15:22:02+02:00",
7+
"exported_at": "2024-10-08T17:00:42+02:00",
88
"name": "Nginx",
99
"author": "[email protected]",
1010
"description": "NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP\/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.",
@@ -25,7 +25,7 @@
2525
},
2626
"scripts": {
2727
"installation": {
28-
"script": "#!\/bin\/bash\r\n\r\n# [SETUP] Install necessary packages, including git\r\necho -e \"[SETUP] Install packages\"\r\napt-get update -qq > \/dev\/null 2>&1 && apt-get install -qq > \/dev\/null 2>&1 -y git wget perl perl-doc fcgiwrap\r\n\r\n# Change to server directory\r\ncd \/mnt\/server\r\n\r\n# [SETUP] Create necessary folders\r\necho -e \"[SETUP] Create folders\"\r\nmkdir -p logs tmp www\r\n\r\n# Clone the default repository into a temporary directory\r\necho \"[Git] Cloning default repository 'https:\/\/github.com\/Ym0T\/pterodactyl-nginx-egg' into temporary directory.\"\r\ngit clone https:\/\/github.com\/Ym0T\/pterodactyl-nginx-egg \/mnt\/server\/gtemp > \/dev\/null 2>&1 && echo \"[Git] Repository cloned successfully.\" || { echo \"[Git] Error: Default repository clone failed.\"; exit 21; }\r\n\r\n# Copy the www folder and files from the temporary repository to the target directory\r\necho \"[Git] Copying folder and files from default repository.\"\r\ncp -r \/mnt\/server\/gtemp\/nginx \/mnt\/server || { echo \"[Git] Error: Copying 'nginx' folder failed.\"; exit 22; }\r\ncp -r \/mnt\/server\/gtemp\/php \/mnt\/server || { echo \"[Git] Error: Copying 'php' folder failed.\"; exit 22; }\r\ncp \/mnt\/server\/gtemp\/nginx.sh \/mnt\/server || { echo \"[Git] Error: Copying 'nginx.sh' file failed.\"; exit 22; }\r\ncp \/mnt\/server\/gtemp\/pull-git.sh \/mnt\/server || { echo \"[Git] Error: Copying 'pull-git.sh' file failed.\"; exit 22; }\r\nchmod +x \/mnt\/server\/nginx.sh && chmod +x \/mnt\/server\/pull-git.sh\r\n\r\n# Remove the temporary cloned repository\r\nrm -rf \/mnt\/server\/gtemp\r\n\r\n# Check if GIT_ADDRESS is set\r\nif [ -z \"${GIT_ADDRESS}\" ]; then\r\n echo \"[Git] Info: GIT_ADDRESS is not set.\"\r\n echo \"[Git] Git operations are disabled. Skipping Git actions.\"\r\nelse\r\n # Add .git suffix to GIT_ADDRESS if it's not present\r\n if [[ ${GIT_ADDRESS} != *.git ]]; then\r\n GIT_ADDRESS=\"${GIT_ADDRESS}.git\"\r\n echo \"[Git] Added .git suffix to GIT_ADDRESS: ${GIT_ADDRESS}\"\r\n fi\r\n\r\n # If username and access token are provided, use authenticated access\r\n if [ -n \"${USERNAME}\" ] && [ -n \"${ACCESS_TOKEN}\" ]; then\r\n echo \"[Git] Using authenticated Git access.\"\r\n \r\n # Extract the domain and the rest of the URL, ensuring the correct format\r\n GIT_DOMAIN=$(echo \"${GIT_ADDRESS}\" | cut -d\/ -f3)\r\n GIT_REPO=$(echo \"${GIT_ADDRESS}\" | cut -d\/ -f4-) # Rest of the URL after the domain\r\n \r\n # Construct the authenticated Git URL\r\n GIT_ADDRESS=\"https:\/\/${USERNAME}:${ACCESS_TOKEN}@${GIT_DOMAIN}\/${GIT_REPO}\"\r\n \r\n echo \"[Git] Updated GIT_ADDRESS for authenticated access: ${GIT_ADDRESS}\"\r\n else\r\n echo \"[Git] Using anonymous Git access.\"\r\n fi\r\n\r\n # Check if the 'www' directory exists, if not create it\r\n if [ ! -d \/mnt\/server\/www ]; then\r\n echo \"[Git] Creating \/mnt\/server\/www directory.\"\r\n mkdir -p \/mnt\/server\/www\r\n else\r\n rm -R \/mnt\/server\/www && mkdir -p \/mnt\/server\/www\r\n fi\r\n\r\n cd \/mnt\/server\/www || { echo \"[Git] Error: Could not access \/mnt\/server\/www directory.\"; exit 1; }\r\n\r\n if [ \"$(ls -A \/mnt\/server\/www)\" ]; then\r\n echo \"[Git] \/mnt\/server\/www directory is not empty.\"\r\n \r\n # Check if .git directory exists in 'www'\r\n if [ -d .git ]; then\r\n echo \"[Git] .git directory exists in 'www'.\"\r\n\r\n # Check if .git\/config exists in 'www'\r\n if [ -f .git\/config ]; then\r\n echo \"[Git] Loading repository info from git config in 'www'.\"\r\n ORIGIN=$(git config --get remote.origin.url)\r\n else\r\n echo \"[Git] Error: .git\/config not found in 'www'. The directory may contain files, but it's not a valid Git repository.\"\r\n exit 10\r\n fi\r\n else\r\n echo \"[Git] Error: Directory contains files but no Git repository found in 'www'.\"\r\n exit 11\r\n fi\r\n\r\n # Check if origin matches the provided GIT_ADDRESS\r\n if [ \"${ORIGIN}\" == \"${GIT_ADDRESS}\" ]; then\r\n echo \"[Git] Repository origin matches. Pulling latest changes from ${GIT_ADDRESS} in 'www'.\"\r\n git pull || { echo \"[Git] Error: git pull failed for 'www'.\"; exit 12; }\r\n else\r\n echo \"[Git] Error: Repository origin does not match the provided GIT_ADDRESS in 'www'.\"\r\n exit 13\r\n fi\r\n else\r\n # The directory is empty, clone the repository\r\n echo \"[Git] \/mnt\/server\/www directory is empty. Cloning ${GIT_ADDRESS} into \/mnt\/server\/www.\"\r\n git clone ${GIT_ADDRESS} . > \/dev\/null 2>&1 && echo \"[Git] Repository cloned successfully.\" || { echo \"[Git] Error: git clone failed for 'www'.\"; exit 14; }\r\n fi\r\nfi\r\n\r\n# Check if WordPress should be installed\r\nif [ \"${WORDPRESS}\" == \"true\" ] || [ \"${WORDPRESS}\" == \"1\" ]; then\r\n echo \"[SETUP] Install WordPress\"\r\n cd \/mnt\/server\/www\r\n wget -q http:\/\/wordpress.org\/latest.tar.gz > \/dev\/null 2>&1 || { echo \"[SETUP] Error: Downloading WordPress failed.\"; exit 16; }\r\n tar xzf latest.tar.gz >\/dev\/null 2>&1\r\n mv wordpress\/* .\r\n rm -rf wordpress latest.tar.gz\r\n echo \"[SETUP] WordPress installed - http:\/\/ip:port\/wp-admin\"\r\n elif [ \"${GIT_STATUS}\" == \"0\" ] || [ \"${GIT_STATUS}\" == \"false\" ]; then\r\n # Create a simple PHP info page if WordPress is not installed\r\n echo \"<?php phpinfo(); ?>\" > \"www\/index.php\"\r\nfi\r\n\r\necho -e \"[DONE] Everything has been installed successfully\"\r\necho -e \"[INFO] You can now start the nginx web server\"",
28+
"script": "#!\/bin\/bash\r\n\r\n# [SETUP] Install necessary packages, including git\r\necho -e \"[SETUP] Install packages\"\r\napt-get update -qq > \/dev\/null 2>&1 && apt-get install -qq > \/dev\/null 2>&1 -y git wget perl perl-doc fcgiwrap\r\n\r\n# Change to server directory\r\ncd \/mnt\/server\r\n\r\n# [SETUP] Create necessary folders\r\necho -e \"[SETUP] Create folders\"\r\nmkdir -p logs tmp www\r\n\r\n# Clone the default repository into a temporary directory\r\necho \"[Git] Cloning default repository 'https:\/\/github.com\/Ym0T\/pterodactyl-nginx-egg' into temporary directory.\"\r\ngit clone https:\/\/github.com\/Ym0T\/pterodactyl-nginx-egg \/mnt\/server\/gtemp > \/dev\/null 2>&1 && echo \"[Git] Repository cloned successfully.\" || { echo \"[Git] Error: Default repository clone failed.\"; exit 21; }\r\n\r\n# Copy the www folder and files from the temporary repository to the target directory\r\necho \"[Git] Copying folder and files from default repository.\"\r\ncp -r \/mnt\/server\/gtemp\/nginx \/mnt\/server || { echo \"[Git] Error: Copying 'nginx' folder failed.\"; exit 22; }\r\ncp -r \/mnt\/server\/gtemp\/php \/mnt\/server || { echo \"[Git] Error: Copying 'php' folder failed.\"; exit 22; }\r\ncp \/mnt\/server\/gtemp\/nginx.sh \/mnt\/server || { echo \"[Git] Error: Copying 'nginx.sh' file failed.\"; exit 22; }\r\ncp \/mnt\/server\/gtemp\/pull-git.sh \/mnt\/server || { echo \"[Git] Error: Copying 'pull-git.sh' file failed.\"; exit 22; }\r\nchmod +x \/mnt\/server\/nginx.sh && chmod +x \/mnt\/server\/pull-git.sh\r\n\r\n# Remove the temporary cloned repository\r\nrm -rf \/mnt\/server\/gtemp\r\n\r\n# Check if GIT_ADDRESS is set\r\nif [ -z \"${GIT_ADDRESS}\" ]; then\r\n echo \"[Git] Info: GIT_ADDRESS is not set.\"\r\n echo \"[Git] Git operations are disabled. Skipping Git actions.\"\r\nelse\r\n # Add .git suffix to GIT_ADDRESS if it's not present\r\n if [[ ${GIT_ADDRESS} != *.git ]]; then\r\n GIT_ADDRESS=\"${GIT_ADDRESS}.git\"\r\n echo \"[Git] Added .git suffix to GIT_ADDRESS: ${GIT_ADDRESS}\"\r\n fi\r\n\r\n # If username and access token are provided, use authenticated access\r\n if [ -n \"${USERNAME}\" ] && [ -n \"${ACCESS_TOKEN}\" ]; then\r\n echo \"[Git] Using authenticated Git access.\"\r\n \r\n # Extract the domain and the rest of the URL, ensuring the correct format\r\n GIT_DOMAIN=$(echo \"${GIT_ADDRESS}\" | cut -d\/ -f3)\r\n GIT_REPO=$(echo \"${GIT_ADDRESS}\" | cut -d\/ -f4-) # Rest of the URL after the domain\r\n \r\n # Construct the authenticated Git URL\r\n GIT_ADDRESS=\"https:\/\/${USERNAME}:${ACCESS_TOKEN}@${GIT_DOMAIN}\/${GIT_REPO}\"\r\n \r\n echo \"[Git] Updated GIT_ADDRESS for authenticated access: ${GIT_ADDRESS}\"\r\n else\r\n echo \"[Git] Using anonymous Git access.\"\r\n fi\r\n\r\n # Check if the 'www' directory exists, if not create it\r\n if [ ! -d \/mnt\/server\/www ]; then\r\n echo \"[Git] Creating \/mnt\/server\/www directory.\"\r\n mkdir -p \/mnt\/server\/www\r\n else\r\n rm -R \/mnt\/server\/www && mkdir -p \/mnt\/server\/www\r\n fi\r\n\r\n cd \/mnt\/server\/www || { echo \"[Git] Error: Could not access \/mnt\/server\/www directory.\"; exit 1; }\r\n\r\n if [ \"$(ls -A \/mnt\/server\/www)\" ]; then\r\n echo \"[Git] \/mnt\/server\/www directory is not empty.\"\r\n \r\n # Check if .git directory exists in 'www'\r\n if [ -d .git ]; then\r\n echo \"[Git] .git directory exists in 'www'.\"\r\n\r\n # Check if .git\/config exists in 'www'\r\n if [ -f .git\/config ]; then\r\n echo \"[Git] Loading repository info from git config in 'www'.\"\r\n ORIGIN=$(git config --get remote.origin.url)\r\n else\r\n echo \"[Git] Error: .git\/config not found in 'www'. The directory may contain files, but it's not a valid Git repository.\"\r\n exit 10\r\n fi\r\n else\r\n echo \"[Git] Error: Directory contains files but no Git repository found in 'www'.\"\r\n exit 11\r\n fi\r\n\r\n # Check if origin matches the provided GIT_ADDRESS\r\n if [ \"${ORIGIN}\" == \"${GIT_ADDRESS}\" ]; then\r\n echo \"[Git] Repository origin matches. Pulling latest changes from ${GIT_ADDRESS} in 'www'.\"\r\n git pull || { echo \"[Git] Error: git pull failed for 'www'.\"; exit 12; }\r\n else\r\n echo \"[Git] Error: Repository origin does not match the provided GIT_ADDRESS in 'www'.\"\r\n exit 13\r\n fi\r\n else\r\n # The directory is empty, clone the repository\r\n echo \"[Git] \/mnt\/server\/www directory is empty. Cloning ${GIT_ADDRESS} into \/mnt\/server\/www.\"\r\n git clone ${GIT_ADDRESS} . > \/dev\/null 2>&1 && echo \"[Git] Repository cloned successfully.\" || { echo \"[Git] Error: git clone failed for 'www'.\"; exit 14; }\r\n fi\r\nfi\r\n\r\n# Check if WordPress should be installed\r\nif [ \"${WORDPRESS}\" == \"true\" ] || [ \"${WORDPRESS}\" == \"1\" ]; then\r\n echo \"[SETUP] Install WordPress\"\r\n cd \/mnt\/server\/www\r\n wget -q http:\/\/wordpress.org\/latest.tar.gz > \/dev\/null 2>&1 || { echo \"[SETUP] Error: Downloading WordPress failed.\"; exit 16; }\r\n tar xzf latest.tar.gz >\/dev\/null 2>&1\r\n mv wordpress\/* .\r\n rm -rf wordpress latest.tar.gz\r\n echo \"[SETUP] WordPress installed - http:\/\/ip:port\/wp-admin\"\r\n elif [ -z \"${GIT_ADDRESS}\" ]; then\r\n # Create a simple PHP info page if WordPress is not installed\r\n echo \"<?php phpinfo(); ?>\" > \"www\/index.php\"\r\nfi\r\n\r\necho -e \"[DONE] Everything has been installed successfully\"\r\necho -e \"[INFO] You can now start the nginx web server\"",
2929
"container": "debian:bookworm-slim",
3030
"entrypoint": "bash"
3131
}

0 commit comments

Comments
 (0)