2014-01-13 13:50:38 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-09-28 18:02:10 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2019-02-13 21:13:59 +01:00
|
|
|
source _common.sh
|
2017-09-28 18:02:10 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2019-02-13 21:13:59 +01:00
|
|
|
# MANAGE SCRIPT FAILURE
|
2017-09-28 18:02:10 +02:00
|
|
|
#=================================================
|
|
|
|
|
2019-02-13 21:13:59 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2016-05-13 21:34:03 +02:00
|
|
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2017-09-28 18:02:10 +02:00
|
|
|
path_url=$YNH_APP_ARG_PATH
|
2016-05-13 21:34:03 +02:00
|
|
|
admin_user=$YNH_APP_ARG_ADMIN_USER
|
|
|
|
upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2014-01-13 13:50:38 +01:00
|
|
|
|
2017-09-28 18:02:10 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2014-01-13 13:50:38 +01:00
|
|
|
|
2017-09-28 18:02:10 +02:00
|
|
|
#=================================================
|
2019-02-13 21:13:59 +01:00
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
2017-09-28 18:02:10 +02:00
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Validating installation parameters..."
|
2015-01-31 23:01:16 +01:00
|
|
|
|
2017-09-28 18:02:10 +02:00
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
|
|
|
|
# Normalize the url path syntax
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
|
|
|
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register $app $domain $path_url
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Storing installation settings..."
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
ynh_app_setting_set $app domain $domain
|
|
|
|
ynh_app_setting_set $app path $path_url
|
|
|
|
ynh_app_setting_set $app admin $admin_user
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Setting up source files..."
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
ynh_app_setting_set $app final_path $final_path
|
|
|
|
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Configuring nginx web server..."
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2014-01-13 21:36:14 +01:00
|
|
|
|
2017-09-28 18:02:10 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Configuring system user..."
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create $app
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Configuring php-fpm..."
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
# Create a dedicated php-fpm config
|
|
|
|
ynh_add_fpm_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# SET AND SAVE THE UPLOAD PASSWORD
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
jirafeauconfigfile="$final_path/lib/config.local.php"
|
|
|
|
cp "../conf/config.local.php" "$jirafeauconfigfile"
|
2014-01-13 13:50:38 +01:00
|
|
|
|
2015-07-13 22:28:21 +02:00
|
|
|
# Set and save upload password, allowing an empty one
|
2017-09-28 18:02:10 +02:00
|
|
|
if [ -z "$upload_password" ]
|
|
|
|
then
|
2019-02-13 21:13:59 +01:00
|
|
|
ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "" "$jirafeauconfigfile"
|
2017-09-28 18:02:10 +02:00
|
|
|
ynh_app_setting_set $app upload_password ""
|
2015-07-13 22:28:21 +02:00
|
|
|
else
|
2019-02-13 21:13:59 +01:00
|
|
|
ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "'$upload_password'" "$jirafeauconfigfile"
|
2017-09-28 18:02:10 +02:00
|
|
|
ynh_app_setting_set $app upload_password "$upload_password"
|
2015-07-13 22:28:21 +02:00
|
|
|
fi
|
|
|
|
|
2017-09-28 18:02:10 +02:00
|
|
|
#=================================================
|
|
|
|
# CONFIGURE JIRAFEAU
|
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Configuring jirafeau..."
|
2017-09-28 18:02:10 +02:00
|
|
|
|
2016-05-13 21:34:03 +02:00
|
|
|
var_root=/home/yunohost.app/$app
|
2019-02-13 21:13:59 +01:00
|
|
|
|
|
|
|
ynh_replace_string "__YNH_DOMAIN__" "$domain" "$jirafeauconfigfile"
|
2017-09-28 18:02:10 +02:00
|
|
|
if [ "$path_url" = "/" ]
|
|
|
|
then
|
2019-02-13 21:13:59 +01:00
|
|
|
ynh_replace_string "__YNH_WWW_PATH__" "" "$jirafeauconfigfile"
|
2015-05-23 15:29:21 +02:00
|
|
|
else
|
2019-02-13 21:13:59 +01:00
|
|
|
ynh_replace_string "__YNH_WWW_PATH__" "$path_url" "$jirafeauconfigfile"
|
2015-05-23 15:29:21 +02:00
|
|
|
fi
|
2019-02-13 21:13:59 +01:00
|
|
|
ynh_replace_string "__YNH_VAR_ROOT__" "$var_root" "$jirafeauconfigfile"
|
|
|
|
ynh_replace_string "__YNH_ADMIN_USER__" "$admin_user" "$jirafeauconfigfile"
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
|
|
ynh_store_file_checksum "$jirafeauconfigfile"
|
|
|
|
|
|
|
|
# Remove the install.php
|
|
|
|
rm $final_path/install.php
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
# SECURING FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
chown -R root: $final_path
|
|
|
|
|
|
|
|
mkdir -p $var_root/{files,links,async,block}
|
|
|
|
chown -R $app:root $var_root
|
|
|
|
chmod -R 700 $var_root
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Configuring SSOwat..."
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
|
|
|
if [ $is_public -eq 0 ]
|
2014-01-13 13:50:38 +01:00
|
|
|
then
|
2017-09-28 18:02:10 +02:00
|
|
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
|
|
|
[ "$path_url" = "/" ] && path_url=""
|
|
|
|
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
|
2014-01-13 13:50:38 +01:00
|
|
|
fi
|
|
|
|
|
2017-09-28 18:02:10 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2019-02-17 20:55:13 +01:00
|
|
|
ynh_print_info "Reloading nginx web server..."
|
2017-09-28 18:02:10 +02:00
|
|
|
|
|
|
|
systemctl reload nginx
|
2019-02-17 20:55:13 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_print_info "Installation of $app completed"
|