diff --git a/.dev/vagrant/.env.vagrant b/.dev/vagrant/.env.vagrant new file mode 100644 index 000000000..2427ec04e --- /dev/null +++ b/.dev/vagrant/.env.vagrant @@ -0,0 +1,39 @@ +APP_ENV=develop +APP_DEBUG=true +APP_KEY=SomeRandomString3232RandomString +APP_THEME=pterodactyl +APP_TIMEZONE=UTC +APP_CLEAR_TASKLOG=720 +APP_DELETE_MINUTES=10 +APP_URL=http://192.168.50.2/ + +DB_HOST=localhost +DB_PORT=3306 +DB_DATABASE=panel +DB_USERNAME=pterodactyl +DB_PASSWORD=pterodactyl + +CACHE_DRIVER=memcached +MEMCACHED_HOST=127.0.0.1 +SESSION_DRIVER=database + +MAIL_DRIVER=smtp +MAIL_HOST=127.0.0.1 +MAIL_PORT=1025 +MAIL_USERNAME= +MAIL_PASSWORD= +MAIL_ENCRYPTION= +MAIL_FROM=support@pterodactyl.io + +API_PREFIX=api +API_VERSION=v1 +API_DEBUG=true + +QUEUE_DRIVER=database +QUEUE_HIGH=high +QUEUE_STANDARD=standard +QUEUE_LOW=low + +SQS_KEY=aws-public +SQS_SECRET=aws-secret +SQS_QUEUE_PREFIX=aws-queue-prefix diff --git a/.dev/vagrant/mailhog.service b/.dev/vagrant/mailhog.service new file mode 100644 index 000000000..01334183d --- /dev/null +++ b/.dev/vagrant/mailhog.service @@ -0,0 +1,13 @@ +[Unit] +Description=Mailhog + +[Service] +# On some systems the user and group might be different. +# Some systems use `apache` as the user and group. +User=www-data +Group=www-data +Restart=on-failure +ExecStart=/usr/bin/mailhog + +[Install] +WantedBy=multi-user.target diff --git a/.dev/vagrant/provision.sh b/.dev/vagrant/provision.sh new file mode 100644 index 000000000..fb6c9d1a6 --- /dev/null +++ b/.dev/vagrant/provision.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +echo "Provisioning development environment for Pterodactyl Panel." + +apt-get install -y software-properties-common > /dev/null + +echo "Add the ondrej/php ppa repository" +add-apt-repository -y ppa:ondrej/php > /dev/null +echo "Add the mariadb repository" +curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash > /dev/null + +apt-get update > /dev/null + +echo "Install the dependencies" +export DEBIAN_FRONTEND=noninteractive +# set the mariadb root password because mariadb asks for it +debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password password pterodactyl' +debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password_again password pterodactyl' +# actually install +apt-get install -y php7.1 php7.1-cli php7.1-gd php7.1-mysql php7.1-pdo php7.1-mbstring php7.1-tokenizer php7.1-bcmath php7.1-xml php7.1-fpm php7.1-memcached php7.1-curl php7.1-zip mariadb-server nginx curl tar unzip git memcached > /dev/null + +echo "Install composer" +curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +echo "Install and run mailhog" +curl -sL -o /usr/bin/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64 +chmod +x /usr/bin/mailhog +cp /var/www/html/pterodactyl/.dev/vagrant/mailhog.service /etc/systemd/system/ +systemctl enable mailhog.service +systemctl start mailhog + +echo "Configure nginx" +cp /var/www/html/pterodactyl/.dev/vagrant/pterodactyl.conf /etc/nginx/sites-available/ +rm /etc/nginx/sites-available/default +ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/pterodactyl.conf +service nginx restart + +echo "Setup database" +mysql -u root -ppterodactyl << SQL +CREATE USER 'pterodactyl'@'localhost' IDENTIFIED BY 'pterodactyl'; +CREATE DATABASE panel; +GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'localhost'; +FLUSH PRIVILEGES; +SQL + +echo "Setup pterodactyl queue worker service" +cp /var/www/html/pterodactyl/.dev/vagrant/pteroq.service /etc/systemd/system/ +systemctl enable pteroq.service + + +echo "Setup panel with base settings" +cp /var/www/html/pterodactyl/.dev/vagrant/.env.vagrant /var/www/html/pterodactyl/.env +cd /var/www/html/pterodactyl +chmod -R 755 storage/* bootstrap/cache +composer install --no-progress +php artisan key:generate --force +php artisan migrate +php artisan db:seed +php artisan pterodactyl:user --firstname Test --lastname Admin --username admin --email testadmin@pterodactyl.io --password Ptero123 --admin 1 +php artisan pterodactyl:user --firstname Test --lastname User --username user --email testuser@pterodactyl.io --password Ptero123 --admin 0 + +echo "Add queue cronjob and start queue worker" +(crontab -l 2>/dev/null; echo "* * * * * php /var/www/html/pterodactyl/artisan schedule:run >> /dev/null 2>&1") | crontab - +systemctl start pteroq + +echo " ----------------" +echo "Provisioning is completed." +echo "The panel should be available at http://localhost:50080/" +echo "You may use the default admin user to login: admin/Ptero123" +echo "A normal user has also been created: user/Ptero123" +echo "MailHog is available at http://localhost:58025/" diff --git a/.dev/vagrant/pterodactyl.conf b/.dev/vagrant/pterodactyl.conf new file mode 100644 index 000000000..d83849a97 --- /dev/null +++ b/.dev/vagrant/pterodactyl.conf @@ -0,0 +1,51 @@ +# If using Ubuntu this file should be placed in: +# /etc/nginx/sites-available/ +# +# If using CentOS this file should be placed in: +# /etc/nginx/conf.d/ +# +server { + listen 80; + server_name 0.0.0.0; + + root /var/www/html/pterodactyl/public; + index index.html index.htm index.php; + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + access_log off; + error_log /var/log/nginx/pterodactyl.app-error.log error; + + # allow larger file uploads and longer script runtimes + client_max_body_size 100m; + client_body_timeout 120s; + + sendfile off; + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + # the fastcgi_pass path needs to be changed accordingly when using CentOS + fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M"; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTP_PROXY ""; + fastcgi_intercept_errors off; + fastcgi_buffer_size 16k; + fastcgi_buffers 4 16k; + fastcgi_connect_timeout 300; + fastcgi_send_timeout 300; + fastcgi_read_timeout 300; + } + + location ~ /\.ht { + deny all; + } +} diff --git a/.dev/vagrant/pteroq.service b/.dev/vagrant/pteroq.service new file mode 100644 index 000000000..7828ee91b --- /dev/null +++ b/.dev/vagrant/pteroq.service @@ -0,0 +1,20 @@ +# Pterodactyl Queue Worker File +# ---------------------------------- +# File should be placed in: +# /etc/systemd/system +# +# nano /etc/systemd/system/pteroq.service + +[Unit] +Description=Pterodactyl Queue Worker + +[Service] +# On some systems the user and group might be different. +# Some systems use `apache` as the user and group. +User=www-data +Group=www-data +Restart=on-failure +ExecStart=/usr/bin/php /var/www/html/pterodactyl/artisan queue:work database --queue=high,standard,low --sleep=3 --tries=3 + +[Install] +WantedBy=multi-user.target diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 000000000..ed84555a5 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,17 @@ +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/xenial64" + + config.vm.synced_folder "./", "/var/www/html/pterodactyl", + owner: "www-data", group: "www-data" + + #config.vm.provision :file, source: ".dev/vagrant/pterdactyl.conf", destination: "/etc/nginx/sites-available/pterodactyl.conf" + #config.vm.provision :file, source: ".dev/vagrant/pteroq.service", destination: "/etc/systemd/system/pteroq.service" + #config.vm.provision :file, source: ".dev/vagrant/mailhog.service", destination: "/etc/systemd/system/mailhog.service" + #config.vm.provision :file, source: ".dev/vagrant/.env", destination: "/var/www/html/pterodactyl/.env" + config.vm.provision :shell, path: ".dev/vagrant/provision.sh" + + config.vm.network :private_network, ip: "192.168.50.2" + config.vm.network :forwarded_port, guest: 80, host: 50080 + config.vm.network :forwarded_port, guest: 8025, host: 58025 + +end