2018-09-29 23:37:05 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS
|
|
|
|
#=================================================
|
2019-01-30 19:16:04 +01:00
|
|
|
ynh_script_progression --message="Retrieve arguments from the manifest"
|
2018-09-29 23:37:05 +02:00
|
|
|
|
|
|
|
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|
|
|
infcloud=$(ynh_app_setting_get $app infcloud)
|
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF AN ACTION HAS TO BE DONE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ $infcloud -eq 1 ]
|
|
|
|
then
|
2019-01-30 19:16:04 +01:00
|
|
|
action_print="Remove"
|
2018-09-29 23:37:05 +02:00
|
|
|
infcloud=0
|
|
|
|
else
|
2019-01-30 19:16:04 +01:00
|
|
|
action_print="Install"
|
2018-09-29 23:37:05 +02:00
|
|
|
infcloud=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC ACTION
|
|
|
|
#=================================================
|
|
|
|
# INSTALL OR REMOVE INFCLOUD
|
|
|
|
#=================================================
|
2019-01-30 19:16:04 +01:00
|
|
|
ynh_script_progression --message="$action_print InfCloud." --weight=9
|
2018-09-29 23:37:05 +02:00
|
|
|
|
|
|
|
if [ $infcloud -eq 1 ]
|
|
|
|
then
|
|
|
|
# Install InfCloud
|
|
|
|
|
|
|
|
# Get settings
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path_url=$(ynh_app_setting_get $app path)
|
|
|
|
language=$(ynh_app_setting_get $app language)
|
|
|
|
admin=$(ynh_app_setting_get $app admin)
|
|
|
|
|
|
|
|
# Optional parameters from config-panel feature
|
|
|
|
firstdayofweek=$(ynh_app_setting_get $app firstdayofweek)
|
|
|
|
activeview=$(ynh_app_setting_get $app activeview)
|
|
|
|
openformmode=$(ynh_app_setting_get $app openformmode)
|
|
|
|
startofbusiness=$(ynh_app_setting_get $app startofbusiness)
|
|
|
|
endofbusiness=$(ynh_app_setting_get $app endofbusiness)
|
|
|
|
defaulteventduration=$(ynh_app_setting_get $app defaulteventduration)
|
|
|
|
|
2019-01-18 21:12:58 +01:00
|
|
|
# Add InfCloud to nginx config
|
2018-09-29 23:37:05 +02:00
|
|
|
ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
|
|
|
|
# Install InfCloud
|
|
|
|
(YNH_CWD="$YNH_CWD/scripts"; ynh_setup_source "$final_path/infcloud")
|
|
|
|
|
2019-01-18 21:12:58 +01:00
|
|
|
# InfCloud configuration
|
|
|
|
# Set language
|
2018-09-29 23:37:05 +02:00
|
|
|
case "$language" in
|
|
|
|
"Czech") language="cs_CZ"
|
|
|
|
;;
|
|
|
|
"Danish") language="da_DK"
|
|
|
|
;;
|
|
|
|
"German") language="de_DE"
|
|
|
|
;;
|
|
|
|
"English/US") language="en_US"
|
|
|
|
;;
|
|
|
|
"Spanish") language="es_ES"
|
|
|
|
;;
|
|
|
|
"French") language="fr_FR"
|
|
|
|
;;
|
|
|
|
"Italian") language="it_IT"
|
|
|
|
;;
|
|
|
|
"Japan") language="ja_JP"
|
|
|
|
;;
|
|
|
|
"Hungarian") language="hu_HU"
|
|
|
|
;;
|
|
|
|
"Dutch") language="nl_NL"
|
|
|
|
;;
|
|
|
|
"Slovak") language="sk_SK"
|
|
|
|
;;
|
|
|
|
"Turkish") language="tr_TR"
|
|
|
|
;;
|
|
|
|
"Russian") language="ru_RU"
|
|
|
|
;;
|
|
|
|
"Ukrainian") language="uk_UA"
|
|
|
|
;;
|
|
|
|
"Chinese") language="zh_CN"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
cp conf/config.js "$final_path/infcloud/"
|
|
|
|
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/infcloud/config.js"
|
|
|
|
ynh_replace_string "__PATH__" "${path_url%/}" "$final_path/infcloud/config.js"
|
|
|
|
ynh_replace_string "__LANG__" "$language" "$final_path/infcloud/config.js"
|
|
|
|
ynh_replace_string "__ADMIN__" "$admin" "$final_path/infcloud/config.js"
|
|
|
|
ynh_replace_string "__TIMEZONE__" "$(cat /etc/timezone)" "$final_path/infcloud/config.js"
|
|
|
|
|
|
|
|
# Optional parameters from config-panel feature
|
|
|
|
if [ -n "$firstdayofweek" ]; then
|
|
|
|
ynh_replace_string "\(^var globalDatepickerFirstDayOfWeek=\).*" "\1$firstdayofweek;" "$final_path/infcloud/config.js"
|
|
|
|
fi
|
|
|
|
if [ -n "$activeview" ]; then
|
|
|
|
ynh_replace_string "\(^var globalActiveView=\).*" "\1\'$activeview\';" "$final_path/infcloud/config.js"
|
|
|
|
fi
|
|
|
|
if [ -n "$openformmode" ]; then
|
|
|
|
ynh_replace_string "\(^var globalOpenFormMode=\).*" "\1\'$openformmode\';" "$final_path/infcloud/config.js"
|
|
|
|
fi
|
|
|
|
if [ -n "$startofbusiness" ]; then
|
|
|
|
ynh_replace_string "\(^var globalCalendarStartOfBusiness=\).*" "\1$startofbusiness;" "$final_path/infcloud/config.js"
|
|
|
|
fi
|
|
|
|
if [ -n "$endofbusiness" ]; then
|
|
|
|
ynh_replace_string "\(^var globalCalendarEndOfBusiness=\).*" "\1$endofbusiness;" "$final_path/infcloud/config.js"
|
|
|
|
fi
|
|
|
|
if [ -n "$defaulteventduration" ]; then
|
|
|
|
ynh_replace_string "\(^var globalDefaultEventDuration=\).*" "\1$defaulteventduration;" "$final_path/infcloud/config.js"
|
|
|
|
fi
|
2019-01-18 21:12:58 +01:00
|
|
|
# Recalculate and store the checksum of the file for the next upgrade.
|
|
|
|
ynh_store_file_checksum "$final_path/infcloud/config.js"
|
2018-09-29 23:37:05 +02:00
|
|
|
|
|
|
|
# Fix permission
|
|
|
|
chown -R radicale: $final_path
|
|
|
|
|
|
|
|
# Create php-fpm configuration
|
|
|
|
(cd scripts; ynh_add_fpm_config)
|
|
|
|
|
|
|
|
# Setup SSOWat
|
2019-01-18 21:12:58 +01:00
|
|
|
# Add /infcloud to the path of radicale to access it from the portal
|
|
|
|
# Replace radicale by InfCloud into YunoHost portal
|
2018-09-29 23:37:05 +02:00
|
|
|
ynh_app_setting_set $app path ${path_url%/}/infcloud
|
2019-01-18 21:12:58 +01:00
|
|
|
# Protect InfCloud access
|
2018-09-29 23:37:05 +02:00
|
|
|
ynh_app_setting_set $app protected_uris "/"
|
|
|
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
2019-01-18 21:12:58 +01:00
|
|
|
# Radicale is always accessible (For access to ressources)
|
2018-09-29 23:37:05 +02:00
|
|
|
ynh_app_setting_set $app skipped_regex "$domain_regex$path_url"
|
|
|
|
# Remove the previous entry for unprotected_uris
|
|
|
|
ynh_app_setting_delete $app unprotected_uris
|
|
|
|
|
|
|
|
else
|
|
|
|
# Remove InfCloud
|
|
|
|
|
|
|
|
# Get settings
|
|
|
|
path_url=$(dirname $(ynh_app_setting_get $app path))
|
|
|
|
|
|
|
|
# Remove InfCloud
|
|
|
|
ynh_secure_remove "$final_path/infcloud"
|
|
|
|
|
|
|
|
# Remove php-fpm configuration
|
|
|
|
ynh_remove_fpm_config
|
|
|
|
|
|
|
|
# Setup SSOWat
|
2019-01-18 21:12:58 +01:00
|
|
|
# Replace InfCloud by radicale into YunoHost portal
|
2018-09-29 23:37:05 +02:00
|
|
|
ynh_app_setting_set $app path $path_url
|
|
|
|
# Remove the previous entry for protected_uris and skipped_regex
|
|
|
|
ynh_app_setting_delete $app protected_uris
|
|
|
|
ynh_app_setting_delete $app skipped_regex
|
|
|
|
|
2019-01-18 21:12:58 +01:00
|
|
|
# Radicale is always accessible (For access to ressources)
|
2018-09-29 23:37:05 +02:00
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
|
|
|
fi
|
|
|
|
|
2019-01-30 19:16:04 +01:00
|
|
|
ynh_script_progression --message="Reconfigure SSOwat"
|
2018-09-29 23:37:05 +02:00
|
|
|
# Regen ssowat configuration
|
|
|
|
yunohost app ssowatconf
|
|
|
|
|
|
|
|
# Update the config of the app
|
|
|
|
ynh_app_setting_set $app infcloud $infcloud
|
2019-01-30 19:16:04 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Execution completed" --last
|