From 2f37994b4b6ac8f1d3088ba0c15692baea7e535f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:05:30 +0100 Subject: [PATCH] Fix dependencies --- scripts/install | 55 ++++++++++++++++++++++++++----------------------- scripts/remove | 10 +++++++-- scripts/restore | 39 ++++++++++++++++++++++------------- scripts/upgrade | 10 +++++++-- 4 files changed, 70 insertions(+), 44 deletions(-) diff --git a/scripts/install b/scripts/install index dfc729c..c510bec 100644 --- a/scripts/install +++ b/scripts/install @@ -95,12 +95,18 @@ ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - #================================================= -# ADD ONLYOFFICE REPOSITORY +# INSTALL DEPENDENCIES #================================================= -ynh_print_info "Add OnlyOffice repository..." +ynh_print_info "Installing dependencies..." -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 -echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list +### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. +### Those deb packages will be installed as dependencies of this package. +### If you're not using this helper: +### - Remove the section "REMOVE DEPENDENCIES" in the remove script +### - As well as the section "REINSTALL DEPENDENCIES" in the restore script +### - And the section "UPGRADE DEPENDENCIES" in the upgrade script + +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= # CREATE A POSTGRESQL DATABASE @@ -124,27 +130,6 @@ ynh_app_setting_set $app db_pwd $db_pwd ynh_psql_test_if_first_run ynh_psql_create_db $db_name $db_name $db_pwd -#================================================= -# DEFINE PORT -#================================================= -ynh_print_info "Define OnlyOffice server port..." - -echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_print_info "Installing dependencies..." - -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -187,8 +172,26 @@ ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP #================================================= -# ... +# DEFINE PORT #================================================= +ynh_print_info "Define OnlyOffice server port..." + +echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections + +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= +ynh_print_info "Add OnlyOffice repository..." + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list + +#================================================= +# INSTALL ONLYOFFICE +#================================================= +ynh_print_info "Install OnlyOffice..." + +ynh_package_install onlyoffice-documentserver #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/remove b/scripts/remove index 54afadd..50aa37e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -39,14 +39,20 @@ ynh_print_info "Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user ynh_psql_remove_db $db_name $db_name +#================================================= +# REMOVE ONLYOFFICE +#================================================= +ynh_print_info "Removing OnlyOffice" + +ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm +ynh_package_autoremove onlyoffice-documentserver + #================================================= # REMOVE DEPENDENCIES #================================================= ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies -documentserver-prepare4shutdown.sh -ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm ynh_remove_app_dependencies #================================================= diff --git a/scripts/restore b/scripts/restore index cf61e9f..4b3d418 100644 --- a/scripts/restore +++ b/scripts/restore @@ -34,6 +34,7 @@ final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app db_pwd) port=$(ynh_app_setting_get $app port) +nextclouddomain=$(ynh_app_setting_get $app nextclouddomain) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -53,6 +54,9 @@ test ! -d $final_path \ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +# 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" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -77,6 +81,21 @@ chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION +#================================================= +# ADD NODEJS REPOSITORY +#================================================= +ynh_print_info "Add nodejs repository..." + +curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - + +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info "Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= @@ -88,11 +107,11 @@ ynh_psql_create_db $db_name $db_name $db_pwd ynh_psql_execute_file_as_root ./db.sql "$db_name" #================================================= -# ADD NODEJS REPOSITORY +# DEFINE PORT #================================================= -ynh_print_info "Installing nodejs..." +ynh_print_info "Define OnlyOffice server port..." -curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections #================================================= # ADD ONLYOFFICE REPOSITORY @@ -103,19 +122,11 @@ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list #================================================= -# DEFINE PORT +# REINSTALL ONLYOFFICE #================================================= -ynh_print_info "Define OnlyOffice server port..." +ynh_print_info "Reinstalling OnlyOffice..." -echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections - -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_print_info "Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver +ynh_package_install onlyoffice-documentserver #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 5a73fd1..23ef060 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -86,12 +86,15 @@ else fi ynh_add_nginx_config "nextclouddomain" +# 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" + #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_print_info "Upgrading dependencies..." -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= # CREATE DEDICATED USER @@ -104,8 +107,11 @@ ynh_system_user_create $app #================================================= # SPECIFIC UPGRADE #================================================= -# ... +# UPGRADE ONLYOFFICE #================================================= +ynh_print_info "Upgrading OnlyOffice..." + +ynh_package_install onlyoffice-documentserver ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.