1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/onlyoffice_ynh.git synced 2024-09-03 19:56:11 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2019-05-20 20:15:10 +02:00
parent b17f0b1128
commit 5096d29455

View file

@ -16,12 +16,12 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get --app=$app --key=is_public)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
nextclouddomain=$(ynh_app_setting_get $app nextclouddomain) nextclouddomain=$(ynh_app_setting_get --app=$app --key=nextclouddomain)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
@ -30,17 +30,17 @@ ynh_print_info --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value # Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1 ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1 is_public=1
elif [ "$is_public" = "No" ]; then elif [ "$is_public" = "No" ]; then
ynh_app_setting_set $app is_public 0 ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0 is_public=0
fi fi
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z $db_name ]; then if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid $app) db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi fi
#================================================= #=================================================
@ -62,7 +62,8 @@ ynh_abort_if_errors
#================================================= #=================================================
# Normalize the URL path syntax # Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
path_url=$(ynh_normalize_url_path --path_url=$path_url)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -71,24 +72,24 @@ path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
ynh_print_info --message="Configuring nginx web server..." ynh_print_info --message="Configuring nginx web server..."
if [ $path_url = "/" ]; then if [ "$path_url" = "/" ]; then
ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf" ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf"
else else
ynh_replace_string "__SUB_PATH__" "$path_url" "../conf/nginx.conf" ynh_replace_string --match_string="__SUB_PATH__" --replace_string="$path_url" --target_file="../conf/nginx.conf"
fi fi
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config "nextclouddomain" ynh_add_nginx_config "nextclouddomain"
# Fix main domain X-Frame-Options # Fix main domain X-Frame-Options
ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf" ynh_replace_string --match_string="X-Frame-Options : SAMEORIGIN" --replace_string="X-Frame-Options : ALLOW-FROM https://$nextclouddomain" --target_file="/etc/nginx/conf.d/$domain.conf"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Upgrading dependencies..." ynh_print_info --message="Upgrading dependencies..."
ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -96,7 +97,7 @@ ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server
ynh_print_info --message="Making sure dedicated system user exists..." ynh_print_info --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create $app $final_path ynh_system_user_create --username=$app
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -121,7 +122,11 @@ echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /e
ynh_print_info --message="Upgrading OnlyOffice..." ynh_print_info --message="Upgrading OnlyOffice..."
wget $source wget $source
apt install -y ./onlyoffice-documentserver_amd64.deb ynh_package_install ./onlyoffice-documentserver_amd64.deb
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
#ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" #ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
@ -130,13 +135,6 @@ apt install -y ./onlyoffice-documentserver_amd64.deb
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
#chown -R root: $final_path
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
@ -146,7 +144,7 @@ ynh_print_info --message="Upgrading SSOwat configuration..."
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway # unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi fi
#================================================= #=================================================
@ -154,7 +152,7 @@ fi
#================================================= #=================================================
ynh_print_info --message="Reloading nginx web server..." ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# RELOAD ONLYOFFICE # RELOAD ONLYOFFICE