Skip to content

Commit

Permalink
Fix package upgrade logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid-tt committed Nov 15, 2023
1 parent 1c41461 commit 7a0dc3f
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions spk/tt-rss/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,17 @@ service_save ()
${CP} "${SOURCE_WEB_DIR}/${PACKAGE}/config.php" "${TMP_DIR}/${PACKAGE}/"

${MKDIR} "${TMP_DIR}/${PACKAGE}/feed-icons/"
${CP} "${SOURCE_WEB_DIR}/${PACKAGE}/feed-icons"/*.ico "${TMP_DIR}/${PACKAGE}/feed-icons/"
${CP} "${SOURCE_WEB_DIR}/${PACKAGE}/feed-icons"/*.ico "${TMP_DIR}/${PACKAGE}/feed-icons/" 2>/dev/null

${CP} "${SOURCE_WEB_DIR}/${PACKAGE}/plugins.local" "${TMP_DIR}/${PACKAGE}/"
${CP} "${SOURCE_WEB_DIR}/${PACKAGE}/themes.local" "${TMP_DIR}/${PACKAGE}/"
${CP} "${SOURCE_WEB_DIR}/${PACKAGE}/plugins.local" "${TMP_DIR}/${PACKAGE}/" 2>/dev/null
${CP} "${SOURCE_WEB_DIR}/${PACKAGE}/themes.local" "${TMP_DIR}/${PACKAGE}/" 2>/dev/null

${MKDIR} -p "${TMP_DIR}/${PACKAGE}/${VERSION_FILE_DIRECTORY}"
echo "${SYNOPKG_OLD_PKGVER}" | sed -r "s/^.*-([0-9]+)$/\1/" >"${TMP_DIR}/${PACKAGE}/${VERSION_FILE}"

${MKDIR} -p "${TMP_DIR}/${PACKAGE}/cache/feed-icons/"
${CP} "${SOURCE_WEB_DIR}/${PACKAGE}/cache/feed-icons"/* "${TMP_DIR}/${PACKAGE}/cache/feed-icons/" 2>/dev/null

return 0
}

Expand Down Expand Up @@ -296,12 +299,27 @@ service_restore ()
"${WEB_DIR}/${PACKAGE}/config.php"
echo "putenv('TTRSS_MYSQL_DB_SOCKET=/run/mysqld/mysqld10.sock');">>"${WEB_DIR}/${PACKAGE}/config.php"
fi
# Check config file for legacy PHP exec to migrate
php_executable_line="putenv('TTRSS_PHP_EXECUTABLE=\/usr\/local\/bin\/php74');"
search_pattern="^putenv('TTRSS_PHP_EXECUTABLE="
# Check if the line exists in the file
if grep -q "$search_pattern" "${WEB_DIR}/${PACKAGE}/config.php"; then
current_line=$(grep "$search_pattern" "${WEB_DIR}/${PACKAGE}/config.php")
if [ "$current_line" != "$php_executable_line" ]; then
# If the line is present but not correct, replace it
sed -i "s/$search_pattern.*/$php_executable_line/" "${WEB_DIR}/${PACKAGE}/config.php"
echo "Legacy PHP exec config migrated successfully."
fi
fi

${MV} "${TMP_DIR}/${PACKAGE}"/feed-icons/*.ico "${WEB_DIR}/${PACKAGE}"/feed-icons/ 2>/dev/null
${MV} "${TMP_DIR}/${PACKAGE}"/plugins.local/* "${WEB_DIR}/${PACKAGE}"/plugins.local/ 2>/dev/null
${MV} "${TMP_DIR}/${PACKAGE}"/themes.local/* "${WEB_DIR}/${PACKAGE}"/themes.local/ 2>/dev/null

${MV} "${TMP_DIR}/${PACKAGE}"/feed-icons/*.ico "${WEB_DIR}/${PACKAGE}"/feed-icons/;
${MV} "${TMP_DIR}/${PACKAGE}"/plugins.local/* "${WEB_DIR}/${PACKAGE}"/plugins.local/;
${MV} "${TMP_DIR}/${PACKAGE}"/themes.local/* "${WEB_DIR}/${PACKAGE}"/themes.local/;
${MKDIR} -p "${WEB_DIR}/${PACKAGE}/cache/feed-icons/"
${MV} "${TMP_DIR}/${PACKAGE}"/cache/feed-icons/* "${WEB_DIR}/${PACKAGE}"/cache/feed-icons/ 2>/dev/null

exec_update_schema;
exec_update_schema

return 0
}

0 comments on commit 7a0dc3f

Please sign in to comment.