1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/shaarli_ynh.git synced 2024-09-03 20:26:10 +02:00

Added dependencies and updated change_url

This commit is contained in:
anmol26s 2018-09-30 07:50:19 +05:30
parent 01cce20693
commit cb6c6a1232
6 changed files with 48 additions and 28 deletions

View file

@ -27,7 +27,8 @@
Level 2=auto
Level 3=auto
# Level 4:
Level 4=0
# Not implimented by upstream
Level 4=na
# Level 5:
Level 5=auto
Level 6=auto

View file

@ -17,7 +17,7 @@
"url": "https://github.com/shaarli/Shaarli",
"license": "free",
"version": "0.10.2",
"multi_instance": "true",
"multi_instance": true,
"services": [
"nginx",
"php5-fpm"

View file

@ -21,6 +21,17 @@ new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get $app final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get "$app" db_name)
#db_pwd=$(ynh_app_setting_get $app db_pwd)
#=================================================
# CHECK THE SYNTAX OF THE PATHS
#=================================================
@ -30,6 +41,7 @@ test -n "$new_path" || new_path="/"
new_path=$(ynh_normalize_url_path $new_path)
old_path=$(ynh_normalize_url_path $old_path)
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
@ -57,26 +69,35 @@ 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 "$nginx_conf_path"
# Replace locations starting with old_path
# Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path"
# Replace path in "return" directives
ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path"
# Calculate and store the nginx config file checksum
ynh_store_file_checksum "$nginx_conf_path"
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# 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 "$nginx_conf_path"
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "$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 "/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx

View file

@ -13,9 +13,14 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
@ -42,9 +47,11 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
@ -57,14 +64,6 @@ ynh_webpath_available $domain $path_url
ynh_webpath_register $app $domain $path_url
# Check that the options are compatible
if [ $is_public = "Yes" ]; then
if [ $privateinstance = "Yes" ] ; then
ynh_die "Incompatible options: the instance cannot be both public and private" 1
fi
fi
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
@ -75,7 +74,7 @@ ynh_app_setting_set $app is_public $is_public
# Install dependencies
ynh_install_app_dependencies php-cli
ynh_install_app_dependencies 'php5-cli|php-cli' php-gettext 'php5-curl|php-curl' 'php-intl|php5-intl' php-gd 'php-mbstring|base-files(<<9.0)' openssl
#=================================================

View file

@ -83,7 +83,7 @@ ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
#=================================================
# Define and install dependencies
ynh_install_app_dependencies php-cli
ynh_install_app_dependencies 'php5-cli|php-cli' php-gettext 'php5-curl|php-curl' 'php-intl|php5-intl' php-gd 'php-mbstring|base-files(<<9.0)' openssl
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
@ -105,7 +105,6 @@ systemctl restart fail2ban
# RELOAD NGINX AND PHP-FPM
#=================================================
systemctl reload php5-fpm
systemctl reload nginx

View file

@ -88,7 +88,7 @@ sudo rm -Rf "$tmpdir"
ynh_add_nginx_config
# Install dependencies
ynh_install_app_dependencies php-cli
ynh_install_app_dependencies 'php5-cli|php-cli' php-gettext 'php5-curl|php-curl' 'php-intl|php5-intl' php-gd 'php-mbstring|base-files(<<9.0)' openssl
#=================================================
# CREATE DEDICATED USER