1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/radicale_ynh.git synced 2024-09-03 20:16:14 +02:00

Merge pull request #13 from YunoHost-Apps/testing

Testing
This commit is contained in:
Maniack Crudelis 2018-09-29 23:39:10 +02:00 committed by GitHub
commit e535674893
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 917 additions and 59 deletions

55
actions.json Normal file
View file

@ -0,0 +1,55 @@
[{
"id": "add_remove_infcloud",
"name": "Install/remove InfCloud",
"command": "/bin/bash scripts/actions/add_remove_infcloud",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Install or remove InfCloud.",
"fr": "Installe ou supprime InfCloud."
}
},
{
"id": "reset_default_infcloud",
"name": "Reset the InfCloud config file and restore a default one.",
"command": "/bin/bash scripts/actions/reset_default_config \"infcloud\"",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Reset the InfCloud config file config.js.",
"fr": "Réinitialise le fichier de configuration InfCloud config.js."
}
},
{
"id": "reset_default_config",
"name": "Reset the config file and restore a default one.",
"command": "/bin/bash scripts/actions/reset_default_config \"config\"",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Reset the config file config.",
"fr": "Réinitialise le fichier de configuration config."
}
},
{
"id": "reset_default_logging",
"name": "Reset the logging file and restore a default one.",
"command": "/bin/bash scripts/actions/reset_default_config \"logging\"",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Reset the config file logging.",
"fr": "Réinitialise le fichier de configuration logging."
}
},
{
"id": "reset_default_rights",
"name": "Reset the rights file and restore a default one.",
"command": "/bin/bash scripts/actions/reset_default_config \"rights\"",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Reset the config file rights.",
"fr": "Réinitialise le fichier de configuration rights."
}
}]

105
config_panel.json Normal file
View file

@ -0,0 +1,105 @@
{
"name": "Radicale configuration panel",
"version": "0.1",
"panel": [{
"name": "Radicale configuration",
"id": "main",
"sections": [{
"name": "InfCloud configuration",
"id": "infcloud_configuration",
"options": [{
"name": "Choose your interface language",
"help": "We can't use a choices field for now. In the meantime please choose between one of this values:<br>Czech, Danish, German, English/US, Spanish, French, Italian, Japan, Hungarian, Dutch, Slovak, Turkish, Russian, Ukrainian, Chinese.",
"id": "language",
"type": "text",
"//": "\"choices\" : [\"Czech\", \"Danish\", \"German\", \"English/US\", \"Spanish\", \"French\", \"Italian\", \"Japan\", \"Hungarian\", \"Dutch\", \"Slovak\", \"Turkish\", \"Russian\", \"Ukrainian\", \"Chinese\"]",
"default" : "English/US"
},
{
"name": "First day of the week ?",
"help": "We can't use a choices field for now. In the meantime please choose between one of this values:<br>Sunday, Monday.",
"id": "firstdayofweek",
"type": "text",
"//": "\"choices\" : [\"Sunday\", \"Monday\"]",
"default" : "Monday"
},
{
"name": "Default calendar view ?",
"help": "We can't use a choices field for now. In the meantime please choose between one of this values:<br>month, multiWeek, agendaWeek, agendaDay.",
"id": "activeview",
"type": "text",
"//": "\"choices\" : [\"month\", \"multiWeek\", \"agendaWeek\", \"agendaDay\"]",
"default" : "agendaWeek"
},
{
"name": "New event on single or double click ?",
"help": "We can't use a choices field for now. In the meantime please choose between one of this values:<br>single, double.",
"id": "openformmode",
"type": "text",
"//": "\"choices\" : [\"single\", \"double\"]",
"default" : "double"
},
{
"name": "Start of business hour ?",
"help": "Non-business hours are faded out in the calendar interface.",
"id": "startofbusiness",
"type": "number",
"default": 8
},
{
"name": "End of business hour ?",
"help": "Non-business hours are faded out in the calendar interface.",
"id": "endofbusiness",
"type": "number",
"default": 18
},
{
"name": "Default event duration ?",
"help": "In minutes.",
"id": "defaulteventduration",
"type": "number",
"default": 120
}]
},
{
"name": "Overwriting config files",
"id": "overwrite_files",
"options": [{
"name": "Overwrite the config file logging ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_logging",
"type": "bool",
"default": true
},
{
"name": "Overwrite the config file config ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_config",
"type": "bool",
"default": true
},
{
"name": "Overwrite the InfCloud config file config.js ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_infcloud",
"type": "bool",
"default": true
},
{
"name": "Overwrite the nginx config file ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_nginx",
"type": "bool",
"default": true
},
{
"name": "Overwrite the php-fpm config file ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_phpfpm",
"type": "bool",
"default": true
}]
}]
}
]
}

View file

@ -30,6 +30,24 @@ IS_PACKAGE_CHECK () {
return $(env | grep -c container=lxc)
}
#=================================================
# BOOLEAN CONVERTER
#=================================================
bool_to_01 () {
local var="$1"
[ "$var" = "true" ] && var=1
[ "$var" = "false" ] && var=0
echo "$var"
}
bool_to_true_false () {
local var="$1"
[ "$var" = "1" ] && var=true
[ "$var" = "0" ] && var=false
echo "$var"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -1,4 +1,4 @@
#!/bin/bash
# Dependencies
app_depencencies="python-pip python-virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev uwsgi uwsgi-plugin-python"
app_depencencies="python-pip python-virtualenv virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev uwsgi uwsgi-plugin-python"

View file

@ -0,0 +1,170 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
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
ynh_print_info "InfCloud will be removed." >&2
infcloud=0
else
ynh_print_info "InfCloud will be installed." >&2
infcloud=1
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# INSTALL OR REMOVE INFCLOUD
#=================================================
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)
# Ajoute InfCloud dans la config Nginx
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")
# Configuration de InfCloud
# Détermine la langue
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
ynh_store_file_checksum "$final_path/infcloud/config.js" # Réenregistre la somme de contrôle du fichier de config
# Fix permission
chown -R radicale: $final_path
# Create php-fpm configuration
(cd scripts; ynh_add_fpm_config)
# Setup SSOWat
# /infcloud vient se rajouter à l'adresse de radicale pour y être associé sur le portail.
# Remplace radicale par InfCloud dans le portail Yunohost
ynh_app_setting_set $app path ${path_url%/}/infcloud
# Protège l'accès à infcloud
ynh_app_setting_set $app protected_uris "/"
domain_regex=$(echo "$domain" | sed 's@-@.@g')
# Radicale est accessible librement (pour l'accès distant aux ressources)
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
# Remplace InfCloud par radicale dans le portail Yunohost
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
# Radicale est accessible librement (pour l'accès distant aux ressources)
ynh_app_setting_set $app unprotected_uris "/"
fi
# Regen ssowat configuration
yunohost app ssowatconf
# Update the config of the app
ynh_app_setting_set $app infcloud $infcloud

View file

@ -0,0 +1,148 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path)
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)
#=================================================
# SORT OUT THE CONFIG FILE TO HANDLE
#=================================================
file="$1"
if [ "$file" = "infcloud" ]; then
config_file="$final_path/infcloud/config.js"
elif [ "$file" = "config" ]; then
config_file="/etc/$app/config"
elif [ "$file" = "logging" ]; then
config_file="/etc/$app/logging"
elif [ "$file" = "rights" ]; then
config_file="/etc/$app/rights"
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# RESET THE CONFIG FILE
#=================================================
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$config_file"
if [ "$file" = "infcloud" ]
then
# Get the default file and overwrite the current config
cp /etc/yunohost/apps/$app/conf/config.js "$config_file"
# Recreate the default config
# Détermine la langue
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
ynh_replace_string "__DOMAIN__" "$domain" "$config_file"
ynh_replace_string "__PATH__" "${path_url%/}" "$config_file"
ynh_replace_string "__LANG__" "$language" "$config_file"
ynh_replace_string "__ADMIN__" "$admin" "$config_file"
ynh_replace_string "__TIMEZONE__" "$(cat /etc/timezone)" "$config_file"
# Optional parameters from config-panel feature
if [ -n "$firstdayofweek" ]; then
ynh_replace_string "\(^var globalDatepickerFirstDayOfWeek=\).*" "\1$firstdayofweek;" "$config_file"
fi
if [ -n "$activeview" ]; then
ynh_replace_string "\(^var globalActiveView=\).*" "\1\'$activeview\';" "$config_file"
fi
if [ -n "$openformmode" ]; then
ynh_replace_string "\(^var globalOpenFormMode=\).*" "\1\'$openformmode\';" "$config_file"
fi
if [ -n "$startofbusiness" ]; then
ynh_replace_string "\(^var globalCalendarStartOfBusiness=\).*" "\1$startofbusiness;" "$config_file"
fi
if [ -n "$endofbusiness" ]; then
ynh_replace_string "\(^var globalCalendarEndOfBusiness=\).*" "\1$endofbusiness;" "$config_file"
fi
if [ -n "$defaulteventduration" ]; then
ynh_replace_string "\(^var globalDefaultEventDuration=\).*" "\1$defaulteventduration;" "$config_file"
fi
fi
if [ "$file" = "config" ]
then
# Get the default file and overwrite the current config
cp /etc/yunohost/apps/$app/conf/config "$config_file"
# Recreate the default config
ynh_replace_string "__PATH__" "${path_url%/}" "$config_file"
ynh_replace_string "__FINALPATH__" "$final_path" "$config_file"
fi
if [ "$file" = "logging" ]
then
# Get the default file and overwrite the current config
cp /etc/yunohost/apps/$app/conf/logging "$config_file"
fi
if [ "$file" = "rights" ]
then
# Get the default file and overwrite the current config
cp /etc/yunohost/apps/$app/conf/rights "$config_file"
fi
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config_file"
# Restart uwsgi to restart radicale
ynh_system_reload --service_name=uwsgi --action=restart

265
scripts/config Normal file
View file

@ -0,0 +1,265 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
# Load common variables for all scripts.
source _variables
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# SPECIFIC CODE
#=================================================
# DECLARE GENERIC FUNCTION
#=================================================
config_file="$final_path/infcloud/config.js"
get_config_value() {
option_name="$1"
# Get the value of this option in the config file
grep "^var $option_name=" "$config_file" | cut -d'=' -f2 | cut -d';' -f1 | cut -d\' -f2
}
#=================================================
# LOAD VALUES
#=================================================
# Load the real value from the app config or elsewhere.
# Then get the value from the form.
# If the form has a value for a variable, take the value from the form,
# Otherwise, keep the value from the app config.
# language
old_language="$(ynh_app_setting_get $app language)"
language="${YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_LANGUAGE:-$old_language}"
# firstdayofweek
old_firstdayofweek="$(get_config_value globalDatepickerFirstDayOfWeek)"
firstdayofweek="${YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_FIRSTDAYOFWEEK:-$old_firstdayofweek}"
# activeview
old_activeview="$(get_config_value globalActiveView)"
activeview="${YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_ACTIVEVIEW:-$old_activeview}"
# openformmode
old_openformmode="$(get_config_value globalOpenFormMode)"
openformmode="${YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_OPENFORMMODE:-$old_openformmode}"
# startofbusiness
old_startofbusiness="$(get_config_value globalCalendarStartOfBusiness)"
startofbusiness="${YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_STARTOFBUSINESS:-$old_startofbusiness}"
# endofbusiness
old_endofbusiness="$(get_config_value globalCalendarEndOfBusiness)"
endofbusiness="${YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_ENDOFBUSINESS:-$old_endofbusiness}"
# defaulteventduration
old_defaulteventduration="$(get_config_value globalDefaultEventDuration)"
defaulteventduration="${YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_DEFAULTEVENTDURATION:-$old_defaulteventduration}"
# Overwrite logging file
old_overwrite_logging="$(ynh_app_setting_get $app overwrite_logging)"
old_overwrite_logging=$(bool_to_true_false $old_overwrite_logging)
overwrite_logging="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_LOGGING:-$old_overwrite_logging}"
# Overwrite config file
old_overwrite_config="$(ynh_app_setting_get $app overwrite_config)"
old_overwrite_config=$(bool_to_true_false $old_overwrite_config)
overwrite_config="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CONFIG:-$old_overwrite_config}"
# Overwrite config.js file from InfCloud
old_overwrite_infcloud="$(ynh_app_setting_get $app overwrite_infcloud)"
old_overwrite_infcloud=$(bool_to_true_false $old_overwrite_infcloud)
overwrite_infcloud="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_INFCLOUD:-$old_overwrite_infcloud}"
# Overwrite nginx configuration
old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)"
old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx)
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
# Overwrite php-fpm configuration
old_overwrite_phpfpm="$(ynh_app_setting_get $app overwrite_phpfpm)"
old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm)
overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}"
#=================================================
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
#=================================================
show_config() {
# here you are supposed to read some config file/database/other then print the values
# echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
case "$language" in
"cs_CZ") language="Czech"
;;
"da_DK") language="Danish"
;;
"de_DE") language="German"
;;
"en_US") language="English/US"
;;
"es_ES") language="Spanish"
;;
"fr_FR") language="French"
;;
"it_IT") language="Italian"
;;
"ja_JP") language="Japan"
;;
"hu_HU") language="Hungarian"
;;
"nl_NL") language="Dutch"
;;
"sk_SK") language="Slovak"
;;
"tr_TR") language="Turkish"
;;
"ru_RU") language="Russian"
;;
"uk_UA") language="Ukrainian"
;;
"zh_CN") language="Chinese"
;;
esac
echo "YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_LANGUAGE=$language"
if [ $firstdayofweek -eq 0 ]; then
firstdayofweek=Sunday
else
firstdayofweek=Monday
fi
echo "YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_FIRSTDAYOFWEEK=$firstdayofweek"
echo "YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_ACTIVEVIEW=$activeview"
echo "YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_OPENFORMMODE=$openformmode"
echo "YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_STARTOFBUSINESS=$startofbusiness"
echo "YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_ENDOFBUSINESS=$endofbusiness"
echo "YNH_CONFIG_MAIN_INFCLOUD_CONFIGURATION_DEFAULTEVENTDURATION=$defaulteventduration"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_LOGGING=$overwrite_logging"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CONFIG=$overwrite_config"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_INFCLOUD=$overwrite_infcloud"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
}
#=================================================
# MODIFY THE CONFIGURATION
#=================================================
apply_config() {
# Change configuration if needed
# language
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
if [ "$language" != "$old_language" ]
then
ynh_replace_string "\(^var globalInterfaceLanguage=\).*" "\1\'$language\';" "$config_file"
ynh_app_setting_set $app language "$language"
fi
# firstdayofweek
if [ "$firstdayofweek" = "Sunday" ]; then
firstdayofweek=0
else
firstdayofweek=1
fi
if [ "$firstdayofweek" != "$old_firstdayofweek" ]
then
ynh_replace_string "\(^var globalDatepickerFirstDayOfWeek=\).*" "\1$firstdayofweek;" "$config_file"
ynh_app_setting_set $app firstdayofweek "$firstdayofweek"
fi
# activeview
if [ "$activeview" != "$old_activeview" ]
then
ynh_replace_string "\(^var globalActiveView=\).*" "\1\'$activeview\';" "$config_file"
ynh_app_setting_set $app activeview "$activeview"
fi
# openformmode
if [ "$openformmode" != "$old_openformmode" ]
then
ynh_replace_string "\(^var globalOpenFormMode=\).*" "\1\'$openformmode\';" "$config_file"
ynh_app_setting_set $app openformmode "$openformmode"
fi
# startofbusiness
if [ "$startofbusiness" != "$old_startofbusiness" ]
then
ynh_replace_string "\(^var globalCalendarStartOfBusiness=\).*" "\1$startofbusiness;" "$config_file"
ynh_app_setting_set $app startofbusiness "$startofbusiness"
fi
# endofbusiness
if [ "$endofbusiness" != "$old_endofbusiness" ]
then
ynh_replace_string "\(^var globalCalendarEndOfBusiness=\).*" "\1$endofbusiness;" "$config_file"
ynh_app_setting_set $app endofbusiness "$endofbusiness"
fi
# defaulteventduration
if [ "$defaulteventduration" != "$old_defaulteventduration" ]
then
ynh_replace_string "\(^var globalDefaultEventDuration=\).*" "\1$defaulteventduration;" "$config_file"
ynh_app_setting_set $app defaulteventduration "$defaulteventduration"
fi
# Set overwrite_logging
overwrite_logging=$(bool_to_01 $overwrite_logging)
ynh_app_setting_set $app overwrite_logging "$overwrite_logging"
# Set overwrite_config
overwrite_config=$(bool_to_01 $overwrite_config)
ynh_app_setting_set $app overwrite_config "$overwrite_config"
# Set overwrite_infcloud
overwrite_infcloud=$(bool_to_01 $overwrite_infcloud)
ynh_app_setting_set $app overwrite_infcloud "$overwrite_infcloud"
# Set overwrite_nginx
overwrite_nginx=$(bool_to_01 $overwrite_nginx)
ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
# Set overwrite_phpfpm
overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm)
ynh_app_setting_set $app overwrite_phpfpm "$overwrite_phpfpm"
}
#=================================================
# GENERIC FINALIZATION
#=================================================
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
#=================================================
case $1 in
show) show_config;;
apply) apply_config;;
esac

View file

@ -55,6 +55,11 @@ ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app infcloud $infcloud
ynh_app_setting_set $app version $version
ynh_app_setting_set $app overwrite_logging "1"
ynh_app_setting_set $app overwrite_config "1"
ynh_app_setting_set $app overwrite_infcloud "1"
ynh_app_setting_set $app overwrite_nginx "1"
ynh_app_setting_set $app overwrite_phpfpm "1"
#=================================================
# STANDARD MODIFICATIONS

View file

@ -22,6 +22,19 @@ infcloud=$(ynh_app_setting_get $app infcloud)
language=$(ynh_app_setting_get $app language)
final_path=$(ynh_app_setting_get $app final_path)
version=$(ynh_app_setting_get $app version)
overwrite_logging=$(ynh_app_setting_get $app overwrite_logging)
overwrite_config=$(ynh_app_setting_get $app overwrite_config)
overwrite_infcloud=$(ynh_app_setting_get $app overwrite_infcloud)
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
overwrite_phpfpm=$(ynh_app_setting_get $app overwrite_phpfpm)
# 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)
#=================================================
# CHECK VERSION
@ -55,6 +68,36 @@ elif [ "$infcloud" = "No" ]; then
infcloud=0
fi
# If overwrite_logging doesn't exist, create it
if [ -z "$overwrite_logging" ]; then
overwrite_logging=1
ynh_app_setting_set $app overwrite_logging $overwrite_logging
fi
# If overwrite_config doesn't exist, create it
if [ -z "$overwrite_config" ]; then
overwrite_config=1
ynh_app_setting_set $app overwrite_config $overwrite_config
fi
# If overwrite_infcloud doesn't exist, create it
if [ -z "$overwrite_infcloud" ]; then
overwrite_infcloud=1
ynh_app_setting_set $app overwrite_infcloud $overwrite_infcloud
fi
# If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1
ynh_app_setting_set $app overwrite_nginx $overwrite_nginx
fi
# If overwrite_phpfpm doesn't exist, create it
if [ -z "$overwrite_phpfpm" ]; then
overwrite_phpfpm=1
ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -89,12 +132,16 @@ ynh_maintenance_mode_ON
# NGINX CONFIGURATION
#=================================================
ynh_add_nginx_config
if [ $infcloud -eq 1 ]
then # Ajoute InfCloud dans la config Nginx
ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf
# Overwrite the nginx configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ]
then
ynh_add_nginx_config
if [ $infcloud -eq 1 ]
then # Ajoute InfCloud dans la config Nginx
ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf
fi
ynh_store_file_checksum "$finalnginxconf"
fi
ynh_store_file_checksum "$finalnginxconf"
#=================================================
# CREATE DEDICATED USER
@ -108,7 +155,11 @@ then
# PHP-FPM CONFIGURATION
#=================================================
ynh_add_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure.
# Overwrite the php-fpm configuration only if it's allowed
if [ $overwrite_phpfpm -eq 1 ]
then
ynh_add_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure.
fi
fi
#=================================================
@ -143,7 +194,14 @@ then
then #Instal InfCloud
final_path_backup=$final_path # Sauvegarde le contenu de $final_path
final_path=$final_path/infcloud # Change final_path pour l'installation de infcloud
# If overwrite_infcloud is 0, copy the config file, then restore it.
if [ $overwrite_infcloud -eq 0 ]; then
cp -a $final_path/config.js ./config.js
fi
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
if [ $overwrite_infcloud -eq 0 ]; then
mv ./config.js $final_path/config.js
fi
final_path=$final_path_backup # Restaure le contenu de $final_path
fi
fi
@ -152,58 +210,92 @@ fi
# CONFIGURE RADICALE
#=================================================
ynh_backup_if_checksum_is_different "/etc/$app/config" # Créé un backup du fichier de config si il a été modifié.
cp ../conf/config /etc/$app/
ynh_backup_if_checksum_is_different "/etc/$app/logging" # Créé un backup du fichier de config si il a été modifié.
cp ../conf/logging /etc/$app/
ynh_store_file_checksum "/etc/$app/logging" # Réenregistre la somme de contrôle du fichier de config
ynh_replace_string "__PATH__" "${path_url%/}" /etc/$app/config
ynh_replace_string "__FINALPATH__" "$final_path" /etc/$app/config
ynh_store_file_checksum "/etc/$app/config" # Réenregistre la somme de contrôle du fichier de config
if [ $infcloud -eq 1 ]
then #Configuration InfCloud
# Détermine la langue
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
ynh_app_setting_set $app language $language
ynh_backup_if_checksum_is_different "$final_path/infcloud/config.js" # Créé un backup du fichier de config si il a été modifié.
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"
ynh_store_file_checksum "$final_path/infcloud/config.js" # Réenregistre la somme de contrôle du fichier de config
# Overwrite the logging config file only if it's allowed
if [ $overwrite_logging -eq 1 ]
then
ynh_backup_if_checksum_is_different "/etc/$app/logging" # Créé un backup du fichier de config si il a été modifié.
cp ../conf/logging /etc/$app/
ynh_store_file_checksum "/etc/$app/logging" # Réenregistre la somme de contrôle du fichier de config
fi
# Overwrite the config file only if it's allowed
if [ $overwrite_config -eq 1 ]
then
ynh_backup_if_checksum_is_different "/etc/$app/config" # Créé un backup du fichier de config si il a été modifié.
cp ../conf/config /etc/$app/
ynh_replace_string "__PATH__" "${path_url%/}" /etc/$app/config
ynh_replace_string "__FINALPATH__" "$final_path" /etc/$app/config
ynh_store_file_checksum "/etc/$app/config" # Réenregistre la somme de contrôle du fichier de config
fi
# Overwrite the InfCloud config file only if it's allowed
if [ $overwrite_infcloud -eq 1 ]
then
if [ $infcloud -eq 1 ]
then #Configuration InfCloud
# Détermine la langue
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
ynh_app_setting_set $app language $language
ynh_backup_if_checksum_is_different "$final_path/infcloud/config.js" # Créé un backup du fichier de config si il a été modifié.
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
ynh_store_file_checksum "$final_path/infcloud/config.js" # Réenregistre la somme de contrôle du fichier de config
fi
fi
#=================================================