1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00
This commit is contained in:
Éric Gaspar 2023-03-25 09:31:11 +01:00
parent 1cbe7befb7
commit 41d3f36283
11 changed files with 266 additions and 207 deletions

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lutim/-/archive/0.12.1/lutim-0.12.1.tar.gz
SOURCE_SUM=141f142d47e3a8367e0c292304ddbecfc34b49ae7e561e2c3526000040318973
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,11 +1,11 @@
# Génération des statistiques. Tous les jours, à 5h. # Génération des statistiques. Tous les jours, à 5h.
0 5 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron stats 0 5 * * * __APP__ cd "__INSTALL_DIR__" && $(which carton) exec script/lutim cron stats
# Suppression des adresses IP obsolètes. Tous les jours, à 6h. # Suppression des adresses IP obsolètes. Tous les jours, à 6h.
0 6 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanbdd 0 6 * * * __APP__ cd "__INSTALL_DIR__" && $(which carton) exec script/lutim cron cleanbdd
# Suppression des images dont le délai a expiré. Tous les jours, à 6h. # Suppression des images dont le délai a expiré. Tous les jours, à 6h.
0 6 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanfiles 0 6 * * * __APP__ cd "__INSTALL_DIR__" && $(which carton) exec script/lutim cron cleanfiles
# Vérification de l'occupation du dossier des images. Tous les jours, à 7h. # Vérification de l'occupation du dossier des images. Tous les jours, à 7h.
0 7 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron watch 0 7 * * * __APP__ cd "__INSTALL_DIR__" && $(which carton) exec script/lutim cron watch

View file

@ -6,8 +6,8 @@ After=network.target
Type=forking Type=forking
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
PIDFile=__FINALPATH__/script/hypnotoad.pid PIDFile=__INSTALL_DIR__/script/hypnotoad.pid
ExecStart=/usr/bin/carton exec hypnotoad script/lutim >> /var/log/lutim/production.log 2>&1 ExecStart=/usr/bin/carton exec hypnotoad script/lutim >> /var/log/lutim/production.log 2>&1
ExecStop=/usr/bin/carton exec hypnotoad -s script/lutim >> /var/log/lutim/production.log 2>&1 ExecStop=/usr/bin/carton exec hypnotoad -s script/lutim >> /var/log/lutim/production.log 2>&1
ExecReload=/usr/bin/carton exec hypnotoad script/lutim >> /var/log/lutim/production.log 2>&1 ExecReload=/usr/bin/carton exec hypnotoad script/lutim >> /var/log/lutim/production.log 2>&1

64
manifest.toml Normal file
View file

@ -0,0 +1,64 @@
packaging_format = 2
id = "lutim"
name = "Lutim"
description.en = "Anonymous image hosting service"
description.fr = "Service d'hébergement anonyme d'images"
version = "0.12.1~ynh4"
maintainers = []
[upstream]
license = "AGPL-3.0-only"
website = "https://lut.im"
demo = "https://lut.im/"
userdoc = "https://framagit.org/luc/lutim/wikis/home"
code = "https://framagit.org/fiat-tux/hat-softwares/lutim"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
[integration]
yunohost = ">= 4.3.0"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = false
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
[install.path]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "path"
default = "/lutim"
[install.init_main_permission]
help.en = "If you set Lutim as public, everyone will be able to upload images and share them.<br>But even if not public, everyone can see an image from a link shared with your Lutim."
help.fr = "Si vous définissez Lutim comme public, tout le monde pourra télécharger des images et les partager.<br>Mais même si ce n'est pas public, tout le monde peut voir une image à partir d'un lien partagé avec votre Lutim."
type = "group"
default = false
[install.always_encrypt]
ask.en = "Force the encryption of images?"
ask.fr = "Forcer le chiffrement des images ?"
type = "boolean"
default = true
[resources]
[resources.sources.main]
url = "https://framagit.org/fiat-tux/hat-softwares/lutim/-/archive/0.12.1/lutim-0.12.1.tar.gz"
sha256 = "141f142d47e3a8367e0c292304ddbecfc34b49ae7e561e2c3526000040318973"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"

View file

@ -5,7 +5,7 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="carton perlmagick libpq-dev shared-mime-info" #REMOVEME? pkg_dependencies="carton perlmagick libpq-dev shared-mime-info"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -38,7 +38,7 @@ ynh_send_readme_to_admin() {
type="${type:-install}" type="${type:-install}"
# Get the value of admin_mail_html # Get the value of admin_mail_html
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) #REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
admin_mail_html="${admin_mail_html:-0}" admin_mail_html="${admin_mail_html:-0}"
# Retrieve the email of users # Retrieve the email of users
@ -158,12 +158,12 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
#================================================= #=================================================
ynh_maintenance_mode_ON () { ynh_maintenance_mode_ON () {
# Load value of $path_url and $domain from the config if their not set # Load value of $path and $domain from the config if their not set
if [ -z $path_url ]; then if [ -z $path ]; then
path_url=$(ynh_app_setting_get $app path) #REMOVEME? path=$(ynh_app_setting_get $app path)
fi fi
if [ -z $domain ]; then if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain) #REMOVEME? domain=$(ynh_app_setting_get $app domain)
fi fi
mkdir -p /var/www/html/ mkdir -p /var/www/html/
@ -190,10 +190,10 @@ ynh_maintenance_mode_ON () {
</html>" > "/var/www/html/maintenance.$app.html" </html>" > "/var/www/html/maintenance.$app.html"
# Create a new nginx config file to redirect all access to the app to the maintenance notice instead. # Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice
rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect;
# Use another location, to not be in conflict with the original config file # Use another location, to not be in conflict with the original config file
location ${path_url}_maintenance/ { location ${path}_maintenance/ {
alias /var/www/html/ ; alias /var/www/html/ ;
try_files maintenance.$app.html =503; try_files maintenance.$app.html =503;
@ -204,7 +204,7 @@ include conf.d/yunohost_panel.conf.inc;
# The current config file will redirect all requests to the root of the app. # The current config file will redirect all requests to the root of the app.
# To keep the full path, we can use the following rewrite rule: # To keep the full path, we can use the following rewrite rule:
# rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect;
# The difference will be in the $1 at the end, which keep the following queries. # The difference will be in the $1 at the end, which keep the following queries.
# But, if it works perfectly for a html request, there's an issue with any php files. # But, if it works perfectly for a html request, there's an issue with any php files.
# This files are treated as simple files, and will be downloaded by the browser. # This files are treated as simple files, and will be downloaded by the browser.
@ -214,16 +214,16 @@ include conf.d/yunohost_panel.conf.inc;
} }
ynh_maintenance_mode_OFF () { ynh_maintenance_mode_OFF () {
# Load value of $path_url and $domain from the config if their not set # Load value of $path and $domain from the config if their not set
if [ -z $path_url ]; then if [ -z $path ]; then
path_url=$(ynh_app_setting_get $app path) #REMOVEME? path=$(ynh_app_setting_get $app path)
fi fi
if [ -z $domain ]; then if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain) #REMOVEME? domain=$(ynh_app_setting_get $app domain)
fi fi
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app.
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx systemctl reload nginx
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
@ -273,7 +273,7 @@ ynh_app_changelog () {
return 0 return 0
fi fi
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version") #REMOVEME? local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version") local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
# Get the line of the version to update to into the changelog # Get the line of the version to update to into the changelog

View file

@ -15,17 +15,17 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# 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 #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." #REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -36,7 +36,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -13,50 +13,50 @@ source /usr/share/yunohost/helpers
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
old_domain=$YNH_APP_OLD_DOMAIN #REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH #REMOVEME? old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN #REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH #REMOVEME? new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
# Needed for helper "ynh_add_nginx_config" #REMOVEME? # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
# Add settings here as needed by your application # Add settings here as needed by your application
is_public=$(ynh_app_setting_get --app=$app --key=is_public) #REMOVEME? is_public=$(ynh_app_setting_get --app=$app --key=is_public)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=20 #REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=20
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting #REMOVEME? ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" #REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# 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 #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Activating maintenance mode..." ynh_script_progression --message="Activating maintenance mode..."
#REMOVEME?
path_url=$old_path path=$old_path
domain=$old_domain domain=$old_domain
ynh_maintenance_mode_ON ynh_maintenance_mode_ON
@ -64,16 +64,16 @@ ynh_maintenance_mode_ON
# CHECK WHICH PARTS SHOULD BE CHANGED # CHECK WHICH PARTS SHOULD BE CHANGED
#================================================= #=================================================
change_domain=0 #REMOVEME? change_domain=0
if [ "$old_domain" != "$new_domain" ] #REMOVEME? if [ "$old_domain" != "$new_domain" ]
then then
change_domain=1 #REMOVEME? change_domain=1
fi fi
change_path=0 #REMOVEME? change_path=0
if [ "$old_path" != "$new_path" ] #REMOVEME? if [ "$old_path" != "$new_path" ]
then then
change_path=1 #REMOVEME? change_path=1
fi fi
#================================================= #=================================================
@ -90,28 +90,30 @@ ynh_systemd_action --service_name=$app --action="stop"
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
#REMOVEME? 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 --file="$nginx_conf_path" #REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper # Set global variables for NGINX helper
domain="$old_domain" #REMOVEME? domain="$old_domain"
path_url="$new_path" #REMOVEME? path="$new_path"
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config #REMOVEME? ynh_add_nginx_config
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 --file="$nginx_conf_path" #REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf #REMOVEME? 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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" #REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#================================================= #=================================================
@ -119,7 +121,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Reconfiguring SSOwat..." ynh_script_progression --message="Reconfiguring SSOwat..."
if [ $is_public -eq 0 ] # Only user with a yunohost account can upload an image #REMOVEME? if [ $is_public -eq 0 ] # Only user with a yunohost account can upload an image
then then
# If the app is private, viewing images stays publicly accessible. # If the app is private, viewing images stays publicly accessible.
if [ "$new_path" == "/" ]; then if [ "$new_path" == "/" ]; then
@ -128,7 +130,7 @@ then
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$new_domain" | sed 's@-@.@g') domain_regex=$(echo "$new_domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$new_path/stats/?$","$domain_regex$new_path/manifest.webapp/?$","$domain_regex$new_path/?$","$domain_regex$new_path/[d-m]/.*$" #REMOVEME? ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$new_path/stats/?$","$domain_regex$new_path/manifest.webapp/?$","$domain_regex$new_path/?$","$domain_regex$new_path/[d-m]/.*$"
fi fi
#================================================= #=================================================
@ -137,7 +139,7 @@ fi
# REPLACE THE PATH IN THE CONFIG OF LUTIM # REPLACE THE PATH IN THE CONFIG OF LUTIM
#================================================= #=================================================
ynh_replace_string --match_string="\(^ *prefix.*=> '\).*" --replace_string="\1$new_path'," --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="\(^ *prefix.*=> '\).*" --replace_string="\1$new_path'," --target_file="$install_dir/lutim.conf"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
@ -152,16 +154,16 @@ ynh_systemd_action --service_name=$app --action="start" --line_match="Manager.*s
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Disabling maintenance mode..." ynh_script_progression --message="Disabling maintenance mode..."
#REMOVEME?
path_url=$old_path path=$old_path
domain=$old_domain domain=$old_domain
ynh_maintenance_mode_OFF ynh_maintenance_mode_OFF

View file

@ -13,43 +13,43 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# 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 #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN #REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH #REMOVEME? path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
always_encrypt=$YNH_APP_ARG_ALWAYS_ENCRYPT #REMOVEME? always_encrypt=$YNH_APP_ARG_ALWAYS_ENCRYPT
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
secret=$(ynh_string_random) secret=$(ynh_string_random)
#================================================= #=================================================
# 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..." --weight=2 #REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=2
final_path=/var/www/$app #REMOVEME? install_dir=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2 #REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain #REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url #REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=always_encrypt --value=$always_encrypt ynh_app_setting_set --app=$app --key=always_encrypt --value=$always_encrypt
ynh_app_setting_set --app=$app --key=secret --value="$secret" ynh_app_setting_set --app=$app --key=secret --value="$secret"
@ -57,46 +57,46 @@ ynh_app_setting_set --app=$app --key=secret --value="$secret"
ynh_app_setting_set --app=$app --key=overwrite_settings --value=1 ynh_app_setting_set --app=$app --key=overwrite_settings --value=1
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1 ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=1 ynh_app_setting_set --app=$app --key=overwrite_systemd --value=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --weight=3 #REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=3
# Find an available port # Find an available port
port=$(ynh_find_port --port=8095) #REMOVEME? port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port #REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=60 #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=60
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --weight=2 #REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -114,10 +114,10 @@ ynh_add_nginx_config
ynh_script_progression --message="Adding a configuration file..." --weight=2 ynh_script_progression --message="Adding a configuration file..." --weight=2
workers="$(( $(nproc) * 2 ))" workers="$(( $(nproc) * 2 ))"
ynh_add_config --template="../conf/lutim.conf.template" --destination="$final_path/lutim.conf" ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf"
chmod 400 "$final_path/lutim.conf" chmod 400 "$install_dir/lutim.conf"
chown $app:$app "$final_path/lutim.conf" chown $app:$app "$install_dir/lutim.conf"
#================================================= #=================================================
# SETUP HOOKS FILE # SETUP HOOKS FILE
@ -131,7 +131,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
#================================================= #=================================================
ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app" ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app"
chmod +x $final_path/script/lutim chmod +x $install_dir/script/lutim
#================================================= #=================================================
# INSTALL LUTIM WITH CARTON # INSTALL LUTIM WITH CARTON
@ -139,16 +139,16 @@ chmod +x $final_path/script/lutim
ynh_script_progression --message="Installing $app with Carton..." --weight=60 ynh_script_progression --message="Installing $app with Carton..." --weight=60
mkdir -p /var/log/$app/ mkdir -p /var/log/$app/
(cd $final_path (cd $install_dir
carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log") carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
# Use a perl path adapted to the system architecture # Use a perl path adapted to the system architecture
arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu) arch_dir=$(ls -1 $install_dir/local/lib/perl5/ | grep linux-gnu)
if [ "$?" -ne 0 ] if [ "$?" -ne 0 ]
then then
ynh_die --message="Unable to find the perl directory for your architecture." ynh_die --message="Unable to find the perl directory for your architecture."
fi fi
ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$final_path/script/lutim" ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$install_dir/script/lutim"
#================================================= #=================================================
# SETUP LOG FILE # SETUP LOG FILE
@ -157,7 +157,7 @@ ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --t
# Making log a symbolic link to /var/log # Making log a symbolic link to /var/log
touch /var/log/$app/production.log touch /var/log/$app/production.log
chown $app -R /var/log/$app chown $app -R /var/log/$app
ln -s /var/log/$app/production.log "$final_path/log/production.log" ln -s /var/log/$app/production.log "$install_dir/log/production.log"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -182,7 +182,7 @@ ynh_use_logrotate
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="$final_path/log/production.log" yunohost service add $app --log="$install_dir/log/production.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -194,7 +194,7 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="
ynh_systemd_action --action=stop ynh_systemd_action --action=stop
# Set right permissions on new files created at first start # Set right permissions on new files created at first start
chown -R $app:$app $final_path chown -R $app:$app $install_dir
# Wait for lutim to be fully started # Wait for lutim to be fully started
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
@ -202,36 +202,36 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." #REMOVEME? ynh_script_progression --message="Configuring permissions..."
ynh_permission_update --permission="main" --add="visitors" #REMOVEME? ynh_permission_update --permission="main" --add="visitors"
# This is a fake permission without any URL. # This is a fake permission without any URL.
# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. # The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified.
# We can't use a real permission for now because the actual permision system doesn't support regex. # We can't use a real permission for now because the actual permision system doesn't support regex.
ynh_permission_create --permission="upload images" --allowed="visitors" #REMOVEME? ynh_permission_create --permission="upload images" --allowed="visitors"
if [ $is_public -eq 0 ] #REMOVEME? if [ $is_public -eq 0 ]
then then
# If the app is private, viewing images stays publicly accessible. # If the app is private, viewing images stays publicly accessible.
if [ "$path_url" == "/" ]; then if [ "$path" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
path_url="" path=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$" #REMOVEME? ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path/stats/?$","$domain_regex$path/manifest.webapp/?$","$domain_regex$path/?$","$domain_regex$path/[d-m]/.*$"
# If the app is not public, then the "visitors" group doesn't have this permission # If the app is not public, then the "visitors" group doesn't have this permission
ynh_permission_update --permission="upload images" --remove="visitors" #REMOVEME? ynh_permission_update --permission="upload images" --remove="visitors"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN
@ -240,7 +240,7 @@ ynh_systemd_action --service_name=nginx --action=reload
# Get main domain and buid the URL of the admin panel of the app. # Get main domain and buid the URL of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo "You can find a config file at $final_path/lutim.conf echo "You can find a config file at $install_dir/lutim.conf
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.

View file

@ -12,12 +12,12 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -51,10 +51,10 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2 #REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" #REMOVEME? ynh_secure_remove --file="$install_dir"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -67,10 +67,10 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=20 #REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=20
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies #REMOVEME? ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
@ -87,10 +87,10 @@ ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=5 #REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=5
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app #REMOVEME? ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -14,30 +14,30 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# 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 #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." #REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
@ -51,31 +51,31 @@ ynh_maintenance_mode_ON
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 #REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=60 #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=60
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
@ -116,7 +116,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="$final_path/log/production.log" yunohost service add $app --log="$install_dir/log/production.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -148,7 +148,7 @@ ynh_maintenance_mode_OFF
# Get main domain and buid the url of the admin panel of the app. # Get main domain and buid the url of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
echo "You can find a config file at $final_path/lutim.conf echo "You can find a config file at $install_dir/lutim.conf
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.

View file

@ -12,26 +12,26 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=4 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=4
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
is_public=$(ynh_app_setting_get --app=$app --key=is_public) #REMOVEME? is_public=$(ynh_app_setting_get --app=$app --key=is_public)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt) #REMOVEME? always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
secret=$(ynh_app_setting_get --app=$app --key=secret) #REMOVEME? secret=$(ynh_app_setting_get --app=$app --key=secret)
overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings) #REMOVEME? overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings)
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx) #REMOVEME? overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
overwrite_systemd=$(ynh_app_setting_get --app=$app --key=overwrite_systemd) #REMOVEME? overwrite_systemd=$(ynh_app_setting_get --app=$app --key=overwrite_systemd)
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html) #REMOVEME? admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
# Optional parameters from config-panel feature # Optional parameters from config-panel feature
antiflood=$(ynh_app_setting_get --app=$app --key=antiflood) #REMOVEME? antiflood=$(ynh_app_setting_get --app=$app --key=antiflood)
delay=$(ynh_app_setting_get --app=$app --key=delay) #REMOVEME? delay=$(ynh_app_setting_get --app=$app --key=delay)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -43,17 +43,17 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=15 #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=15
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# 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 #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
@ -76,7 +76,7 @@ ynh_systemd_action --service_name=$app --action="stop"
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) #REMOVEME? skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris)
# Unused with the permission system # Unused with the permission system
if [ ! -z "$skipped_uris" ]; then if [ ! -z "$skipped_uris" ]; then
@ -84,33 +84,33 @@ if [ ! -z "$skipped_uris" ]; then
fi fi
# Create the permission "upload images" only if it doesn't exist. # Create the permission "upload images" only if it doesn't exist.
if ! ynh_permission_exists --permission="upload images" #REMOVEME? if ! ynh_permission_exists --permission="upload images"
then then
# This is a fake permission without any URL. # This is a fake permission without any URL.
# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. # The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified.
# We can't use a real permission for now because the actual permision system doesn't support regex. # We can't use a real permission for now because the actual permision system doesn't support regex.
ynh_permission_create --permission="upload images" --allowed="visitors" #REMOVEME? ynh_permission_create --permission="upload images" --allowed="visitors"
if [ $is_public -eq 0 ] #REMOVEME? if [ $is_public -eq 0 ]
then then
# If the app is private, viewing images stays publicly accessible. # If the app is private, viewing images stays publicly accessible.
if [ "$path_url" == "/" ]; then if [ "$path" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
path_url="" path=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$" #REMOVEME? ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path/stats/?$","$domain_regex$path/manifest.webapp/?$","$domain_regex$path/?$","$domain_regex$path/[d-m]/.*$"
# If the app is not public, then the "visitors" group doesn't have this permission # If the app is not public, then the "visitors" group doesn't have this permission
ynh_permission_update --permission="upload images" --remove="visitors" #REMOVEME? ynh_permission_update --permission="upload images" --remove="visitors"
fi fi
fi fi
# if final_path isn't set, which can happens with old scripts, set final_path. # if install_dir isn't set, which can happens with old scripts, set install_dir.
if [ -z "$final_path" ]; then if [ -z "$install_dir" ]; then
final_path=/var/www/$app #REMOVEME? install_dir=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
fi fi
# Fix always_encrypt as a boolean # Fix always_encrypt as a boolean
@ -142,7 +142,7 @@ fi
# If secret doesn't exist, create it # If secret doesn't exist, create it
if [ -z "$secret" ]; then if [ -z "$secret" ]; then
secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2) secret=$(grep "secrets *=>" "$install_dir/lutim.conf" | cut -d\' -f2)
ynh_app_setting_set --app=$app --key=secret --value=$secret ynh_app_setting_set --app=$app --key=secret --value=$secret
fi fi
@ -159,10 +159,10 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -173,19 +173,19 @@ then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
fi fi
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=9 #REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=9
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -209,21 +209,21 @@ ynh_script_progression --message="Reconfiguring $app..."
if [ $overwrite_settings -eq 1 ] if [ $overwrite_settings -eq 1 ]
then then
workers="$(( $(nproc) * 2 ))" workers="$(( $(nproc) * 2 ))"
ynh_add_config --template="../conf/lutim.conf.template" --destination="$final_path/lutim.conf" ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf"
chmod 400 "$final_path/lutim.conf" chmod 400 "$install_dir/lutim.conf"
chown $app:$app "$final_path/lutim.conf" chown $app:$app "$install_dir/lutim.conf"
# Optional parameters from config-panel feature # Optional parameters from config-panel feature
if [ -n "$antiflood" ]; then if [ -n "$antiflood" ]; then
ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$final_path/lutim.conf" ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$install_dir/lutim.conf"
# Disable anti_flood_delay if the delay is 0 # Disable anti_flood_delay if the delay is 0
if [ $antiflood = 0 ]; then if [ $antiflood = 0 ]; then
ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$install_dir/lutim.conf"
fi fi
fi fi
if [ -n "$delay" ]; then if [ -n "$delay" ]; then
ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$final_path/lutim.conf" ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$install_dir/lutim.conf"
fi fi
fi fi
@ -247,8 +247,8 @@ ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app"
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading $app with Carton..." --weight=4 ynh_script_progression --message="Upgrading $app with Carton..." --weight=4
pushd "$final_path" pushd "$install_dir"
ynh_secure_remove --file="$final_path/local" #REMOVEME? ynh_secure_remove --file="$install_dir/local"
carton install --without=mysql --without=htpasswd --without=test carton install --without=mysql --without=htpasswd --without=test
popd popd
fi fi
@ -280,7 +280,7 @@ chown $app -R /var/log/$app
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="$final_path/log/production.log" yunohost service add $app --log="$install_dir/log/production.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -292,9 +292,9 @@ ynh_systemd_action --service_name=$app --action="start" --line_match="Manager.*s
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
@ -313,7 +313,7 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
# Build the changelog # Build the changelog
ynh_app_changelog || true ynh_app_changelog || true
echo "You can find a config file at $final_path/lutim.conf echo "You can find a config file at $install_dir/lutim.conf
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.