mirror of
https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git
synced 2024-09-03 18:36:09 +02:00
Panel-config + actions fully tested
This commit is contained in:
parent
37bb93d4cc
commit
452bae7154
11 changed files with 424 additions and 108 deletions
31
actions.json
31
actions.json
|
@ -30,4 +30,35 @@
|
|||
"en": "List all existing pads.",
|
||||
"fr": "Liste tout les pads existants."
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "reset_default_config",
|
||||
"name": "Reset the config file and restore a default one.",
|
||||
"command": "/bin/bash scripts/actions/reset_default_config \"settings.json\"",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Reset the config file settings.json.",
|
||||
"fr": "Réinitialise le fichier de configuration settings.json."
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "public_private",
|
||||
"name": "Move to public or private",
|
||||
"command": "/bin/bash scripts/actions/public_private",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Change the public access of the app."
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Is it a public app ?"
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}]
|
||||
|
|
|
@ -76,11 +76,43 @@
|
|||
"name": "Public access",
|
||||
"id": "is_public",
|
||||
"options": [{
|
||||
"name": "Is it a public website ?",
|
||||
"name": "Is it a public app ?",
|
||||
"id": "is_public",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "Overwriting config files",
|
||||
"id": "overwrite_files",
|
||||
"options": [{
|
||||
"name": "Overwrite the config file settings.json ?",
|
||||
"help": "If the file is overwritten, a backup will be created.",
|
||||
"id": "overwrite_settings",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "Overwrite the config file credentials.json ?",
|
||||
"help": "If the file is overwritten, a backup will be created.",
|
||||
"id": "overwrite_credentials",
|
||||
"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 systemd config file ?",
|
||||
"help": "If the file is overwritten, a backup will be created.",
|
||||
"id": "overwrite_systemd",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
}]
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -22,6 +22,24 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
|||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
|
|
@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers
|
|||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
|
|
|
@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers
|
|||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
|
|
|
@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers
|
|||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
|
|
58
scripts/actions/public_private
Executable file
58
scripts/actions/public_private
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
# Get is_public
|
||||
is_public=${YNH_ACTION_IS_PUBLIC}
|
||||
|
||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
is_public_old=$(ynh_app_setting_get $app is_public)
|
||||
|
||||
if [ $is_public -eq $is_public_old ]
|
||||
then
|
||||
ynh_die "is_public is already set as $is_public." 0
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# MOVE TO PUBLIC OR PRIVATE
|
||||
#=================================================
|
||||
|
||||
if [ $is_public -eq 0 ]
|
||||
then
|
||||
ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO...
|
||||
else
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
fi
|
||||
|
||||
# Regen ssowat configuration
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Update the config of the app
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
72
scripts/actions/reset_default_config
Executable file
72
scripts/actions/reset_default_config
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/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)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
export=$(ynh_app_setting_get $app export)
|
||||
language=$(ynh_app_setting_get $app language)
|
||||
mypads=$(ynh_app_setting_get $app mypads)
|
||||
useldap=$(ynh_app_setting_get $app useldap)
|
||||
|
||||
#=================================================
|
||||
# SORT OUT THE CONFIG FILE TO HANDLE
|
||||
#=================================================
|
||||
|
||||
file="$1"
|
||||
|
||||
if [ "$file" = "settings.json" ]; then
|
||||
config_file="$final_path/settings.json"
|
||||
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" = "settings.json" ]
|
||||
then
|
||||
# Get the default file and overwrite the current config
|
||||
cp /etc/yunohost/apps/$app/conf/settings.json "$config_file"
|
||||
|
||||
# Recreate the default config
|
||||
ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
|
||||
if [ "$export" = "abiword" ]
|
||||
then
|
||||
abiword_path=`which abiword` # Get abiword binary path
|
||||
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
||||
elif [ "$export" = "libreoffice" ]
|
||||
then
|
||||
soffice_path=`which soffice` # Get soffice binary path
|
||||
ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
||||
fi
|
||||
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
|
||||
|
||||
# Use ldap for mypads
|
||||
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
||||
then
|
||||
ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$config_file"
|
||||
|
||||
# Wait for etherpad to be fully started
|
||||
ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120"
|
144
scripts/config
144
scripts/config
|
@ -15,7 +15,7 @@ source _variables
|
|||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
|
@ -38,60 +38,75 @@ get_config_value() {
|
|||
# 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.
|
||||
# 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.
|
||||
|
||||
# Export
|
||||
old_export="$(ynh_app_setting_get $app export)"
|
||||
export="${YNH_CONFIG_MAIN_EXPORT_EXPORT:-$old_export}"
|
||||
# Export
|
||||
old_export="$(ynh_app_setting_get $app export)"
|
||||
export="${YNH_CONFIG_MAIN_EXPORT_EXPORT:-$old_export}"
|
||||
|
||||
# padOptions noColors
|
||||
old_pad_config_nocolors="$(get_config_value noColors)"
|
||||
pad_config_nocolors="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS:-$old_pad_config_nocolors}"
|
||||
# padOptions showLineNumbers
|
||||
old_pad_config_showlinenumbers="$(get_config_value showLineNumbers)"
|
||||
pad_config_showlinenumbers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS:-$old_pad_config_showlinenumbers}"
|
||||
# padOptions chatAndUsers
|
||||
old_pad_config_chatandusers="$(get_config_value chatAndUsers)"
|
||||
pad_config_chatandusers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS:-$old_pad_config_chatandusers}"
|
||||
# padOptions alwaysShowChat
|
||||
old_pad_config_alwaysshowchat="$(get_config_value alwaysShowChat)"
|
||||
pad_config_alwaysshowchat="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT:-$old_pad_config_alwaysshowchat}"
|
||||
# Plugin option ep_markdown_default
|
||||
old_pad_config_show_markdown="$(get_config_value ep_markdown_default)"
|
||||
pad_config_show_markdown="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN:-$old_pad_config_show_markdown}"
|
||||
# Plugin option ep_page_view_default
|
||||
old_pad_config_pageview="$(get_config_value ep_page_view_default)"
|
||||
pad_config_pageview="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_PAGEVIEW:-$old_pad_config_pageview}"
|
||||
# padOptions noColors
|
||||
old_pad_config_nocolors="$(get_config_value noColors)"
|
||||
pad_config_nocolors="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS:-$old_pad_config_nocolors}"
|
||||
# padOptions showLineNumbers
|
||||
old_pad_config_showlinenumbers="$(get_config_value showLineNumbers)"
|
||||
pad_config_showlinenumbers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS:-$old_pad_config_showlinenumbers}"
|
||||
# padOptions chatAndUsers
|
||||
old_pad_config_chatandusers="$(get_config_value chatAndUsers)"
|
||||
pad_config_chatandusers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS:-$old_pad_config_chatandusers}"
|
||||
# padOptions alwaysShowChat
|
||||
old_pad_config_alwaysshowchat="$(get_config_value alwaysShowChat)"
|
||||
pad_config_alwaysshowchat="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT:-$old_pad_config_alwaysshowchat}"
|
||||
# Plugin option ep_markdown_default
|
||||
old_pad_config_show_markdown="$(get_config_value ep_markdown_default)"
|
||||
pad_config_show_markdown="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN:-$old_pad_config_show_markdown}"
|
||||
# Plugin option ep_page_view_default
|
||||
old_pad_config_pageview="$(get_config_value ep_page_view_default)"
|
||||
pad_config_pageview="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_PAGEVIEW:-$old_pad_config_pageview}"
|
||||
|
||||
# Mypads
|
||||
if [ -d $final_path/node_modules/ep_mypads ]
|
||||
then
|
||||
# Mypads
|
||||
if [ -d $final_path/node_modules/ep_mypads ]
|
||||
then
|
||||
old_mypads=true
|
||||
else
|
||||
else
|
||||
old_mypads=false
|
||||
fi
|
||||
mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}"
|
||||
# Ldap for Mypads
|
||||
if grep -q "//noldap" $config_file
|
||||
then
|
||||
fi
|
||||
mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}"
|
||||
# Ldap for Mypads
|
||||
if grep -q "//noldap" $config_file
|
||||
then
|
||||
old_useldap=false
|
||||
else
|
||||
else
|
||||
old_useldap=true
|
||||
fi
|
||||
useldap="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP:-$old_useldap}"
|
||||
fi
|
||||
useldap="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP:-$old_useldap}"
|
||||
|
||||
# is_public
|
||||
old_is_public="$(ynh_app_setting_get $app is_public)"
|
||||
if [ $old_is_public -eq 1 ]
|
||||
then
|
||||
old_is_public=true
|
||||
else
|
||||
old_is_public=false
|
||||
fi
|
||||
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
|
||||
# is_public
|
||||
old_is_public="$(ynh_app_setting_get $app is_public)"
|
||||
old_is_public=$(bool_to_true_false $old_is_public)
|
||||
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
|
||||
|
||||
# Overwrite settings.json file
|
||||
old_overwrite_settings="$(ynh_app_setting_get $app overwrite_settings)"
|
||||
old_overwrite_settings=$(bool_to_true_false $old_overwrite_settings)
|
||||
overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}"
|
||||
|
||||
# Overwrite credentials.json file
|
||||
old_overwrite_credentials="$(ynh_app_setting_get $app overwrite_credentials)"
|
||||
old_overwrite_credentials=$(bool_to_true_false $old_overwrite_credentials)
|
||||
overwrite_credentials="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS:-$old_overwrite_credentials}"
|
||||
|
||||
# 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 systemd configuration
|
||||
old_overwrite_systemd="$(ynh_app_setting_get $app overwrite_systemd)"
|
||||
old_overwrite_systemd=$(bool_to_true_false $old_overwrite_systemd)
|
||||
overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}"
|
||||
|
||||
#=================================================
|
||||
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
||||
|
@ -114,6 +129,11 @@ show_config() {
|
|||
echo "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap"
|
||||
|
||||
echo "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public"
|
||||
|
||||
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
|
||||
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS=$overwrite_credentials"
|
||||
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -128,6 +148,7 @@ apply_config() {
|
|||
if [ "$pad_config_nocolors" != "$old_pad_config_nocolors" ]
|
||||
then
|
||||
ynh_replace_string "\(\"noColors\" *: \).*," "\1$pad_config_nocolors," "$config_file"
|
||||
ynh_app_setting_set $app pad_config_nocolors "$pad_config_nocolors"
|
||||
restart_etherpad=1
|
||||
fi
|
||||
|
||||
|
@ -135,6 +156,7 @@ apply_config() {
|
|||
if [ "$pad_config_showlinenumbers" != "$old_pad_config_showlinenumbers" ]
|
||||
then
|
||||
ynh_replace_string "\(\"showLineNumbers\" *: \).*," "\1$pad_config_showlinenumbers," "$config_file"
|
||||
ynh_app_setting_set $app pad_config_showlinenumbers "$pad_config_showlinenumbers"
|
||||
restart_etherpad=1
|
||||
fi
|
||||
|
||||
|
@ -142,6 +164,7 @@ apply_config() {
|
|||
if [ "$pad_config_chatandusers" != "$old_pad_config_chatandusers" ]
|
||||
then
|
||||
ynh_replace_string "\(\"chatAndUsers\" *: \).*," "\1$pad_config_chatandusers," "$config_file"
|
||||
ynh_app_setting_set $app pad_config_chatandusers "$pad_config_chatandusers"
|
||||
restart_etherpad=1
|
||||
fi
|
||||
|
||||
|
@ -149,6 +172,7 @@ apply_config() {
|
|||
if [ "$pad_config_alwaysshowchat" != "$old_pad_config_alwaysshowchat" ]
|
||||
then
|
||||
ynh_replace_string "\(\"alwaysShowChat\" *: \).*," "\1$pad_config_alwaysshowchat," "$config_file"
|
||||
ynh_app_setting_set $app pad_config_alwaysshowchat "$pad_config_alwaysshowchat"
|
||||
restart_etherpad=1
|
||||
fi
|
||||
|
||||
|
@ -156,6 +180,7 @@ apply_config() {
|
|||
if [ "$pad_config_show_markdown" != "$old_pad_config_show_markdown" ]
|
||||
then
|
||||
ynh_replace_string "\(\"ep_markdown_default\" *: \).*," "\1$pad_config_show_markdown," "$config_file"
|
||||
ynh_app_setting_set $app pad_config_show_markdown "$pad_config_show_markdown"
|
||||
restart_etherpad=1
|
||||
fi
|
||||
|
||||
|
@ -163,6 +188,7 @@ apply_config() {
|
|||
if [ "$pad_config_pageview" != "$old_pad_config_pageview" ]
|
||||
then
|
||||
ynh_replace_string "\(\"ep_page_view_default\" *: \).*," "\1$pad_config_pageview," "$config_file"
|
||||
ynh_app_setting_set $app pad_config_pageview "$pad_config_pageview"
|
||||
restart_etherpad=1
|
||||
fi
|
||||
|
||||
|
@ -232,17 +258,23 @@ apply_config() {
|
|||
# Change public accessibility
|
||||
if [ "$is_public" = "true" ]
|
||||
then
|
||||
is_public=1
|
||||
yunohost app action run $app public_private --args is_public=1
|
||||
else
|
||||
is_public=0
|
||||
yunohost app action run $app public_private --args is_public=0
|
||||
fi
|
||||
if [ $is_public -eq 1 ]; then
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
else
|
||||
ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO...
|
||||
fi
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Set overwrite_settings
|
||||
overwrite_settings=$(bool_to_01 $overwrite_settings)
|
||||
ynh_app_setting_set $app overwrite_settings "$overwrite_settings"
|
||||
# Set overwrite_credentials
|
||||
overwrite_credentials=$(bool_to_01 $overwrite_credentials)
|
||||
ynh_app_setting_set $app overwrite_credentials "$overwrite_credentials"
|
||||
# Set overwrite_nginx
|
||||
overwrite_nginx=$(bool_to_01 $overwrite_nginx)
|
||||
ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
|
||||
# Set overwrite_systemd
|
||||
overwrite_systemd=$(bool_to_01 $overwrite_systemd)
|
||||
ynh_app_setting_set $app overwrite_systemd "$overwrite_systemd"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -72,6 +72,10 @@ ynh_app_setting_set $app language $language
|
|||
ynh_app_setting_set $app export $export
|
||||
ynh_app_setting_set $app mypads $mypads
|
||||
ynh_app_setting_set $app useldap $useldap
|
||||
ynh_app_setting_set $app overwrite_settings "1"
|
||||
ynh_app_setting_set $app overwrite_credentials "1"
|
||||
ynh_app_setting_set $app overwrite_nginx "1"
|
||||
ynh_app_setting_set $app overwrite_systemd "1"
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
|
|
143
scripts/upgrade
143
scripts/upgrade
|
@ -28,6 +28,17 @@ export=$(ynh_app_setting_get $app export)
|
|||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
mypads=$(ynh_app_setting_get $app mypads)
|
||||
useldap=$(ynh_app_setting_get $app useldap)
|
||||
overwrite_settings=$(ynh_app_setting_get $app overwrite_settings)
|
||||
overwrite_credentials=$(ynh_app_setting_get $app overwrite_credentials)
|
||||
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
|
||||
overwrite_systemd=$(ynh_app_setting_get $app overwrite_systemd)
|
||||
|
||||
# Optional parameters from config-panel feature
|
||||
pad_config_nocolors=$(ynh_app_setting_get $app pad_config_nocolors)
|
||||
pad_config_showlinenumbers=$(ynh_app_setting_get $app pad_config_showlinenumbers)
|
||||
pad_config_chatandusers=$(ynh_app_setting_get $app pad_config_chatandusers)
|
||||
pad_config_alwaysshowchat=$(ynh_app_setting_get $app pad_config_alwaysshowchat)
|
||||
pad_config_show_markdown=$(ynh_app_setting_get $app pad_config_show_markdown)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -39,7 +50,7 @@ ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/eth
|
|||
ynh_abort_if_up_to_date
|
||||
|
||||
#=================================================
|
||||
# FIX OLD THINGS
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
|
@ -50,17 +61,17 @@ elif [ "$is_public" = "No" ]; then
|
|||
is_public=0
|
||||
fi
|
||||
|
||||
if [ -z $db_name ]; then # If db_name setting doesn't exist
|
||||
if [ -z "$db_name" ]; then # If db_name setting doesn't exist
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
fi
|
||||
|
||||
if [ -z $abiword ]; then # If abiword setting doesn't exist
|
||||
if [ -z "$abiword" ]; then # If abiword setting doesn't exist
|
||||
abiword=0
|
||||
ynh_app_setting_set $app abiword $abiword
|
||||
fi
|
||||
|
||||
if [ -n $abiword ]; then # If abiword setting exists
|
||||
if [ -n "$abiword" ]; then # If abiword setting exists
|
||||
if [ $abiword -eq 1 ]; then
|
||||
export=abiword
|
||||
fi
|
||||
|
@ -68,26 +79,50 @@ if [ -n $abiword ]; then # If abiword setting exists
|
|||
ynh_app_setting_delete $app abiword
|
||||
fi
|
||||
|
||||
if [ -z $export ]; then # If export setting doesn't exist
|
||||
if [ -z "$export" ]; then # If export setting doesn't exist
|
||||
export=none
|
||||
ynh_app_setting_set $app export $export
|
||||
fi
|
||||
|
||||
if [ -z $mypads ]; then # If mypads setting doesn't exist
|
||||
if [ -z "$mypads" ]; then # If mypads setting doesn't exist
|
||||
mypads=1
|
||||
ynh_app_setting_set $app mypads $mypads
|
||||
fi
|
||||
|
||||
if [ -z $useldap ]; then # If useldap setting doesn't exist
|
||||
if [ -z "$useldap" ]; then # If useldap setting doesn't exist
|
||||
useldap=0
|
||||
ynh_app_setting_set $app useldap $useldap
|
||||
fi
|
||||
|
||||
if [ -z $path_url ]; then # If path_url setting doesn't exist
|
||||
if [ -z "$path_url" ]; then # If path_url setting doesn't exist
|
||||
path_url="/"
|
||||
ynh_app_setting_set $app path $path_url
|
||||
fi
|
||||
|
||||
# If overwrite_settings doesn't exist, create it
|
||||
if [ -z "$overwrite_settings" ]; then
|
||||
overwrite_settings=1
|
||||
ynh_app_setting_set $app overwrite_settings $overwrite_settings
|
||||
fi
|
||||
|
||||
# If overwrite_credentials doesn't exist, create it
|
||||
if [ -z "$overwrite_credentials" ]; then
|
||||
overwrite_credentials=1
|
||||
ynh_app_setting_set $app overwrite_credentials $overwrite_credentials
|
||||
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_systemd doesn't exist, create it
|
||||
if [ -z "$overwrite_systemd" ]; then
|
||||
overwrite_systemd=1
|
||||
ynh_app_setting_set $app overwrite_systemd $overwrite_systemd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -128,12 +163,16 @@ ynh_setup_source "$final_path" # Download, check integrity and uncompress the so
|
|||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [ "$path_url" != "/" ]
|
||||
# Overwrite the nginx configuration only if it's allowed
|
||||
if [ $overwrite_nginx -eq 1 ]
|
||||
then
|
||||
if [ "$path_url" != "/" ]
|
||||
then
|
||||
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
|
||||
fi
|
||||
ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf"
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf"
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE NODEJS
|
||||
|
@ -172,40 +211,66 @@ done <<< "$(ls -1 "$final_path/node_modules" | grep "^ep_")")
|
|||
# CONFIGURE ETHERPAD
|
||||
#=================================================
|
||||
|
||||
ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Verify the checksum and backup the file if it's different
|
||||
cp ../conf/settings.json "$final_path/settings.json"
|
||||
cp ../conf/credentials.json "$final_path/credentials.json"
|
||||
ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
|
||||
ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json"
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json"
|
||||
ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON
|
||||
if [ "$export" = "abiword" ]
|
||||
# Overwrite the settings config file only if it's allowed
|
||||
if [ $overwrite_settings -eq 1 ]
|
||||
then
|
||||
ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different
|
||||
cp ../conf/settings.json "$final_path/settings.json"
|
||||
ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
|
||||
if [ "$export" = "abiword" ]
|
||||
then
|
||||
abiword_path=`which abiword` # Get abiword binary path
|
||||
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
||||
elif [ "$export" = "libreoffice" ]
|
||||
then
|
||||
elif [ "$export" = "libreoffice" ]
|
||||
then
|
||||
soffice_path=`which soffice` # Get soffice binary path
|
||||
ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
||||
fi
|
||||
if test -z $language; then
|
||||
fi
|
||||
if test -z $language; then
|
||||
language=en # If upgrading from a version which doesn't support translations, set language to English by default
|
||||
ynh_app_setting_set $app language $language
|
||||
fi
|
||||
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
|
||||
|
||||
# Use ldap for mypads
|
||||
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
||||
then
|
||||
fi
|
||||
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
|
||||
# Use ldap for mypads
|
||||
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
||||
then
|
||||
ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json"
|
||||
fi
|
||||
|
||||
# Optional parameters from config-panel feature
|
||||
if [ -n "$pad_config_nocolors" ]; then
|
||||
ynh_replace_string "\(\"noColors\" *: \).*," "\1$pad_config_nocolors," "$final_path/settings.json"
|
||||
fi
|
||||
if [ -n "$pad_config_showlinenumbers" ]; then
|
||||
ynh_replace_string "\(\"showLineNumbers\" *: \).*," "\1$pad_config_showlinenumbers," "$final_path/settings.json"
|
||||
fi
|
||||
if [ -n "$pad_config_chatandusers" ]; then
|
||||
ynh_replace_string "\(\"chatAndUsers\" *: \).*," "\1$pad_config_chatandusers," "$final_path/settings.json"
|
||||
fi
|
||||
if [ -n "$pad_config_alwaysshowchat" ]; then
|
||||
ynh_replace_string "\(\"alwaysShowChat\" *: \).*," "\1$pad_config_alwaysshowchat," "$final_path/settings.json"
|
||||
fi
|
||||
if [ -n "$pad_config_show_markdown" ]; then
|
||||
ynh_replace_string "\(\"ep_markdown_default\" *: \).*," "\1$pad_config_show_markdown," "$final_path/settings.json"
|
||||
fi
|
||||
|
||||
ynh_store_file_checksum "$final_path/settings.json" # Recalculate and store the config file checksum into the app settings
|
||||
fi
|
||||
|
||||
ynh_store_file_checksum "$final_path/settings.json" # Recalculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$final_path/credentials.json" # Recalculate and store the config file checksum into the app settings
|
||||
# Overwrite the credentials config file only if it's allowed
|
||||
if [ $overwrite_credentials -eq 1 ]
|
||||
then
|
||||
ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Verify the checksum and backup the file if it's different
|
||||
cp ../conf/credentials.json "$final_path/credentials.json"
|
||||
ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json"
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json"
|
||||
ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON
|
||||
|
||||
ynh_store_file_checksum "$final_path/credentials.json" # Recalculate and store the config file checksum into the app settings
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -238,8 +303,12 @@ ynh_use_logrotate --non-append
|
|||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
||||
ynh_add_systemd_config
|
||||
# Overwrite the systemd configuration only if it's allowed
|
||||
if [ $overwrite_systemd -eq 1 ]
|
||||
then
|
||||
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
||||
ynh_add_systemd_config
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SOME HACKS
|
||||
|
|
Loading…
Add table
Reference in a new issue