mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
Indentation
This commit is contained in:
parent
4e28257f05
commit
a934b73698
9 changed files with 239 additions and 239 deletions
|
@ -1,22 +1,22 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
always_encrypt=1
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=1 (8095)
|
||||
change_url=1
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
always_encrypt=1
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=1 (8095)
|
||||
change_url=1
|
||||
;;; Levels
|
||||
# Level 5: https://github.com/YunoHost/package_linter/issues/36
|
||||
Level 5=1
|
||||
|
@ -24,6 +24,6 @@
|
|||
Email=
|
||||
Notification=down
|
||||
;;; Upgrade options
|
||||
; commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
||||
name=08 Sep 2017 4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&always_encrypt=1&
|
||||
; commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
||||
name=08 Sep 2017 4c29aa94f9d9048411c6e165e122e03574fb9b8d
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&always_encrypt=1&
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
location __PATH__ {
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
||||
# This is important for user's privacy !
|
||||
access_log off;
|
||||
error_log /var/log/nginx/lutim.error.log;
|
||||
# This is important for user's privacy !
|
||||
access_log off;
|
||||
error_log /var/log/nginx/lutim.error.log;
|
||||
|
||||
# This is important ! Make it OK with your Lutim configuration
|
||||
client_max_body_size 40M;
|
||||
# This is important ! Make it OK with your Lutim configuration
|
||||
client_max_body_size 40M;
|
||||
|
||||
proxy_pass http://127.0.0.1:__PORT__;
|
||||
proxy_pass http://127.0.0.1:__PORT__;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
# Lutim reads this header and understands that the current session is actually HTTPS.
|
||||
# Enable it if you run a HTTPS server (in this case, don't forgot to change the listen port
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
# Lutim reads this header and understands that the current session is actually HTTPS.
|
||||
# Enable it if you run a HTTPS server (in this case, don't forgot to change the listen port
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
|
||||
# We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite
|
||||
proxy_redirect off;
|
||||
# We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
|
124
manifest.json
124
manifest.json
|
@ -1,64 +1,64 @@
|
|||
{
|
||||
"name": "Lutim",
|
||||
"id": "lutim",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Self hosting images and sharing anonymous application",
|
||||
"fr": "Application d'hébergement et de partage d'images anonyme"
|
||||
},
|
||||
"version": "0.11.6~ynh3",
|
||||
"url": "https://lut.im",
|
||||
"license": "AGPL-3.0",
|
||||
"maintainer": {
|
||||
"name": "Maniack Crudelis et matlink",
|
||||
"email": "maniackc_dev@crudelis.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.7"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Lutim",
|
||||
"fr": "Choisissez un domaine pour Lutim"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Lutim",
|
||||
"fr": "Choisissez un chemin pour Lutim"
|
||||
},
|
||||
"example": "/lutim",
|
||||
"default": "/lutim"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Uploading images is it public?",
|
||||
"fr": "L'upload des images est-il public ?"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "always_encrypt",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Force the encryption of images?",
|
||||
"fr": "Forcer le chiffrement des images ?"
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
"name": "Lutim",
|
||||
"id": "lutim",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Self hosting images and sharing anonymous application",
|
||||
"fr": "Application d'hébergement et de partage d'images anonyme"
|
||||
},
|
||||
"version": "0.11.6~ynh3",
|
||||
"url": "https://lut.im",
|
||||
"license": "AGPL-3.0",
|
||||
"maintainer": {
|
||||
"name": "Maniack Crudelis et matlink",
|
||||
"email": "maniackc_dev@crudelis.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.7"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Lutim",
|
||||
"fr": "Choisissez un domaine pour Lutim"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Lutim",
|
||||
"fr": "Choisissez un chemin pour Lutim"
|
||||
},
|
||||
"example": "/lutim",
|
||||
"default": "/lutim"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Uploading images is it public?",
|
||||
"fr": "L'upload des images est-il public ?"
|
||||
},
|
||||
"default": false,
|
||||
},
|
||||
{
|
||||
"name": "always_encrypt",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Force the encryption of images?",
|
||||
"fr": "Forcer le chiffrement des images ?"
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ secret=$(ynh_app_setting_get --app=$app --key=secret)
|
|||
file="$1"
|
||||
|
||||
if [ "$file" = "lutim.conf" ]; then
|
||||
config_file="$final_path/lutim.conf"
|
||||
config_file="$final_path/lutim.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -43,15 +43,15 @@ ynh_backup_if_checksum_is_different --file="$config_file"
|
|||
|
||||
if [ "$file" = "lutim.conf" ]
|
||||
then
|
||||
# Get the default file and overwrite the current config
|
||||
cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file"
|
||||
# Get the default file and overwrite the current config
|
||||
cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file"
|
||||
|
||||
# Recreate the default config
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config_file"
|
||||
# Recreate the default config
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config_file"
|
||||
# Set the number of process for Lutim to twice the number of CPU core.
|
||||
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
|
||||
fi
|
||||
|
|
|
@ -63,13 +63,13 @@ ynh_maintenance_mode_ON
|
|||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -95,26 +95,26 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -124,14 +124,14 @@ ynh_script_progression --message="Reconfiguring SSOwat..."
|
|||
|
||||
if [ $is_public -eq 0 ] # Only user with a yunohost account can upload an image
|
||||
then
|
||||
# If the app is private, viewing images stays publicly accessible.
|
||||
if [ "$new_path" == "/" ]; then
|
||||
# If the path is /, clear it to prevent any error with the regex.
|
||||
new_path=""
|
||||
fi
|
||||
# Modify the domain to be used in a regex
|
||||
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]/.*$"
|
||||
# If the app is private, viewing images stays publicly accessible.
|
||||
if [ "$new_path" == "/" ]; then
|
||||
# If the path is /, clear it to prevent any error with the regex.
|
||||
new_path=""
|
||||
fi
|
||||
# Modify the domain to be used in a regex
|
||||
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]/.*$"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -26,9 +26,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
config_file="$final_path/lutim.conf"
|
||||
|
||||
get_config_value() {
|
||||
option_name="$1"
|
||||
# Get the value of this option in the config file
|
||||
grep "$option_name *=>" "$config_file" | cut -d'>' -f2 | sed s'/ //g' | cut -d',' -f1
|
||||
option_name="$1"
|
||||
# Get the value of this option in the config file
|
||||
grep "$option_name *=>" "$config_file" | cut -d'>' -f2 | sed s'/ //g' | cut -d',' -f1
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -49,15 +49,15 @@ antiflood="${YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD:-$old_antiflood}"
|
|||
# delay
|
||||
old_delay="$(get_config_value default_delay)"
|
||||
if [ $old_delay -eq 0 ]; then
|
||||
old_delay=None
|
||||
old_delay=None
|
||||
elif [ $old_delay -eq 1 ]; then
|
||||
old_delay=Day
|
||||
old_delay=Day
|
||||
elif [ $old_delay -eq 7 ]; then
|
||||
old_delay=Week
|
||||
old_delay=Week
|
||||
elif [ $old_delay -eq 30 ]; then
|
||||
old_delay=Month
|
||||
old_delay=Month
|
||||
else
|
||||
old_delay=Year
|
||||
old_delay=Year
|
||||
fi
|
||||
delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}"
|
||||
|
||||
|
@ -82,18 +82,18 @@ admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_htm
|
|||
#=================================================
|
||||
|
||||
show_config() {
|
||||
# here you are supposed to read some config file/database/other then print the values
|
||||
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||
# here you are supposed to read some config file/database/other then print the values
|
||||
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT=$always_encrypt"
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood"
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay"
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT=$always_encrypt"
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood"
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
||||
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -166,6 +166,6 @@ apply_config() {
|
|||
#=================================================
|
||||
|
||||
case $1 in
|
||||
show) show_config;;
|
||||
apply) apply_config;;
|
||||
show) show_config;;
|
||||
apply) apply_config;;
|
||||
esac
|
||||
|
|
|
@ -17,7 +17,7 @@ source _variables
|
|||
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remaining that are not handle by the remove script.
|
||||
ynh_clean_check_starting
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -158,7 +158,7 @@ carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
|
|||
arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu)
|
||||
if [ "$?" -ne 0 ]
|
||||
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
|
||||
ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$final_path/script/lutim"
|
||||
|
||||
|
@ -208,17 +208,17 @@ ynh_permission_create --permission="upload images" --allowed="visitors"
|
|||
|
||||
if [ $is_public -eq 0 ]
|
||||
then
|
||||
# If the app is private, viewing images stays publicly accessible.
|
||||
if [ "$path_url" == "/" ]; then
|
||||
# If the path is /, clear it to prevent any error with the regex.
|
||||
path_url=""
|
||||
fi
|
||||
# Modify the domain to be used in a regex
|
||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||
# If the app is private, viewing images stays publicly accessible.
|
||||
if [ "$path_url" == "/" ]; then
|
||||
# If the path is /, clear it to prevent any error with the regex.
|
||||
path_url=""
|
||||
fi
|
||||
# Modify the domain to be used in a regex
|
||||
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]/.*$"
|
||||
|
||||
# If the app is not public, then the "visitors" group doesn't have this permission
|
||||
ynh_permission_update --permission="upload images" --remove="visitors"
|
||||
# If the app is not public, then the "visitors" group doesn't have this permission
|
||||
ynh_permission_update --permission="upload images" --remove="visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -17,7 +17,7 @@ source ../settings/scripts/_variables
|
|||
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remaining that are not handle by the remove script.
|
||||
ynh_clean_check_starting
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -39,9 +39,9 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
|
|
144
scripts/upgrade
144
scripts/upgrade
|
@ -48,87 +48,87 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
|
|||
|
||||
# Fix is_public as a boolean
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris)
|
||||
|
||||
# Unused with the permission system
|
||||
if [ ! -z "$skipped_uris" ]; then
|
||||
ynh_app_setting_delete --app=$app --key=skipped_uris
|
||||
ynh_app_setting_delete --app=$app --key=skipped_uris
|
||||
fi
|
||||
|
||||
# Create the permission "upload images" only if it doesn't exist.
|
||||
if ! ynh_permission_exists --permission="upload images"
|
||||
then
|
||||
# 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.
|
||||
# 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"
|
||||
# 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.
|
||||
# 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"
|
||||
|
||||
if [ $is_public -eq 0 ]
|
||||
then
|
||||
# If the app is private, viewing images stays publicly accessible.
|
||||
if [ "$path_url" == "/" ]; then
|
||||
# If the path is /, clear it to prevent any error with the regex.
|
||||
path_url=""
|
||||
fi
|
||||
# Modify the domain to be used in a regex
|
||||
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]/.*$"
|
||||
if [ $is_public -eq 0 ]
|
||||
then
|
||||
# If the app is private, viewing images stays publicly accessible.
|
||||
if [ "$path_url" == "/" ]; then
|
||||
# If the path is /, clear it to prevent any error with the regex.
|
||||
path_url=""
|
||||
fi
|
||||
# Modify the domain to be used in a regex
|
||||
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]/.*$"
|
||||
|
||||
# If the app is not public, then the "visitors" group doesn't have this permission
|
||||
ynh_permission_update --permission="upload images" --remove="visitors"
|
||||
fi
|
||||
# If the app is not public, then the "visitors" group doesn't have this permission
|
||||
ynh_permission_update --permission="upload images" --remove="visitors"
|
||||
fi
|
||||
fi
|
||||
|
||||
# if final_path isn't set, which can happens with old scripts, set final_path.
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
# Fix always_encrypt as a boolean
|
||||
if [ "$always_encrypt" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=always_encrypt --value=1
|
||||
always_encrypt=1
|
||||
ynh_app_setting_set --app=$app --key=always_encrypt --value=1
|
||||
always_encrypt=1
|
||||
elif [ "$always_encrypt" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=always_encrypt --value=0
|
||||
always_encrypt=0
|
||||
ynh_app_setting_set --app=$app --key=always_encrypt --value=0
|
||||
always_encrypt=0
|
||||
fi
|
||||
|
||||
# If overwrite_settings doesn't exist, create it
|
||||
if [ -z "$overwrite_settings" ]; then
|
||||
overwrite_settings=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings
|
||||
overwrite_settings=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings
|
||||
fi
|
||||
|
||||
# If overwrite_nginx doesn't exist, create it
|
||||
if [ -z "$overwrite_nginx" ]; then
|
||||
overwrite_nginx=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
|
||||
overwrite_nginx=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
|
||||
fi
|
||||
|
||||
# If overwrite_systemd doesn't exist, create it
|
||||
if [ -z "$overwrite_systemd" ]; then
|
||||
overwrite_systemd=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd
|
||||
overwrite_systemd=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd
|
||||
fi
|
||||
|
||||
# If secret doesn't exist, create it
|
||||
if [ -z "$secret" ]; then
|
||||
secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2)
|
||||
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
||||
secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2)
|
||||
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
||||
fi
|
||||
|
||||
# Close opened port
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_exec_quiet yunohost firewall disallow TCP $port
|
||||
ynh_exec_quiet yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
# Replace skipped_uris by unprotected_uris for the migration to the new permission system.
|
||||
|
@ -144,9 +144,9 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
|||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Clean installation remaining that are not handle by the remove script.
|
||||
ynh_clean_check_starting
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
ynh_clean_check_starting
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -173,9 +173,9 @@ ynh_maintenance_mode_ON
|
|||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -192,8 +192,8 @@ ynh_install_app_dependencies $app_depencencies
|
|||
# Overwrite the nginx configuration only if it's allowed
|
||||
if [ $overwrite_nginx -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
|
||||
ynh_add_nginx_config
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -214,31 +214,31 @@ ynh_script_progression --message="Reconfigure Lutim"
|
|||
# Overwrite the settings config file only if it's allowed
|
||||
if [ $overwrite_settings -eq 1 ]
|
||||
then
|
||||
# Configure Lutim
|
||||
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/lutim.conf"
|
||||
cp ../conf/lutim.conf.template "$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$final_path/lutim.conf"
|
||||
# Configure Lutim
|
||||
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/lutim.conf"
|
||||
cp ../conf/lutim.conf.template "$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$final_path/lutim.conf"
|
||||
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$final_path/lutim.conf"
|
||||
# Set the number of process for Lutim to twice the number of CPU core.
|
||||
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$final_path/lutim.conf"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$final_path/lutim.conf"
|
||||
|
||||
# Optional parameters from config-panel feature
|
||||
if [ -n "$antiflood" ]; then
|
||||
ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$final_path/lutim.conf"
|
||||
# Disable anti_flood_delay if the delay is 0
|
||||
if [ $antiflood = 0 ]; then
|
||||
ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$final_path/lutim.conf"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$delay" ]; then
|
||||
ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$final_path/lutim.conf"
|
||||
fi
|
||||
# Optional parameters from config-panel feature
|
||||
if [ -n "$antiflood" ]; then
|
||||
ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$final_path/lutim.conf"
|
||||
# Disable anti_flood_delay if the delay is 0
|
||||
if [ $antiflood = 0 ]; then
|
||||
ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$final_path/lutim.conf"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$delay" ]; then
|
||||
ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$final_path/lutim.conf"
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -255,8 +255,8 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
|
|||
# Overwrite the systemd configuration only if it's allowed
|
||||
if [ $overwrite_systemd -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
|
||||
ynh_add_systemd_config
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
|
||||
ynh_add_systemd_config
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -273,9 +273,9 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
|
|||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading Lutim with carton..." --weight=4
|
||||
(cd $final_path
|
||||
carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
|
||||
ynh_script_progression --message="Upgrading Lutim with carton..." --weight=4
|
||||
(cd $final_path
|
||||
carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue