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

Normalization from example_ynh

This commit is contained in:
Maniack Crudelis 2019-02-13 21:13:59 +01:00
parent 3bbd3ddaf3
commit 4e3ea101dc
12 changed files with 124 additions and 101 deletions

View file

@ -1,8 +1,60 @@
# Jirafeau package for YunoHost # Jirafeau for YunoHost
Easy drag&Drop file sharing.
[![Integration level](https://dash.yunohost.org/integration/jirafeau.svg)](https://dash.yunohost.org/appci/app/jirafeau)
[![Install Jirafeau with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=jirafeau) [![Install Jirafeau with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=jirafeau)
* [Jirafeau website](https://gitlab.com/mojo42/Jirafeau) > *This package allow you to install Jirafeau quickly and simply on a YunoHost server.
* [YunoHost website](https://yunohost.org/) If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview
Jirafeau is a web site permitting to upload a file in a simple way and give an unique link to it.
**Shipped version:** 3.4.1
## Screenshots
![](http://i.imgur.com/TPjh48P.png)
## Demo
* [YunoHost demo](https://jirafeau.net/)
## Configuration
## Documentation
* Official documentation:
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jirafeau%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/jirafeau/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jirafeau/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/jirafeau%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/jirafeau/)
## Limitations
## Additional information
## Links
* Report a bug: https://github.com/YunoHost-Apps/jirafeau_ynh/issues
* Jirafeau website: https://gitlab.com/mojo42/Jirafeau
* YunoHost website: https://yunohost.org/
---
Developers info
----------------
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing --debug
or
sudo yunohost app upgrade jirafeau -u https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing --debug
```

View file

@ -1,5 +1,4 @@
;; Test complet ;; Test complet
auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)

View file

@ -27,11 +27,11 @@
/* URL of installation, with traling slash (eg. »https://exmaple.com/jirafeau/«) /* URL of installation, with traling slash (eg. »https://exmaple.com/jirafeau/«)
*/ */
$cfg['web_root'] = 'https://' . 'YNH_DOMAIN' . 'YNH_WWW_PATH' . '/'; $cfg['web_root'] = 'https://' . '__YNH_DOMAIN__' . '__YNH_WWW_PATH__' . '/';
/* Path to data directory, with trailing slash (eg. »/var/www/data/var_314159265358979323846264« /* Path to data directory, with trailing slash (eg. »/var/www/data/var_314159265358979323846264«
*/ */
$cfg['var_root'] = 'YNH_VAR_ROOT' . '/'; $cfg['var_root'] = '__YNH_VAR_ROOT__' . '/';
/* Language - choice between 'auto' or any language located in the /lib/locales/ folder. /* Language - choice between 'auto' or any language located in the /lib/locales/ folder.
* The mode »auto« will cause the script to detect the user's browser information * The mode »auto« will cause the script to detect the user's browser information
@ -74,7 +74,7 @@ $cfg['link_name_length'] = 8;
* $cfg['upload_password'] = array('psw1'); // One password * $cfg['upload_password'] = array('psw1'); // One password
* $cfg['upload_password'] = array('psw1', 'psw2'); // Two passwords * $cfg['upload_password'] = array('psw1', 'psw2'); // Two passwords
*/ */
$cfg['upload_password'] = array(YNH_UPLOAD_PASSWORD); $cfg['upload_password'] = array(__YNH_UPLOAD_PASSWORD__);
/* List of IP allowed to upload a file. /* List of IP allowed to upload a file.
* If the list is empty, then there is no upload restriction based on IP. * If the list is empty, then there is no upload restriction based on IP.
@ -96,7 +96,7 @@ $cfg['admin_password'] = '';
* that the provided user is logged in. * that the provided user is logged in.
* If »admin_password« parameter is set, then the »admin_password« is ignored. * If »admin_password« parameter is set, then the »admin_password« is ignored.
*/ */
$cfg['admin_http_auth_user'] = 'YNH_ADMIN_USER'; $cfg['admin_http_auth_user'] = '__YNH_ADMIN_USER__';
/* Allow user to select different options for file expiration time. /* Allow user to select different options for file expiration time.
* Possible values in array: * Possible values in array:

View file

@ -1,12 +1,18 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
# Path to source
alias __FINALPATH__/ ; alias __FINALPATH__/ ;
# Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
client_max_body_size 10G; client_max_body_size 10G;
client_body_timeout 30m; client_body_timeout 30m;
proxy_read_timeout 30m; proxy_read_timeout 30m;
index index.php; index index.php;
try_files $uri $uri/ index.php; try_files $uri $uri/ index.php;
@ -21,9 +27,11 @@ location __PATH__/ {
fastcgi_read_timeout 30m; fastcgi_read_timeout 30m;
fastcgi_send_timeout 30m; fastcgi_send_timeout 30m;
} }
location ~ ^__PATH__/lib/.*\.php { location ~ ^__PATH__/lib/.*\.php {
deny all; deny all;
} }
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;

View file

@ -9,8 +9,8 @@
"en": "Upload a file in a simple way and give a unique link to it", "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" "fr": "Hébergez simplement un fichier et partagez-le avec un lien unique"
}, },
"url": "https://gitlab.com/mojo42/Jirafeau",
"version": "3.4.1~ynh2", "version": "3.4.1~ynh2",
"url": "https://gitlab.com/mojo42/Jirafeau",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"maintainer": { "maintainer": {
"name": "julien", "name": "julien",

View file

@ -1,16 +1 @@
#!/bin/bash #!/bin/bash
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Delete a file checksum from the app settings
#
# $app should be defined when calling this helper
#
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}

View file

@ -4,12 +4,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -42,7 +37,8 @@ ynh_backup "$final_path"
# The 1 parameter indicates the directory is "big", # The 1 parameter indicates the directory is "big",
# so that it won't be backed up before upgrade # so that it won't be backed up before upgrade
ynh_backup "/home/yunohost.app/$app" 1 # This argument has to be the third one.
ynh_backup "/home/yunohost.app/$app" "/home/yunohost.app/$app" 1
#================================================= #=================================================
# BACKUP OF THE NGINX CONFIGURATION # BACKUP OF THE NGINX CONFIGURATION

View file

@ -25,7 +25,7 @@ app=$YNH_APP_INSTANCE_NAME
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# CHECK PATHS SYNTAX # CHECK PATHS SYNTAX
@ -63,30 +63,23 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file # Change the path in the nginx config file
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
then then
# Make a backup of the original nginx config file if modified # Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path" ynh_backup_if_checksum_is_different "$nginx_conf_path"
# Set global variables for nginx helper # Set global variables for nginx helper
domain="$old_domain" domain="$old_domain"
path_url="$new_path" path_url="$new_path"
# Store path_url setting
ynh_app_setting_set $app path_url "$path_url"
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path"
fi
ynh_store_file_checksum "$nginx_conf_path"
fi fi
# Change the domain for nginx # Change the domain for nginx
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path" ynh_delete_file_checksum "$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#================================================= #=================================================

View file

@ -6,14 +6,15 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE FAILURE OF THE SCRIPT # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée. # Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
@ -28,7 +29,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
final_path=/var/www/$app final_path=/var/www/$app
@ -37,8 +38,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax # Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url) path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register $app $domain $path_url
@ -66,11 +65,6 @@ ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie d
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -98,10 +92,10 @@ cp "../conf/config.local.php" "$jirafeauconfigfile"
# Set and save upload password, allowing an empty one # Set and save upload password, allowing an empty one
if [ -z "$upload_password" ] if [ -z "$upload_password" ]
then then
ynh_replace_string "YNH_UPLOAD_PASSWORD" "" "$jirafeauconfigfile" ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "" "$jirafeauconfigfile"
ynh_app_setting_set $app upload_password "" ynh_app_setting_set $app upload_password ""
else else
ynh_replace_string "YNH_UPLOAD_PASSWORD" "'$upload_password'" "$jirafeauconfigfile" ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "'$upload_password'" "$jirafeauconfigfile"
ynh_app_setting_set $app upload_password "$upload_password" ynh_app_setting_set $app upload_password "$upload_password"
fi fi
@ -110,15 +104,16 @@ fi
#================================================= #=================================================
var_root=/home/yunohost.app/$app var_root=/home/yunohost.app/$app
ynh_replace_string "YNH_DOMAIN" "$domain" "$jirafeauconfigfile"
ynh_replace_string "__YNH_DOMAIN__" "$domain" "$jirafeauconfigfile"
if [ "$path_url" = "/" ] if [ "$path_url" = "/" ]
then then
ynh_replace_string "YNH_WWW_PATH" "" "$jirafeauconfigfile" ynh_replace_string "__YNH_WWW_PATH__" "" "$jirafeauconfigfile"
else else
ynh_replace_string "YNH_WWW_PATH" "$path_url" "$jirafeauconfigfile" ynh_replace_string "__YNH_WWW_PATH__" "$path_url" "$jirafeauconfigfile"
fi fi
ynh_replace_string "YNH_VAR_ROOT" "$var_root" "$jirafeauconfigfile" ynh_replace_string "__YNH_VAR_ROOT__" "$var_root" "$jirafeauconfigfile"
ynh_replace_string "YNH_ADMIN_USER" "$admin_user" "$jirafeauconfigfile" ynh_replace_string "__YNH_ADMIN_USER__" "$admin_user" "$jirafeauconfigfile"
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$jirafeauconfigfile" ynh_store_file_checksum "$jirafeauconfigfile"

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -4,12 +4,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# # Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant
# sudo cp ../settings/scripts/_common.sh ./_common.sh
# sudo chmod a+rx _common.sh
# fi
# source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -42,26 +37,26 @@ test ! -d $final_path \
#================================================= #=================================================
# STANDARD RESTORE STEPS # STANDARD RESTORE STEPS
#================================================= #=================================================
# RESTORE OF THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE OF THE MAIN DIR OF THE APP # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_restore_file "$final_path" ynh_restore_file "$final_path"
#================================================= #=================================================
# RECREATE OF THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create $app
#================================================= #=================================================
# RESTORE OF THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -45,11 +45,14 @@ fi
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_backup_before_upgrade # Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
ynh_restore_upgradebackup # restore it if the upgrade fails # restore it if the upgrade fails
ynh_restore_upgradebackup
} }
ynh_abort_if_errors # Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# CHECK THE PATH # CHECK THE PATH
@ -73,17 +76,12 @@ ynh_setup_source "$final_path"
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
# Create a system user # Create a dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create $app
#================================================= #=================================================
@ -101,17 +99,17 @@ ynh_add_fpm_config
jirafeauconfigfile="$final_path/lib/config.local.php" jirafeauconfigfile="$final_path/lib/config.local.php"
ynh_backup_if_checksum_is_different "$final_path/lib/config.local.php" # Créé un backup du fichier de config si il a été modifié. ynh_backup_if_checksum_is_different "$final_path/lib/config.local.php"
sudo cp "../conf/config.local.php" "$final_path/lib/config.local.php" cp "../conf/config.local.php" "$final_path/lib/config.local.php"
# Set and save upload password, allowing an empty one # Set and save upload password, allowing an empty one
if [ -z "$upload_password" ] if [ -z "$upload_password" ]
then then
ynh_replace_string "YNH_UPLOAD_PASSWORD" "" "$jirafeauconfigfile" ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "" "$jirafeauconfigfile"
ynh_app_setting_set $app upload_password "" ynh_app_setting_set $app upload_password ""
else else
ynh_replace_string "YNH_UPLOAD_PASSWORD" "'$upload_password'" "$jirafeauconfigfile" ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "'$upload_password'" "$jirafeauconfigfile"
ynh_app_setting_set $app upload_password "$upload_password" ynh_app_setting_set $app upload_password "$upload_password"
fi fi
@ -120,17 +118,19 @@ fi
#================================================= #=================================================
var_root=/home/yunohost.app/$app var_root=/home/yunohost.app/$app
ynh_replace_string "YNH_DOMAIN" "$domain" "$jirafeauconfigfile"
ynh_replace_string "__YNH_DOMAIN__" "$domain" "$jirafeauconfigfile"
if [ "$path_url" = "/" ] if [ "$path_url" = "/" ]
then then
ynh_replace_string "YNH_WWW_PATH" "" "$jirafeauconfigfile" ynh_replace_string "__YNH_WWW_PATH__" "" "$jirafeauconfigfile"
else else
ynh_replace_string "YNH_WWW_PATH" "$path_url" "$jirafeauconfigfile" ynh_replace_string "__YNH_WWW_PATH__" "$path_url" "$jirafeauconfigfile"
fi fi
ynh_replace_string "YNH_VAR_ROOT" "$var_root" "$jirafeauconfigfile" ynh_replace_string "__YNH_VAR_ROOT__" "$var_root" "$jirafeauconfigfile"
ynh_replace_string "YNH_ADMIN_USER" "$admin_user" "$jirafeauconfigfile" ynh_replace_string "__YNH_ADMIN_USER__" "$admin_user" "$jirafeauconfigfile"
ynh_store_file_checksum "$jirafeauconfigfile" # Enregistre la somme de contrôle du fichier de config # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$jirafeauconfigfile"
# Remove the install.php # Remove the install.php
rm $final_path/install.php rm $final_path/install.php
@ -141,11 +141,11 @@ rm $final_path/install.php
# SECURING FILES AND DIRECTORIES # SECURING FILES AND DIRECTORIES
#================================================= #=================================================
sudo chown -R root: $final_path chown -R root: $final_path
sudo mkdir -p $var_root/{files,links,async,block} mkdir -p $var_root/{files,links,async,block}
sudo chown -R $app:root $var_root chown -R $app:root $var_root
sudo chmod -R 700 $var_root chmod -R 700 $var_root
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
@ -163,4 +163,4 @@ fi
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
sudo systemctl reload nginx systemctl reload nginx