From 9cc43c0f5a3a3982d4130d16426011b56bc4c1fc Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 26 Mar 2019 23:14:43 +0100 Subject: [PATCH] Revert "Fix upgrade from the old version" This reverts commit 25d73a472c195aa0b0a3713c9f00f6bc586fe6a6. --- conf/lufi.conf.template | 2 +- scripts/backup | 5 +---- scripts/change_url | 2 -- scripts/install | 5 ----- scripts/remove | 2 +- scripts/restore | 14 +++++--------- scripts/upgrade | 24 +++--------------------- 7 files changed, 11 insertions(+), 43 deletions(-) diff --git a/conf/lufi.conf.template b/conf/lufi.conf.template index 4a24af8..4fc1e86 100644 --- a/conf/lufi.conf.template +++ b/conf/lufi.conf.template @@ -117,7 +117,7 @@ # choose what database you want to use # valid choices are sqlite, postgresql and mysql (all lowercase) # optional, default is sqlite - dbtype => '__DB_MANAGER__', + dbtype => 'postgresql', # SQLite ONLY - only used if dbtype is set to sqlite # define a path to the SQLite database diff --git a/scripts/backup b/scripts/backup index e7dac3c..15c84e6 100644 --- a/scripts/backup +++ b/scripts/backup @@ -30,7 +30,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) -db_manager=$(ynh_app_setting_get $app db_manager) #================================================= # STANDARD BACKUP STEPS @@ -53,9 +52,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_print_info "Backing up the PostgreSQL database..." -if [ $db_manager = "postgresql" ]; then - ynh_psql_dump_db "$db_name" > db.sql -fi +ynh_psql_dump_db "$db_name" > db.sql #================================================= # SPECIFIC BACKUP diff --git a/scripts/change_url b/scripts/change_url index a90a093..23da1c3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -37,7 +37,6 @@ db_pwd=$(ynh_app_setting_get $app psqlpwd) db_user=$db_name secret=$(ynh_app_setting_get $app secret) max_file_size=$(ynh_app_setting_get $app max_file_size) -db_manager=$(ynh_app_setting_get $app db_manager) #================================================= # CHECK THE SYNTAX OF THE PATHS @@ -113,7 +112,6 @@ ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" -ynh_replace_string "__DB_MANAGER__" "$db_manager" "${final_path}/lufi.conf" if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" fi diff --git a/scripts/install b/scripts/install index 05be583..33afb7c 100644 --- a/scripts/install +++ b/scripts/install @@ -48,9 +48,6 @@ if ! [[ $max_file_size =~ "^[\-0-9]+$" ]] && [ $max_file_size -lt 0 ]; then ynh_die "Max file must be a number positive or zero" fi -# Use postgresql by default -db_manager="postgresql" - # Check web path availability ynh_webpath_available $domain $path_url # Register (book) web path @@ -76,7 +73,6 @@ ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app port $port ynh_app_setting_set $app path $path_url ynh_app_setting_set $app max_file_size $max_file_size -ynh_app_setting_set $app db_manager $db_manager #================================================= # STANDARD MODIFICATIONS @@ -141,7 +137,6 @@ ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" -ynh_replace_string "__DB_MANAGER__" "$db_manager" "${final_path}/lufi.conf" if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" fi diff --git a/scripts/remove b/scripts/remove index 627263d..8377d9d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -63,7 +63,7 @@ ynh_remove_nginx_config # DELETE LOG #================================================= -ynh_secure_remove "/var/log/$app" +ynh_secure_remove "/var/log/$app/" #================================================= # REMOVE LOGROTATE CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 0bef29a..286e393 100644 --- a/scripts/restore +++ b/scripts/restore @@ -32,7 +32,6 @@ domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) -db_manager=$(ynh_app_setting_get $app db_manager) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -80,15 +79,12 @@ ynh_system_user_create $app #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= +ynh_print_info "Restoring the PostregSQL database..." -if [ $db_manager = "postgresql" ]; then - ynh_print_info "Restoring the PostregSQL database..." - - db_pwd=$(ynh_app_setting_get $app psqlpwd) - ynh_psql_test_if_first_run - ynh_psql_setup_db $db_name $db_name $db_pwd - ynh_psql_connect_as $db_name $db_pwd $db_name < ./db.sql -fi +db_pwd=$(ynh_app_setting_get $app psqlpwd) +ynh_psql_test_if_first_run +ynh_psql_setup_db $db_name $db_name $db_pwd +ynh_psql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # RESTORE USER RIGHTS diff --git a/scripts/upgrade b/scripts/upgrade index e2dd559..fb6d1e3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,7 +26,6 @@ db_name=$(ynh_app_setting_get $app db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get $app psqlpwd) max_file_size=$(ynh_app_setting_get $app max_file_size) -db_manager=$(ynh_app_setting_get $app db_manager) #================================================= # FIX OLD THINGS @@ -60,11 +59,6 @@ if [ -z "$max_file_size" ]; then max_file_size=100 # 100 Mo fi -# If db_manager is empty, use sqlite for a backward compatibility -if [ -z "$db_manager" ]; then - db_manager="sqlite" -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -122,7 +116,6 @@ ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" -ynh_replace_string "__DB_MANAGER__" "$db_manager" "${final_path}/lufi.conf" if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" fi @@ -148,7 +141,7 @@ chmod +x $final_path/script/lufi # SECURING FILES AND DIRECTORIES #================================================= -chown -R $app: "$final_path" +chown -R $app:$app "$final_path" #================================================= # SETUP SYSTEMD @@ -163,11 +156,7 @@ ynh_add_systemd_config #================================================= pushd $final_path -if [ $db_manager = "postgresql" ]; then - carton install --deployment --without=sqlite --without=mysql -else - carton install --deployment --without=postgresql --without=mysql -fi +carton install --deployment --without=sqlite --without=mysql popd #================================================= @@ -182,21 +171,14 @@ ynh_use_logrotate --non-append # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -# if /var/log/$app/production.log is a symbolic link, then move it to $final_path/log/production.log -if [ ! -L "/var/log/$app/production.log" ] -then - mv "/var/log/$app/production.log" "$final_path/log/production.log" - chown -R $app: "$final_path/log/production.log" -fi - yunohost service add $app --log "$final_path/log/production.log" #================================================= # RESTART LUFI #================================================= +ynh_systemd_action -n $app -a reload -l "Creating process id file" -p "$final_path/log/production.log" ln -sf "$final_path/log/production.log" "/var/log/$app/production.log" -ynh_systemd_action -n $app -a restart -l "Creating process id file" -p "$final_path/log/production.log" #================================================= # SETUP SSOWAT