1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/onlyoffice_ynh.git synced 2024-09-03 19:56:11 +02:00
This commit is contained in:
yalh76 2020-06-02 21:46:04 +02:00
parent 5a57f1d7f4
commit cc7787ce1e
6 changed files with 55 additions and 35 deletions

View file

@ -10,6 +10,6 @@ location ^~ __PATH__/ {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
add_header X-Frame-Options "ALLOW-FROM https://__NEXTCLOUDDOMAIN__" always;
more_set_headers "X-Frame-Options : ALLOW-FROM https://__NEXTCLOUDDOMAIN__ always";
client_max_body_size 10M;
}

View file

@ -35,6 +35,23 @@ nextclouddomain=$(ynh_app_setting_get --app=$app --key=nextclouddomain)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
@ -87,8 +104,6 @@ then
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_replace_string --match_string="X-Frame-Options : ALLOW-FROM https://$nextclouddomain" --replace_string="X-Frame-Options : SAMEORIGIN" --target_file="/etc/nginx/conf.d/$old_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/$new_domain.conf"
fi
#=================================================

View file

@ -32,6 +32,9 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -52,7 +55,7 @@ ynh_app_setting_set --app=$app --key=nextclouddomain --value=$nextclouddomain
#=================================================
ynh_script_progression --message="Configuring firewall..."
# Find a free port
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
@ -61,7 +64,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
ynh_script_progression --message="Add nodejs repository..."
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_8.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_10.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
#=================================================
# ADD ONLYOFFICE REPOSITORY
@ -91,6 +94,15 @@ ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
#ynh_setup_source --dest_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -105,9 +117,6 @@ fi
# Create a dedicated nginx config
ynh_add_nginx_config "nextclouddomain"
# Fix main domain X-Frame-Options
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"
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -160,9 +169,7 @@ ynh_store_file_checksum --file="/etc/onlyoffice/documentserver/default.json"
#=================================================
ynh_script_progression --message="Reloading OnlyOffice..."
supervisorctl restart all
sleep 30
supervisorctl reload
#=================================================
# REGENERATE FONTS
@ -171,7 +178,6 @@ ynh_script_progression --message="Generating fonts..."
/usr/bin/documentserver-generate-allfonts.sh
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -20,16 +20,10 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# STOP ONLYOFFICE
#=================================================
ynh_script_progression --message="Stopping OnlyOffice..."
supervisorctl stop all
#=================================================
# REMOVE ONLYOFFICE
#=================================================
@ -45,7 +39,6 @@ ynh_secure_remove --file=/var/lib/dpkg/info/onlyoffice-documentserver.prerm
# right after.
ln -s /bin/true /usr/local/bin/supervisorctl
ynh_package_autopurge onlyoffice-documentserver
ynh_secure_remove /usr/local/bin/supervisorctl
#=================================================
# REMOVE THE POSTGRESQL DATABASE
@ -64,8 +57,18 @@ ynh_script_progression --message="Removing dependencies..."
ynh_remove_app_dependencies
ynh_remove_extra_repo
dpkg --configure -a
apt-key del "E09C A29F 6E17 8040 EF22 B409 8320 CA65 CB2D E8E5"
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -87,7 +90,7 @@ ynh_secure_remove --file="/var/lib/onlyoffice"
ynh_secure_remove --file="/var/cache/nginx/onlyoffice"
# Remove the log files
ynh_secure_remove --file="/var/log/$app/"
ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION

View file

@ -50,9 +50,6 @@ ynh_script_progression --message="Restoring the nginx configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# Fix main domain X-Frame-Options
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"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -68,7 +65,7 @@ ynh_system_user_create --username=$app
#=================================================
ynh_script_progression --message="Add nodejs repository..."
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_8.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_10.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
#=================================================
# ADD ONLYOFFICE REPOSITORY
@ -132,9 +129,7 @@ ynh_script_progression --message="Generating fonts..."
#=================================================
ynh_script_progression --message="Reloading OnlyOffice..."
supervisorctl restart all
sleep 30
supervisorctl reload
#=================================================
# GENERIC FINALIZATION

View file

@ -45,6 +45,12 @@ if [ -z "$db_name" ]; then
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
ynh_secure_remove --file="/etc/apt/sources.list.d/onlyoffice.list"
ynh_secure_remove --file="/etc/apt/sources.list.d/nodesource.list"
@ -86,9 +92,6 @@ fi
# Create a dedicated nginx config
ynh_add_nginx_config "nextclouddomain"
# Fix main domain X-Frame-Options
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
#=================================================
@ -111,7 +114,7 @@ ynh_system_user_create --username=$app
#=================================================
ynh_script_progression --message="Add nodejs repository..."
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_8.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_10.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
#=================================================
# ADD ONLYOFFICE REPOSITORY
@ -178,9 +181,7 @@ fi
#=================================================
ynh_script_progression --message="Reloading OnlyOffice..."
supervisorctl restart all
sleep 30
supervisorctl reload
#=================================================
# RELOAD NGINX