1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jirafeau_ynh.git synced 2024-09-03 19:35:53 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2022-07-28 23:32:49 +02:00
parent 2ad16181db
commit 1373072c77
10 changed files with 186 additions and 193 deletions

View file

@ -2,9 +2,9 @@
; Manifest
domain="domain.tld"
path="/path"
is_public=1
admin_user="package_checker"
upload_password="supersecretpassword"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=1
@ -17,6 +17,7 @@
upgrade=1 from_commit=0615fbcfa5b163812657b2f291026bf24b5e0667
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
@ -24,4 +25,3 @@ Notification=none
;;; Upgrade options
; commit=0615fbcfa5b163812657b2f291026bf24b5e0667
name=Merge pull request #92

View file

@ -27,7 +27,7 @@
/* URL of installation, with traling slash (eg. »https://exmaple.com/jirafeau/«)
*/
$cfg['web_root'] = 'https://' . '__DOMAIN__' . '__PATH__' . '/';
$cfg['web_root'] = 'https://' . '__DOMAIN__' . '__JIRAFEAU_PATH__' . '/';
/* Path to data directory, with trailing slash (eg. »/var/www/data/var_314159265358979323846264«
*/

View file

@ -2,13 +2,14 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/ ;
alias __FINALPATH__/;
index index.php;
client_max_body_size 10G;
client_body_timeout 30m;
proxy_read_timeout 30m;
index index.php;
try_files $uri $uri/ index.php;
location ~ ^__PATH__/lib/functions.js.php {
@ -30,6 +31,7 @@ location __PATH__/ {
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;

View file

@ -6,7 +6,7 @@
"en": "Upload a file in a simple way and give a unique link to it",
"fr": "Hébergez simplement un fichier et partagez-le avec un lien unique"
},
"version": "4.4.0~ynh1",
"version": "4.4.0~ynh2",
"url": "https://gitlab.com/mojo42/Jirafeau",
"upstream": {
"license": "AGPL-3.0-only",
@ -28,7 +28,7 @@
"php7.3-fpm"
],
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain"
@ -39,6 +39,11 @@
"example": "/jirafeau",
"default": "/jirafeau"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "admin_user",
"type": "user",
@ -55,11 +60,6 @@
"en": "Set the password granting upload permissions (leave empty to allow anybody to upload). Please avoid using ' (quotes) in the password as it will fail the app...",
"fr": "Définissez le mot de passe permettant l'accès à l'envoi de fichiers (laissez vide pour autoriser tout le monde). Veuillez éviter d'utiliser ' (guillemets) dans le mot de passe car cela fera échouer l'application..."
}
},
{
"name": "is_public",
"type": "boolean",
"default": true
}
]
}

View file

@ -6,6 +6,7 @@
YNH_PHP_VERSION="7.3"
# dependencies used by the app
pkg_dependencies=""
#=================================================

View file

@ -1,9 +1,12 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -32,31 +35,31 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP OF THE MAIN DIR OF THE APP
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP OF THE DATA DIR
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP OF THE NGINX CONFIGURATION
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP OF THE PHP-FPM CONFIGURATION
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE CRON FILE
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
@ -65,4 +68,4 @@ ynh_backup --src_path="/etc/cron.d/$app"
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for Jirafeau. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,7 +1,7 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -22,10 +22,9 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin_user=$YNH_APP_ARG_ADMIN_USER
upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC
phpversion=$YNH_PHP_VERSION
app=$YNH_APP_INSTANCE_NAME
@ -35,7 +34,7 @@ app=$YNH_APP_INSTANCE_NAME
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -49,7 +48,10 @@ 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=admin --value=$admin_user
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
@ -65,8 +67,6 @@ ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -76,10 +76,21 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
# Remove the install.php
ynh_secure_remove --file=$final_path/install.php
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -88,34 +99,8 @@ ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# SPECIFIC SETUP
#=================================================
# SET AND SAVE THE UPLOAD PASSWORD
#=================================================
jirafeauconfigfile="$final_path/lib/config.local.php"
cp "../conf/config.local.php" "$jirafeauconfigfile"
# Set and save upload password, allowing an empty one
if [ -z "$upload_password" ]
then
ynh_replace_string --match_string="__UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile"
ynh_app_setting_set --app=$app --key=upload_password --value=""
else
ynh_replace_special_string --match_string="__UPLOAD_PASSWORD__" --replace_string="'$upload_password'" --target_file="$jirafeauconfigfile"
ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password"
fi
#=================================================
# CREATE DATA DIRECTORY
#=================================================
@ -131,28 +116,21 @@ chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# CONFIGURE JIRAFEAU
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring Jirafeau..." --weight=2
ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile"
if [ "$path_url" = "/" ]
then
ynh_replace_string --match_string="__PATH__" --replace_string="" --target_file="$jirafeauconfigfile"
jirafeau_path=""
else
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile"
jirafeau_path="$path_url"
fi
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$jirafeauconfigfile"
ynh_replace_string --match_string="__ADMIN_USER__" --replace_string="$admin_user" --target_file="$jirafeauconfigfile"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$jirafeauconfigfile"
ynh_add_config --template="../conf/config.local.php" --destination="$final_path/lib/config.local.php"
# Remove the install.php
ynh_secure_remove --file=$final_path/install.php
chmod 400 "$jirafeauconfigfile"
chown $app:$app "$jirafeauconfigfile"
chmod 400 "$final_path/lib/config.local.php"
chown $app:$app "$final_path/lib/config.local.php"
#=================================================
# SET THE CRON FILE
@ -160,9 +138,12 @@ chown $app:$app "$jirafeauconfigfile"
ynh_script_progression --message="Configuring the cron file..." --weight=2
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP SSOWAT
#=================================================

View file

@ -1,7 +1,7 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -23,7 +23,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE THE MAIN DIR OF THE APP
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2
@ -42,7 +42,7 @@ then
fi
#=================================================
# REMOVE THE NGINX CONFIGURATION
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2
@ -50,7 +50,7 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
ynh_remove_nginx_config
#=================================================
# REMOVE THE PHP-FPM CONFIGURATION
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
@ -66,14 +66,17 @@ ynh_script_progression --message="Removing dependencies..." --weight=3
ynh_remove_app_dependencies
#=================================================
# REMOVE THE CRON FILE
# SPECIFIC REMOVE
#=================================================
ynh_script_progression --message="Removing the cron file..." --weight=1
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# GENERIC FINALISATION
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================

View file

@ -1,9 +1,12 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -17,7 +20,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=2
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
@ -36,14 +39,7 @@ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORE STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -55,7 +51,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring $app main directory..." --weight=2
ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
@ -92,16 +88,23 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE THE CRON FILE
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the cron file..." --weight=1
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALISATION
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================

View file

@ -1,7 +1,7 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -28,23 +28,26 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Jirafeau before upgrading (may take a while)..." --weight=3
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -62,6 +65,15 @@ if [ -z "$datadir" ]; then
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi
ynh_permission_update --permission="main" --add="visitors"
if [ $is_public -eq 0 ]
then
domain_regex=$(echo "$domain" | sed 's@-@.@g')
[ "$path_url" = "/" ] && path_url=""
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -70,8 +82,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -92,12 +102,11 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
ynh_script_progression --message="Upgrading dependencies..." --weight=3
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
@ -108,12 +117,15 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
ynh_add_fpm_config
#=================================================
# UPGRADE DEPENDENCIES
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=3
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
ynh_install_app_dependencies $pkg_dependencies
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SET THE CRON FILE
#=================================================
@ -124,19 +136,7 @@ chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=2
ynh_permission_update --permission="main" --add="visitors"
if [ $is_public -eq 0 ]
then
domain_regex=$(echo "$domain" | sed 's@-@.@g')
[ "$path_url" = "/" ] && path_url=""
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
fi
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================