diff --git a/conf/config.yaml.default b/conf/config.yaml.default index 29ebd45..326d0e1 100644 --- a/conf/config.yaml.default +++ b/conf/config.yaml.default @@ -16,7 +16,7 @@ app: # Set to 'I UNDERSTAND THIS VIOLATES THE PRIVACY OF MY USERS' to enable enable_bookmarker_proxy: false # no trailing slash - api_url: 'https://turtl.__DOMAIN__' + api_url: 'https://__DOMAIN__' www_url: 'https://__DOMAIN__' login: # Max failed login attemps. Set to -1 to disable diff --git a/conf/systemd.service b/conf/systemd.service index 6936a63..231ac24 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,7 +1,7 @@ [Unit] Description=Turtl Server: Note taking service Documentation=https://turtlapp.com/ -After=network.target +After=network.target postgresql.service [Service] Type=simple diff --git a/scripts/_common.sh b/scripts/_common.sh index 7ad5df2..579f669 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="postgresql" +pkg_dependencies="postgresql postgresql-contrib" nodejs_version=12 diff --git a/scripts/backup b/scripts/backup index a3c46e9..b913da3 100755 --- a/scripts/backup +++ b/scripts/backup @@ -31,6 +31,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/remove b/scripts/remove index 0012aea..4c1f860 100755 --- a/scripts/remove +++ b/scripts/remove @@ -52,7 +52,7 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= ynh_remove_logrotate #================================================= -# REMOVE THE MYSQL DATABASE +# REMOVE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 diff --git a/scripts/restore b/scripts/restore index 59c5a74..467de90 100755 --- a/scripts/restore +++ b/scripts/restore @@ -33,6 +33,8 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -69,6 +71,19 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # SPECIFIC RESTORATION #================================================= @@ -81,13 +96,13 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index baed730..43b0993 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK VERSION