More fixes

This commit is contained in:
ericgaspar 2021-03-06 09:08:39 +01:00
parent fb8772892e
commit 4be58c54bb
No known key found for this signature in database
GPG key ID: 574F281483054D44
15 changed files with 318 additions and 190 deletions

View file

@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
## Overview ## Overview
Pterodactyl is the open-source game server management panel built with PHP7, Nodejs, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to administrators and users. Stop wasting time fiddling with other systems — make game servers a first class citizen on your platform. Pterodactyl is the open-source game server management panel built with PHP7, Nodejs, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to administrators and users. Stop wasting time fiddling with other systems — make game servers a first class citizen on your platform.
**Shipped version:** 0.7.17 **Shipped version:** 1.2.2
## Screenshots ## Screenshots
@ -76,8 +76,8 @@ As Pterodactyl do not support LDAP for now [#594](https://github.com/pterodactyl
--- ---
Developers info ## Developers info
----------------
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/pterodactyl_ynh/tree/testing). Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/pterodactyl_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.

View file

@ -1,7 +1,7 @@
# Pterodactyl Panel pour Yunohost # Pterodactyl Panel pour Yunohost
![](https://ci-apps.yunohost.org/ci/badges/pterodactyl.maintain.svg) ![](https://ci-apps.yunohost.org/ci/badges/pterodactyl.status.svg) [![Integration level](https://dash.yunohost.org/integration/pterodactyl.svg)](https://dash.yunohost.org/appci/app/pterodactyl) ![](https://ci-apps.yunohost.org/ci/badges/pterodactyl.maintain.svg) ![](https://ci-apps.yunohost.org/ci/badges/pterodactyl.status.svg) [![Integration level](https://dash.yunohost.org/integration/pterodactyl.svg)](https://dash.yunohost.org/appci/app/pterodactyl)
[![Install Pterodactyl with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=pterodactyl) [![Install Pterodactyl with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=pterodactyl)
*[Read this README in English.](./README.md)* *[Read this README in English.](./README.md)*
@ -9,7 +9,7 @@
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
**Version de Pterodactyl** : 0.7.17 **Version de Pterodactyl** : 1.2.2
## Screenshots ## Screenshots
@ -34,12 +34,12 @@ Après l'installation:
3. Créez un node 3. Créez un node
4. Copiez la configuration (core.json) pour le node créé en 3. 4. Copiez la configuration (core.json) pour le node créé en 3.
5. Modifiez core.json 5. Modifiez core.json
```$ sudo nano /srv/daemon/config/core.json``` `$ sudo nano /srv/daemon/config/core.json`
6. Modifiez les chemins des certificats SSL Yunohost. 6. Modifiez les chemins des certificats SSL Yunohost.
```$ /etc/yunohost/certs/yourDomain.tld/crt.pem = SSL Certificate `$ /etc/yunohost/certs/yourDomain.tld/crt.pem = SSL Certificate
$ /etc/yunohost/certs/yourDomain.tld/key.pem = SSL Key``` $ /etc/yunohost/certs/yourDomain.tld/key.pem = SSL Key`
7. Démarrez le service Wings 7. Démarrez le service Wings
```$ sudo systemctl start wings``` `$ sudo systemctl start wings`
### Mettre à jour: ### Mettre à jour:
@ -57,7 +57,7 @@ Pterodactyl ne supporte pas le LDAP pour l'instant [#594](https://github.com/pte
#### Architectures supportées #### Architectures supportées
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pterodactyl%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pterodactyl/) * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pterodactyl%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pterodactyl/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pterodactyl%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pterodactyl/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pterodactyl%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pterodactyl/)
## Limitations ## Limitations
@ -74,8 +74,8 @@ Pterodactyl ne supporte pas le LDAP pour l'instant [#594](https://github.com/pte
--- ---
Developers info ## Developers info
----------------
Merci de faire vos PR sur la branche [testing](https://github.com/YunoHost-Apps/pterodactyl_ynh/tree/testing). Merci de faire vos PR sur la branche [testing](https://github.com/YunoHost-Apps/pterodactyl_ynh/tree/testing).
Pour essayer la branche testing, effectuez ces commandes : Pour essayer la branche testing, effectuez ces commandes :

View file

@ -1,13 +1,12 @@
# See here for more informations # See here for more informations
# https://github.com/YunoHost/package_check#syntax-check_process-file # https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/pterodactyl" (PATH) path="/pterodactyl" (PATH)
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
language="fr"
password="pass" password="pass"
admin="john" (USER) admin="john" (USER)
port="9980" (PORT) port="9980" (PORT)
@ -26,3 +25,8 @@
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -7,20 +7,20 @@ APP_CLEAR_TASKLOG=720
APP_DELETE_MINUTES=10 APP_DELETE_MINUTES=10
APP_ENVIRONMENT_ONLY=true APP_ENVIRONMENT_ONLY=true
LOG_CHANNEL=daily LOG_CHANNEL=daily
APP_LOCALE=en APP_LOCALE=__LANGUAGE__
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3306 DB_PORT=3306
DB_DATABASE=__DB_NAME__ DB_DATABASE=__DB_NAME__
DB_USERNAME=__DB_USER__ DB_USERNAME=__DB_NAME__
DB_PASSWORD=__DB_PWD__ DB_PASSWORD=__DB_PWD__
HASHIDS_SALT= HASHIDS_SALT=
HASHIDS_LENGTH=8 HASHIDS_LENGTH=8
MAIL_DRIVER=smtp MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io MAIL_HOST=smtp.example.com
MAIL_PORT=2525 MAIL_PORT=25
MAIL_USERNAME= MAIL_USERNAME=
MAIL_PASSWORD= MAIL_PASSWORD=
MAIL_ENCRYPTION=tls MAIL_ENCRYPTION=tls

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/pterodactyl/panel/releases/download/v0.7.17/panel.tar.gz SOURCE_URL=https://github.com/pterodactyl/panel/releases/download/v1.2.2/panel.tar.gz
SOURCE_SUM=b3e37e5cf34b3fbcec73cab8947300dd55f1ba289a83501c76f198dd4e6c3750 SOURCE_SUM=e03a532623a62adf36c4b2769a90ed0a38954af1645d453bee0e470651e9aaf2
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

1
conf/cron Normal file
View file

@ -0,0 +1 @@
* * * * * php__PHPVERSION__ __FINALPATH__/artisan schedule:run >> /dev/null 2>&1

View file

@ -1,4 +1,4 @@
root /var/www/pterodactyl/public/; root __FINALPATH__/public/;
index index.php; index index.php;
access_log /var/log/nginx/pterodactyl.app-access.log; access_log /var/log/nginx/pterodactyl.app-access.log;
@ -21,7 +21,7 @@ index index.php;
#add_header X-Frame-Options "ALLOW-FROM __DOMAIN__:8080"; #add_header X-Frame-Options "ALLOW-FROM __DOMAIN__:8080";
#add_header Access-Control-Allow-Origin "__DOMAIN__:8080"; #add_header Access-Control-Allow-Origin "__DOMAIN__:8080";
location __PATH__ { location __PATH__/ {
try_files $uri $uri/ /index.php?$query_string; try_files $uri $uri/ /index.php?$query_string;
# Force https # Force https
if ($scheme = http) { if ($scheme = http) {

View file

@ -3,8 +3,8 @@ Description=Pterodactyl Wings Daemon
After=docker.service After=docker.service
[Service] [Service]
User=root User=__APP__
#Group=some_group #Group__APP__
WorkingDirectory=/srv/daemon WorkingDirectory=/srv/daemon
LimitNOFILE=4096 LimitNOFILE=4096
PIDFile=/var/run/wings/daemon.pid PIDFile=/var/run/wings/daemon.pid

View file

@ -6,7 +6,7 @@
"en": "Gameserver management panel (Minecraft, ARK, Rust,...)", "en": "Gameserver management panel (Minecraft, ARK, Rust,...)",
"fr": "Panel de gestion de serveurs de jeux (Minecraft, ARK, Rust,...)" "fr": "Panel de gestion de serveurs de jeux (Minecraft, ARK, Rust,...)"
}, },
"version": "0.7.17~ynh1", "version": "1.2.2~ynh1",
"url": "https://pterodactyl.io/", "url": "https://pterodactyl.io/",
"license": "MIT", "license": "MIT",
"maintainer": { "maintainer": {
@ -51,6 +51,16 @@
}, },
"example": "johndoe" "example": "johndoe"
}, },
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["fr", "en"],
"default": "fr"
},
{ {
"name": "password", "name": "password",
"type": "password", "type": "password",

View file

@ -6,9 +6,11 @@
YNH_PHP_VERSION=7.3 YNH_PHP_VERSION=7.3
nodejs_version=14
extra_php_dependencies="php${YNH_PHP_VERSION}-igbinary php${YNH_PHP_VERSION}-memcached php${YNH_PHP_VERSION}-msgpack php${YNH_PHP_VERSION}-xdebug php${YNH_PHP_VERSION}-bcmath php7.2-cli php${YNH_PHP_VERSION}-common php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-opcache php${YNH_PHP_VERSION}-readline php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip" extra_php_dependencies="php${YNH_PHP_VERSION}-igbinary php${YNH_PHP_VERSION}-memcached php${YNH_PHP_VERSION}-msgpack php${YNH_PHP_VERSION}-xdebug php${YNH_PHP_VERSION}-bcmath php7.2-cli php${YNH_PHP_VERSION}-common php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-opcache php${YNH_PHP_VERSION}-readline php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip"
pkg_dependencies="libargon2-1 libsodium23 libzip5 memcached" pkg_dependencies="libargon2-1 libsodium23 libzip5 memcached apt-transport-https ca-certificates curl gnupg2 software-properties-common zip unzip tar make gcc g++ python curl gnupg"
#================================================= #=================================================

View file

@ -38,11 +38,6 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that
### creates and fill the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
@ -61,43 +56,25 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/systemd/system/wings.service"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/cron.d/$app" ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup --src_path="/etc/$app/"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Backing up the MySQL database..." ynh_print_info --message="Backing up the MySQL database..."
### (However, things like MySQL dumps *do* take some time to run, though the
### copy of the generated dump to the archive still happens later)
ynh_mysql_dump_db --database="$db_name" > db.sql ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================

View file

@ -28,6 +28,7 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
language=$YNH_APP_ARG_LANGUAGE
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
email=$(ynh_user_get_info --username=$admin --key=mail) email=$(ynh_user_get_info --username=$admin --key=mail)
@ -37,7 +38,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --time --weight=1 ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -52,6 +53,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=language --value=$language
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
@ -67,6 +69,9 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_script_progression --message="Installing dependencies..." --weight=1
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
@ -91,7 +96,7 @@ ynh_setup_source --dest_dir="$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
@ -99,30 +104,26 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --time --weight=1 ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user # Create a system user
ynh_system_user_create --username=$app ynh_system_user_create --username=$app
#================================================= #=================================================
# SPECIFIC SETUP # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# setup application config # Create a dedicated PHP-FPM config
cp -a ../conf/.env $final_path/.env ynh_add_fpm_config
cp -a ../conf/wings.service /etc/systemd/system/wings.service
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
#ynh_replace_string "random_key" "$random_key" "$final_path/.env" ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
ynh_replace_string "__DB_USER__" "$db_name" "$final_path/.env"
ynh_replace_string "__DB_PASS__" "$db_pwd" "$final_path/.env" ynh_add_config --template="../conf/wings.service" --destination="/etc/systemd/system/wings.service"
ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/.env"
#ynh_replace_string "yunomail" "$email" "$final_path/.env"
#ynh_replace_string "yunodomain" "$domain" "$final_path/.env"
#============================================== #==============================================
# INSTALL Composer # INSTALL Composer
@ -136,26 +137,29 @@ ynh_install_composer
pushd $final_path pushd $final_path
chmod -R 755 storage/* bootstrap/cache chmod -R 755 storage/* bootstrap/cache
composer install --no-progress #composer install --no-progress
composer install --no-dev --optimize-autoloader
php artisan key:generate --force php artisan key:generate --force
php artisan migrate --force php artisan p:environment:setup
php artisan db:seed --force php artisan p:environment:database
php artisan p:user:make --name-first $admin --name-last $admin --username $admin --email $email --password $password --admin 1
php artisan p:environment:setup --author=$email --url=https://$domain --timezone=America/New_York --cache=redis --session=database --queue=redis --disable-settings-ui --redis-host=127.0.0.1 --redis-pass= --redis-port=6379
php artisan migrate --seed --force php artisan migrate --seed --force
#php artisan migrate --force
#php artisan db:seed --force
php artisan p:user:make --name-first $admin --name-last $admin --username $admin --email $email --password $password --admin 1
#php artisan p:environment:setup --author=$email --url=https://$domain --timezone=America/New_York --cache=redis --session=database --queue=redis --disable-settings-ui --redis-host=127.0.0.1 --redis-pass= --redis-port=6379
#php artisan migrate --seed --force
popd popd
#============================================== #==============================================
# Install Docker # Install Docker
#============================================== #==============================================
ynh_package_install apt-transport-https ca-certificates curl gnupg2 software-properties-common zip unzip tar make gcc g++ python curl gnupg
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
ynh_package_update ynh_package_update
ynh_package_install docker-ce ynh_package_install docker-ce
cp -a ../conf/daemon.json /etc/docker/daemon.json cp -a ../conf/daemon.json /etc/docker/daemon.json
systemctl enable docker systemctl enable docker --quiet
systemctl start docker systemctl start docker
#============================================== #==============================================
@ -165,8 +169,6 @@ systemctl start docker
mkdir -p /srv/daemon /srv/daemon-data mkdir -p /srv/daemon /srv/daemon-data
pushd /srv/daemon pushd /srv/daemon
ynh_install_nodejs --nodejs_version=10
ynh_package_install make gcc g++ ynh_package_install make gcc g++
ynh_setup_source --dest_dir=/srv/daemon --source_id=daemon.src ynh_setup_source --dest_dir=/srv/daemon --source_id=daemon.src
@ -182,25 +184,41 @@ popd
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_add_systemd_config mkdir -p /var/log/$app/
systemctl enable $app.service
systemctl enable wings.service
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
mkdir -p /var/log/pterodactyl/
touch /var/log/$app/$app-prod.log touch /var/log/$app/$app-prod.log
yunohost service add $app --log "/var/log/$app/$app-prod.log"
yunohost service add wings
#============================================== # Create a dedicated systemd config
# Cron ynh_add_systemd_config
#==============================================
crontab -l | { cat; echo "* * * * * php $final_path/artisan schedule:run" ; } | crontab - # Create systemd service for wings
ynh_add_systemd_config --service=wings --template=wings.service
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log"
# Start a systemd service
ynh_systemd_action --service_name=wings --action=start --log_path="/var/log/$app/$app.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
yunohost service add $app --description="Pterodactyl Queue Worker" --log="/var/log/$app/$app-prod.log"
yunohost service add wings --description="Pterodactyl Queue Worker"
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setuping a cron..."
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -209,25 +227,23 @@ crontab -l | { cat; echo "* * * * * php $final_path/artisan schedule:run" ; } |
#================================================= #=================================================
# Set permissions to app files # Set permissions to app files
chown -R www-data:www-data $final_path chown -R $app: $final_path
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --time --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -235,4 +251,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --time --last ynh_script_progression --message="Installation of $app completed" --last

View file

@ -12,100 +12,101 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --time --weight=1
yunohost service remove $app
fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
ynh_remove_systemd_config --service=wings
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status | grep -q $app
then
echo "Remove $app service"
yunohost service remove $app
fi
if yunohost service status wings
then
echo "Remove wings service"
yunohost service remove wings
fi
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_user $db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --time --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --time --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove --file="$final_path"
ynh_secure_remove "/srv/daemon"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1
# Remove the dedicated nginx config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --time --weight=1
# Remove the dedicated php-fpm config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_remove_fpm_config
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port" >&2
yunohost firewall disallow TCP $port 2>&1
fi
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE THE CRON FILE # REMOVE VARIOUS FILES
#================================================= #=================================================
# Remove a cron file # Remove a cron file
ynh_secure_remove "/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
# Remove a directory securely
ynh_secure_remove "/etc/apt/sources.list.d/php.list"
# Remove the log files # Remove the log files
ynh_secure_remove "/var/log/$app/" ynh_secure_remove --file="/var/log/$app/"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete $app ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --time --last

View file

@ -1,52 +1,162 @@
#!/bin/bash #!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper #=================================================
# will be located in the current directory, regarding the last argument. # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Exit on command errors and treat unset variables as an error # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
set -eu source ../settings/scripts/_common.sh
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve old app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # MANAGE SCRIPT FAILURE
path_url=$(ynh_app_setting_get "$app" path_url) #=================================================
# Check domain/path availability ynh_clean_setup () {
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ #### Remove this function if there's nothing to clean before calling the remove script.
|| ynh_die "Path not available: ${domain}${path_url}" true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Restore sources & data #=================================================
src_path="/var/www/${app}" # LOAD SETTINGS
sudo cp -a ./sources "$src_path" #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
# Restore permissions to app files app=$YNH_APP_INSTANCE_NAME
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: "$src_path"
### MySQL (remove if not used) ### domain=$(ynh_app_setting_get --app=$app --key=domain)
# If a MySQL database is used: path_url=$(ynh_app_setting_get --app=$app --key=path)
# # Create and restore the database final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# dbname=$app db_name=$(ynh_app_setting_get --app=$app --key=db_name)
# dbuser=$app db_user=$db_name
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
### MySQL end ###
# Restore NGINX configuration #=================================================
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" # CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
### PHP (remove if not used) ### ynh_webpath_available --domain=$domain --path_url=$path_url \
# If a dedicated php-fpm process is used: || ynh_die --message="Path not available: ${domain}${path_url}"
# # Copy PHP-FPM pool configuration and reload the service test ! -d $final_path \
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" || ynh_die --message="There is already a directory: $final_path "
# sudo service php5-fpm reload
### PHP end ###
# Restart webserver #=================================================
sudo service nginx reload # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R root: $final_path
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --time --weight=1
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_restore_file --origin_path="/etc/cron.d/$app"
ynh_restore_file --origin_path="/etc/$app/"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --time --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --time --last

View file

@ -56,6 +56,13 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -77,7 +84,7 @@ ynh_abort_if_errors
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -153,7 +160,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# Set permissions on app files # Set permissions on app files
chown -R root: $final_path chown -R $app: $final_path
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST