diff --git a/conf/config.php b/conf/config.php index e36c36d..d43192a 100644 --- a/conf/config.php +++ b/conf/config.php @@ -4,12 +4,12 @@ // *** Database configuration (important!) *** // ******************************************* - putenv('TTRSS_DB_TYPE=pgsql'); // or mysql + putenv('TTRSS_DB_TYPE=pgsql'); putenv('TTRSS_DB_HOST=localhost'); putenv('TTRSS_DB_USER=__DB_USER__'); putenv('TTRSS_DB_NAME=__DB_NAME__'); putenv('TTRSS_DB_PASS=__DB_PWD__'); - putenv('TTRSS_DB_PORT=5432'); // usually 5432 for PostgreSQL, 3306 for MySQL + putenv('TTRSS_DB_PORT=5432'); // *********************************** // *** Basic settings (important!) *** diff --git a/conf/systemd.service b/conf/systemd.service index ee3c238..341d325 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ Description=TTRSS: News feed reader and aggregator -After=network.target mysql.service +After=network.target postgresql.service [Service] Type=simple diff --git a/doc/PRE_UPGRADE.md b/doc/PRE_UPGRADE.md new file mode 100644 index 0000000..b43cd17 --- /dev/null +++ b/doc/PRE_UPGRADE.md @@ -0,0 +1 @@ +We are moving from MariaDB to PostgreSQL database. There is no database migration for now. It advised to export your OPML, install TTRSS and import back the OPML file. \ No newline at end of file diff --git a/scripts/install b/scripts/install index 1658e20..adab104 100644 --- a/scripts/install +++ b/scripts/install @@ -30,21 +30,21 @@ chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# PHP-FPM CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 - # Create a dedicated NGINX config ynh_add_nginx_config +# Create a dedicated systemd config +ynh_add_systemd_config + +yunohost service add $app --description="News feed reader and aggregator" --log="/var/log/$app/$app.log" + #================================================= # SPECIFIC SETUP #================================================= @@ -59,32 +59,15 @@ ynh_add_config --template="../conf/config.php" --destination="$install_dir/confi chmod 400 "$install_dir/config.php" chown $app "$install_dir/config.php" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=2 - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # INITIALIZE DATABASE #================================================= ynh_script_progression --message="Initializing database..." --weight=6 -ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \ - < "$install_dir/schema/ttrss_schema_mysql.sql" +ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \ + < "$install_dir/schema/ttrss_schema_pgsql.sql" -ynh_exec_as $app php${phpversion} ${install_dir}/update.php --update-schema=force-yes - -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="News feed reader and aggregator" --log="/var/log/$app/$app.log" +ynh_exec_as $app php$phpversion $install_dir/update.php --update-schema=force-yes #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index 638eb53..9487cb3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,12 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers - #================================================= -# STANDARD REMOVE +# REMOVE SYSTEM CONFIGURATIONS #================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null @@ -23,27 +23,12 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=3 - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config diff --git a/scripts/restore b/scripts/restore index 96f8017..c938385 100644 --- a/scripts/restore +++ b/scripts/restore @@ -20,58 +20,37 @@ ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=50 - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -# Recreate a dedicated php-fpm config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= -# RESTORE SYSTEMD +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=2 +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - yunohost service add $app --description="News feed reader and aggregator" --log="/var/log/$app/$app.log" -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" - #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index ddc96fd..867e0aa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,21 +68,21 @@ chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# PHP-FPM CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 - # Create a dedicated NGINX config ynh_add_nginx_config +# Create a dedicated systemd config +ynh_add_systemd_config + +yunohost service add $app --description="News feed reader and aggregator" --log="/var/log/$app/$app.log" + #================================================= # SPECIFIC UPGRADE #================================================= @@ -103,23 +103,6 @@ fi chmod 400 "$install_dir/config.php" chown $app:$app "$install_dir/config.php" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="News feed reader and aggregator" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #=================================================