From ad4f3a2503b342c5fab45743f500a28d0ab3eaf1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 22 May 2019 02:43:24 +0200 Subject: [PATCH] Reapply example_ynh --- scripts/_common.sh | 9 ++++++--- scripts/install | 14 ++++++-------- scripts/restore | 7 +++---- scripts/upgrade | 29 +++++++++++++++++++++++------ 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8819f60..e4da49e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,13 +5,16 @@ #================================================= # dependencies used by the app -pkg_dependencies="postgresql libstdc++6 redis-server rabbitmq-server" +pkg_dependencies="postgresql libstdc++6 redis-server rabbitmq-server libcurl4-nss-dev" #================================================= # PERSONAL HELPERS #================================================= -source="https://github.com/ONLYOFFICE/DocumentServer/releases/download/ONLYOFFICE-DocumentServer-5.2.8/onlyoffice-documentserver_amd64.deb" -version="5.2.8" + +onlyoffice_version="5.2.8" + +onlyoffice_source="https://github.com/ONLYOFFICE/DocumentServer/releases/download/ONLYOFFICE-DocumentServer-$onlyoffice_version/onlyoffice-documentserver_amd64.deb" + #================================================= # EXPERIMENTAL HELPERS diff --git a/scripts/install b/scripts/install index 42ea71f..062e0ec 100644 --- a/scripts/install +++ b/scripts/install @@ -86,8 +86,8 @@ ynh_print_info --message="Creating a PostgreSQL database..." db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name db_pwd=$(ynh_string_random --length=32) -ynh_app_setting_set $app db_name $db_name -ynh_app_setting_set $app db_pwd $db_pwd +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +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 @@ -134,30 +134,28 @@ echo onlyoffice-documentserver onlyoffice/db-name string $db_name | sudo debconf #================================================= ynh_print_info --message="Install OnlyOffice..." -wget $source +wget $onlyoffice_source ynh_package_install ./onlyoffice-documentserver_amd64.deb #================================================= # MODIFY A CONFIG FILE #================================================= -#ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE" +ynh_replace_string --match_string="\"rejectUnauthorized\": true" --replace_string="\"rejectUnauthorized\": false" --target_file="/etc/onlyoffice/documentserver/default.json" #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= # Calculate and store the config file checksum into the app settings -#ynh_store_file_checksum --file="$final_path/CONFIG_FILE" - +ynh_store_file_checksum --file="/etc/onlyoffice/documentserver/default.json" #================================================= # RELOAD ONLYOFFICE #================================================= ynh_print_info --message="Reloading OnlyOffice..." -supervisorctl stop all -supervisorctl start all +supervisorctl restart all sleep 30 diff --git a/scripts/restore b/scripts/restore index a1f06fd..9b59be1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -109,8 +109,8 @@ echo onlyoffice-documentserver onlyoffice/db-name string $db_name | sudo debconf #================================================= ynh_print_info --message="Reinstalling OnlyOffice..." -wget $source -apt install -y ./onlyoffice-documentserver_amd64.deb +wget $onlyoffice_source +ynh_package_install ./onlyoffice-documentserver_amd64.deb #================================================= # RESTORE THE CONFIGURATION @@ -133,8 +133,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_print_info --message="Reloading OnlyOffice..." -supervisorctl stop all -supervisorctl start all +supervisorctl restart all sleep 30 diff --git a/scripts/upgrade b/scripts/upgrade index ff06584..c16518a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,6 +51,7 @@ ynh_print_info --message="Backing up the app before upgrading (may take a while) # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + read -p "key" # restore it if the upgrade fails ynh_restore_upgradebackup } @@ -73,7 +74,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) ynh_print_info --message="Configuring nginx web server..." if [ "$path_url" = "/" ]; then - ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf" + ynh_replace_string --match_string="__SUB_PATH__" --replace_string="" --target_file="../conf/nginx.conf" else ynh_replace_string --match_string="__SUB_PATH__" --replace_string="$path_url" --target_file="../conf/nginx.conf" fi @@ -116,21 +117,38 @@ ynh_print_info --message="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 +#================================================= +# CONFIGURE ONLYOFFICE +#================================================= +ynh_print_info --message="Configuring Onlyoffice..." + +echo onlyoffice-documentserver onlyoffice/ds-port select $port | sudo debconf-set-selections +echo onlyoffice-documentserver onlyoffice/db-host string 127.0.0.1 | sudo debconf-set-selections +echo onlyoffice-documentserver onlyoffice/db-user string $db_user | sudo debconf-set-selections +echo onlyoffice-documentserver onlyoffice/db-pwd password $db_pwd | debconf-set-selections +echo onlyoffice-documentserver onlyoffice/db-name string $db_name | sudo debconf-set-selections + #================================================= # UPGRADE ONLYOFFICE #================================================= ynh_print_info --message="Upgrading OnlyOffice..." -wget $source +wget $onlyoffice_source ynh_package_install ./onlyoffice-documentserver_amd64.deb +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +ynh_replace_string --match_string="\"rejectUnauthorized\": true" --replace_string="\"rejectUnauthorized\": false" --target_file="/etc/onlyoffice/documentserver/default.json" + #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -#ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" +ynh_backup_if_checksum_is_different --file="/etc/onlyoffice/documentserver/default.json" # Recalculate and store the checksum of the file for the next upgrade. -#ynh_store_file_checksum "$final_path/CONFIG_FILE" +ynh_store_file_checksum --file="/etc/onlyoffice/documentserver/default.json" #================================================= @@ -159,8 +177,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_print_info --message="Reloading OnlyOffice..." -supervisorctl stop all -supervisorctl start all +supervisorctl restart all sleep 30