#!/bin/bash #================================================= # GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= source scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= ynh_script_progression --message="Retrieve arguments from the manifest" --weight=3 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 #================================================= ynh_script_progression --message="Reset the config file $config_file" --weight=9 # 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 # Set 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 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" ynh_script_progression --message="Restart Radicale" --weight=2 # Restart uwsgi to restart radicale ynh_systemd_action --action=restart --service_name=uwsgi #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Execution completed" --last