diff --git a/cross/selfoss/Makefile b/cross/selfoss/Makefile index 76690e63d18..beb50abccd2 100644 --- a/cross/selfoss/Makefile +++ b/cross/selfoss/Makefile @@ -1,9 +1,9 @@ PKG_NAME = selfoss -PKG_VERS = 2.13 +PKG_VERS = 2.19 PKG_EXT = zip PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) -PKG_DIST_SITE = https://github.com/SSilence/selfoss/releases/download/$(PKG_VERS) -PKG_DIR = $(PKG_NAME)-$(PKG_VERS) +PKG_DIST_SITE = https://github.com/fossar/$(PKG_NAME)/releases/download/$(PKG_VERS) +PKG_DIR = $(PKG_NAME) DEPENDS = @@ -11,12 +11,11 @@ HOMEPAGE = https://selfoss.aditu.de/ COMMENT = The new multipurpose rss reader, live stream, mashup, aggregation web application. LICENSE = GPLv3 -EXTRACT_PATH = $(WORK_DIR)/$(PKG_DIR) INSTALL_TARGET = selfoss_install include ../../mk/spksrc.install-resources.mk .PHONY: selfoss_install selfoss_install: - mkdir -p $(STAGING_INSTALL_PREFIX)/share/selfoss - tar -cf - -C $(WORK_DIR)/$(PKG_DIR) . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/selfoss + mkdir -p $(STAGING_INSTALL_PREFIX)/share/$(PKG_NAME) + tar -cf - -C $(WORK_DIR)/$(PKG_DIR) . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/$(PKG_NAME) diff --git a/cross/selfoss/digests b/cross/selfoss/digests index de1a47f3e36..7d1c734d031 100644 --- a/cross/selfoss/digests +++ b/cross/selfoss/digests @@ -1,3 +1,3 @@ -selfoss-2.13.zip SHA1 d5b2efec42c028480fd1811a838f2dfb1e115f2a -selfoss-2.13.zip SHA256 407d7899bbac684e0c78385ad02af027af441198683ceedc23edc58c0dd19b8a -selfoss-2.13.zip MD5 1a5f2f8a233c1e9723a08f35737aaa3f +selfoss-2.19.zip SHA1 383567d96c00027ab1f390df4e1eda2efeccba31 +selfoss-2.19.zip SHA256 e49c4750e9723277963ca699b602f09f9148e2b9f258fce6b14429498af0e4fc +selfoss-2.19.zip MD5 c5121a54b88920eb6785e503a6f03e06 diff --git a/spk/selfoss/Makefile b/spk/selfoss/Makefile index c26826c9756..bacba6005bb 100644 --- a/spk/selfoss/Makefile +++ b/spk/selfoss/Makefile @@ -1,41 +1,48 @@ SPK_NAME = selfoss -SPK_VERS = 2.13 -SPK_REV = 6 +SPK_VERS = 2.19 +SPK_REV = 7 SPK_ICON = src/selfoss.png -DSM_UI_DIR = app -DEPENDS = cross/busybox cross/$(SPK_NAME) +DEPENDS = cross/selfoss +# Pure PHP package, make sure ARCH is not defined +override ARCH= + +REQUIRED_MIN_DSM = 6.0 +SPK_DEPENDS = WebStation:PHP7.4:Apache2.4 MAINTAINER = moneytoo DESCRIPTION = The new multipurpose rss reader, live stream, mashup, aggregation web application. -ADMIN_URL = /selfoss/ DISPLAY_NAME = Selfoss -CHANGELOG = "1. Update Selfoss to 2.13
2. Fix DSM4.3 compatibility" - +CHANGELOG = "1. Update Selfoss to 2.19.
2. Use faster SQLite database." HOMEPAGE = https://selfoss.aditu.de/ + LICENSE = GPLv3 WIZARDS_DIR = src/wizard/ -CONF_DIR = src/conf/ -INSTALLER_SCRIPT = src/installer.sh -SSS_SCRIPT = src/dsm-control.sh +SYSTEM_GROUP = http -INSTALL_DEP_SERVICES = apache-web mysql -START_DEP_SERVICES = apache-web mysql +# Admin link for in DSM UI +ADMIN_URL = /selfoss/ + +DSM_UI_DIR = app +DSM_UI_CONFIG = src/app/config +CONF_DIR = src/conf/ -INSTALL_PREFIX = /usr/local/$(SPK_NAME) +# Set user as 'auto' for DSM 6 privilege +SERVICE_USER = auto +SERVICE_SETUP = src/service-setup.sh +STARTABLE = no -POST_STRIP_TARGET = selfoss_extra_install +# TMPDIR is used for selfoss built in backup and update +USE_ALTERNATE_TMPDIR = 1 -BUSYBOX_CONFIG = daemon nice -ENV += BUSYBOX_CONFIG="$(BUSYBOX_CONFIG)" +POST_STRIP_TARGET = selfoss_extra_install include ../../mk/spksrc.spk.mk .PHONY: selfoss_extra_install selfoss_extra_install: - install -m 755 -d $(STAGING_DIR)/var - install -m 755 src/selfoss.sh $(STAGING_DIR)/bin/ - install -m 755 -d $(STAGING_DIR)/app - install -m 644 src/app/config $(STAGING_DIR)/app/config + install -m 755 -d $(STAGING_DIR)/web + install -m 644 src/web/selfoss.conf $(STAGING_DIR)/web/selfoss.conf + install -m 644 src/web/selfoss.json $(STAGING_DIR)/web/selfoss.json diff --git a/spk/selfoss/src/app/config b/spk/selfoss/src/app/config index df2cf1ec296..796daae2884 100644 --- a/spk/selfoss/src/app/config +++ b/spk/selfoss/src/app/config @@ -1,15 +1,14 @@ { ".url": { "com.synocommunity.packages.selfoss": { - "title": "Selfoss", + "allUsers": true, "desc": "Selfoss", "icon": "images/selfoss-{0}.png", - "type": "url", - "protocol": "http", "port": "80", - "url": "/selfoss", - "allUsers": true, - "grantPrivilege": "local" + "protocol": "http", + "title": "Selfoss", + "type": "url", + "url": "/selfoss" } } } diff --git a/spk/selfoss/src/conf/PKG_DEPS b/spk/selfoss/src/conf/PKG_DEPS deleted file mode 100644 index 9f832e23f1a..00000000000 --- a/spk/selfoss/src/conf/PKG_DEPS +++ /dev/null @@ -1,2 +0,0 @@ -[MariaDB] -dsm_min_ver=5.0-4300 diff --git a/spk/selfoss/src/conf/resource b/spk/selfoss/src/conf/resource new file mode 100644 index 00000000000..11bb1bb3e72 --- /dev/null +++ b/spk/selfoss/src/conf/resource @@ -0,0 +1,54 @@ +{ + "webservice": { + "migrate": { + "root": [{ + "new": "selfoss", + "old": "selfoss" + }] + }, + "pkg_dir_prepare": [{ + "group": "http", + "mode": "0750", + "source": "/var/packages/selfoss/target/share/selfoss", + "target": "selfoss", + "user": "sc-selfoss" + }], + "portals": [{ + "alias": "selfoss", + "app": "com.synocommunity.packages.selfoss", + "display_name": "Selfoss", + "name": "Selfoss", + "service": "Selfoss", + "type": "alias" + }], + "services": [{ + "backend": 2, + "display_name": "Selfoss", + "icon": "app/images/selfoss-{0}.png", + "php": { + "backend": 8, + "connect_timeout": 120, + "extensions": [ + "curl", + "gd", + "imagick", + "openssl", + "pdo_sqlite" + ], + "group": "http", + "php_settings": { + "error_log": "/var/services/web_packages/selfoss/data/logs/php_errors.log", + "max_execution_time": "900" + }, + "profile_desc": "PHP Profile for Selfoss", + "profile_name": "Selfoss Profile", + "user": "sc-selfoss" + }, + "read_timeout": 3600, + "root": "selfoss", + "send_timeout": 120, + "service": "Selfoss", + "type": "apache_php" + }] + } +} diff --git a/spk/selfoss/src/dsm-control.sh b/spk/selfoss/src/dsm-control.sh deleted file mode 100755 index 9a05331b444..00000000000 --- a/spk/selfoss/src/dsm-control.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -# Package -PACKAGE="selfoss" -DNAME="Selfoss" - -# Others -INSTALL_DIR="/usr/local/${PACKAGE}" -WEB_DIR="/var/services/web" -PATH="${INSTALL_DIR}/bin:${PATH}" -BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)" -USER="$([ "${BUILDNUMBER}" -ge "4418" ] && echo -n http || echo -n nobody)" -SELFOSS="${INSTALL_DIR}/bin/selfoss.sh" -PID_FILE="${INSTALL_DIR}/var/selfoss.pid" - - -start_daemon () -{ - start-stop-daemon -S -q -m -b -N 10 -x ${SELFOSS} -c ${USER} -u ${USER} -p ${PID_FILE} -} - -stop_daemon () -{ - start-stop-daemon -K -q -u ${USER} -p ${PID_FILE} - wait_for_status 1 20 || start-stop-daemon -K -s 9 -q -p ${PID_FILE} -} - -daemon_status () -{ - start-stop-daemon -K -q -t -u ${USER} -p ${PID_FILE} -} - -wait_for_status () -{ - counter=$2 - while [ ${counter} -gt 0 ]; do - daemon_status - [ $? -eq $1 ] && return - let counter=counter-1 - sleep 1 - done - return 1 -} - - -case $1 in - start) - if daemon_status; then - echo ${DNAME} is already running - else - echo Starting ${DNAME} ... - start_daemon - fi - ;; - stop) - if daemon_status; then - echo Stopping ${DNAME} ... - stop_daemon - else - echo ${DNAME} is not running - fi - ;; - status) - if daemon_status; then - echo ${DNAME} is running - exit 0 - else - echo ${DNAME} is not running - exit 1 - fi - ;; - log) - exit 1 - ;; - *) - exit 1 - ;; -esac diff --git a/spk/selfoss/src/installer.sh b/spk/selfoss/src/installer.sh deleted file mode 100755 index 992b0466ac1..00000000000 --- a/spk/selfoss/src/installer.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/sh - -# Package -PACKAGE="selfoss" -DNAME="Selfoss" - -# Others -INSTALL_DIR="/usr/local/${PACKAGE}" -SSS="/var/packages/${PACKAGE}/scripts/start-stop-status" -WEB_DIR="/var/services/web" -TMP_DIR="${SYNOPKG_PKGDEST}/../../@tmp" -BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)" - -USER="$([ "${BUILDNUMBER}" -ge "4418" ] && echo -n http || echo -n nobody)" -MYSQL="$([ "${BUILDNUMBER}" -ge "7321" ] && echo -n /bin/mysql || echo -n /usr/syno/mysql/bin/mysql)" -MYSQLDUMP="$([ "${BUILDNUMBER}" -ge "7321" ] && echo -n /bin/mysqldump || echo -n /usr/syno/mysql/bin/mysqldump)" -MYSQL_USER="selfoss" -MYSQL_DATABASE="selfoss" - - -preinst () -{ - # Check database - if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then - if ! ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e quit > /dev/null 2>&1; then - echo "Incorrect MySQL root password" - exit 1 - fi - if ${MYSQL} -u root -p"${wizard_mysql_password_root}" mysql -e "SELECT User FROM user" | grep ^${MYSQL_USER}$ > /dev/null 2>&1; then - echo "MySQL user ${MYSQL_USER} already exists" - exit 1 - fi - if ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e "SHOW DATABASES" | grep ^${MYSQL_DATABASE}$ > /dev/null 2>&1; then - echo "MySQL database ${MYSQL_DATABASE} already exists" - exit 1 - fi - fi - - exit 0 -} - -postinst () -{ - # Link - ln -s ${SYNOPKG_PKGDEST} ${INSTALL_DIR} - - # Create conf dir for 4.3 and add dependencies - mkdir -p /var/packages/${PACKAGE}/conf && echo -e "[MariaDB]\ndsm_min_ver=5.0-4300" > /var/packages/${PACKAGE}/conf/PKG_DEPS - - # Install busybox stuff - ${INSTALL_DIR}/bin/busybox --install ${INSTALL_DIR}/bin - - # Install the web interface - cp -pR ${INSTALL_DIR}/share/${PACKAGE} ${WEB_DIR} - - # Setup database and configuration file - if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then - ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e "CREATE DATABASE ${MYSQL_DATABASE}; GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO '${MYSQL_USER}'@'localhost' IDENTIFIED BY '${wizard_mysql_password_selfoss}';" - echo -e "[globals]\ndb_type=mysql\ndb_host=localhost\ndb_port=3306\ndb_username=${MYSQL_USER}\ndb_password=${wizard_mysql_password_selfoss}\nsalt=$(openssl rand -hex 8)" > ${WEB_DIR}/${PACKAGE}/config.ini - fi - - # Fix permissions - chown ${USER} ${WEB_DIR}/${PACKAGE}/public - chown -R ${USER} ${WEB_DIR}/${PACKAGE}/data - - exit 0 -} - -preuninst () -{ - # Check database - if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" ] && ! ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e quit > /dev/null 2>&1; then - echo "Incorrect MySQL root password" - exit 1 - fi - - # Check database export location - if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" -a -n "${wizard_dbexport_path}" ]; then - if [ -f "${wizard_dbexport_path}" -o -e "${wizard_dbexport_path}/${MYSQL_DATABASE}.sql" ]; then - echo "File ${wizard_dbexport_path}/${MYSQL_DATABASE}.sql already exists. Please remove or choose a different location" - exit 1 - fi - fi - - # Stop the package - ${SSS} stop > /dev/null - - exit 0 -} - -postuninst () -{ - # Remove link - rm -f ${INSTALL_DIR} - - # Export and remove database - if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" ]; then - if [ -n "${wizard_dbexport_path}" ]; then - mkdir -p ${wizard_dbexport_path} - ${MYSQLDUMP} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} > ${wizard_dbexport_path}/${MYSQL_DATABASE}.sql - fi - ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e "DROP DATABASE ${MYSQL_DATABASE}; DROP USER '${MYSQL_USER}'@'localhost';" - fi - - # Remove the web interface - rm -fr ${WEB_DIR}/${PACKAGE} - - exit 0 -} - -preupgrade () -{ - # Stop the package - ${SSS} stop > /dev/null - - # Save the configuration file - rm -fr ${TMP_DIR}/${PACKAGE} - mkdir -p ${TMP_DIR}/${PACKAGE} - mv ${WEB_DIR}/${PACKAGE}/config.ini ${TMP_DIR}/${PACKAGE}/ - mv ${WEB_DIR}/${PACKAGE}/data ${TMP_DIR}/${PACKAGE}/ - - exit 0 -} - -postupgrade () -{ - # Restore the configuration file - mv ${TMP_DIR}/${PACKAGE}/config.ini ${WEB_DIR}/${PACKAGE}/ - cp -r ${TMP_DIR}/${PACKAGE}/data ${WEB_DIR}/${PACKAGE}/ - rm -fr ${TMP_DIR}/${PACKAGE} - - # Remove trailing whitespace from config - sed -ie "s/[ \t]*$//" ${WEB_DIR}/${PACKAGE}/config.ini - - exit 0 -} diff --git a/spk/selfoss/src/selfoss.png b/spk/selfoss/src/selfoss.png index 201bd20a2b2..1cc859c2348 100644 Binary files a/spk/selfoss/src/selfoss.png and b/spk/selfoss/src/selfoss.png differ diff --git a/spk/selfoss/src/selfoss.sh b/spk/selfoss/src/selfoss.sh deleted file mode 100644 index 96ac93b84c4..00000000000 --- a/spk/selfoss/src/selfoss.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e - -PHP="php" -SELFOSS="/var/services/web/selfoss/update.php" -SLEEP_TIME="600" - -# Main loop -while true; do - # Update - echo "Updating..." - ${PHP} ${SELFOSS} - - # Wait - echo "Waiting ${SLEEP_TIME} seconds..." - sleep ${SLEEP_TIME} -done diff --git a/spk/selfoss/src/service-setup.sh b/spk/selfoss/src/service-setup.sh new file mode 100755 index 00000000000..85283e33988 --- /dev/null +++ b/spk/selfoss/src/service-setup.sh @@ -0,0 +1,200 @@ + +# Selfoss service setup +WEB_DIR="/var/services/web_packages" +# for backwards compatability +if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 7 ];then + WEB_DIR="/var/services/web" +fi +if [ -z "${SYNOPKG_PKGTMP}" ]; then + SYNOPKG_PKGTMP="${SYNOPKG_PKGDEST_VOL}/@tmp" +fi + +# Others +SELFOSS_ROOT="${WEB_DIR}/${SYNOPKG_PKGNAME}" +JQ="/bin/jq" +SYNOSVC="/usr/syno/sbin/synoservice" + +if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + WEB_USER="http" + WEB_GROUP="http" +fi + +set_selfoss_permissions () +{ + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + DIRAPP=$1 + echo "Setting the correct ownership and permissions of the files and folders in ${DIRAPP}" + # Set the ownership for all files and folders to http:http + find -L ${DIRAPP} -type d -print0 | xargs -0 chown ${WEB_USER}:${WEB_GROUP} 2>/dev/null + find -L ${DIRAPP} -type f -print0 | xargs -0 chown ${WEB_USER}:${WEB_GROUP} 2>/dev/null + # Use chmod on files and directories to set permissions to 0750 + find -L ${DIRAPP} -type f -print0 | xargs -0 chmod 750 2>/dev/null + find -L ${DIRAPP} -type d -print0 | xargs -0 chmod 750 2>/dev/null + else + echo "Notice: set_selfoss_permissions() is no longer required on DSM 7." + fi +} + +service_postinst () +{ + # Web interface setup for DSM 6 -- used by INSTALL and UPGRADE + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + # Install the web interface + echo "Installing web interface" + ${MKDIR} ${SELFOSS_ROOT} + rsync -aX ${SYNOPKG_PKGDEST}/share/${SYNOPKG_PKGNAME}/ ${SELFOSS_ROOT} 2>&1 + + # Install web configurations + TEMPDIR="${SYNOPKG_PKGTMP}/web" + ${MKDIR} ${TEMPDIR} + WS_CFG_DIR="/usr/syno/etc/packages/WebStation" + WS_CFG_FILE="WebStation.json" + WS_CFG_PATH="${WS_CFG_DIR}/${WS_CFG_FILE}" + TMP_WS_CFG_PATH="${TEMPDIR}/${WS_CFG_FILE}" + PHP_CFG_FILE="PHPSettings.json" + PHP_CFG_PATH="${WS_CFG_DIR}/${PHP_CFG_FILE}" + TMP_PHP_CFG_PATH="${TEMPDIR}/${PHP_CFG_FILE}" + PHP_PROF_NAME="Default PHP 7.4 Profile" + WS_BACKEND="$(${JQ} -r '.default.backend' ${WS_CFG_PATH})" + WS_PHP="$(${JQ} -r '.default.php' ${WS_CFG_PATH})" + RESTART_APACHE="no" + RSYNC_ARCH_ARGS="--backup --suffix=.bak --remove-source-files" + # Check if Apache is the selected back-end + if [ ! "$WS_BACKEND" = "2" ]; then + echo "Set Apache as the back-end server" + ${JQ} '.default.backend = 2' ${WS_CFG_PATH} > ${TMP_WS_CFG_PATH} + rsync -aX ${RSYNC_ARCH_ARGS} ${TMP_WS_CFG_PATH} ${WS_CFG_DIR}/ 2>&1 + RESTART_APACHE="yes" + fi + # Check if default PHP profile is selected + if [ -z "$WS_PHP" ] || [ "$WS_PHP" = "null" ]; then + echo "Enable default PHP profile" + # Locate default PHP profile + PHP_PROF_ID="$(${JQ} -r '. | to_entries[] | select(.value | type == "object" and .profile_desc == "'"$PHP_PROF_NAME"'") | .key' "${PHP_CFG_PATH}")" + ${JQ} ".default.php = \"$PHP_PROF_ID\"" "${WS_CFG_PATH}" > ${TMP_WS_CFG_PATH} + rsync -aX ${RSYNC_ARCH_ARGS} ${TMP_WS_CFG_PATH} ${WS_CFG_DIR}/ 2>&1 + RESTART_APACHE="yes" + fi + # Check for Selfoss PHP profile + if ! ${JQ} -e '.["com-synocommunity-packages-selfoss"]' "${PHP_CFG_PATH}" >/dev/null; then + echo "Add PHP profile for Selfoss" + ${JQ} --slurpfile ocNode ${SYNOPKG_PKGDEST}/web/selfoss.json '.["com-synocommunity-packages-selfoss"] = $ocNode[0]' ${PHP_CFG_PATH} > ${TMP_PHP_CFG_PATH} + rsync -aX ${RSYNC_ARCH_ARGS} ${TMP_PHP_CFG_PATH} ${WS_CFG_DIR}/ 2>&1 + RESTART_APACHE="yes" + fi + # Check for Selfoss Apache config + if [ ! -f "/usr/local/etc/apache24/sites-enabled/selfoss.conf" ]; then + echo "Add Apache config for Selfoss" + rsync -aX ${SYNOPKG_PKGDEST}/web/selfoss.conf /usr/local/etc/apache24/sites-enabled/ 2>&1 + RESTART_APACHE="yes" + fi + # Restart Apache if configs have changed + if [ "$RESTART_APACHE" = "yes" ]; then + if ${JQ} -e 'to_entries | map(select((.key | startswith("com-synocommunity-packages-")) and .key != "com-synocommunity-packages-selfoss")) | length > 0' "${PHP_CFG_PATH}" >/dev/null; then + echo " [WARNING] Multiple PHP profiles detected, will require restart of DSM to load new configs" + else + echo "Restart Apache to load new configs" + ${SYNOSVC} --restart pkgctl-Apache2.4 + fi + fi + # Clean-up temporary files + ${RM} ${TEMPDIR} + fi + + if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then + # Fix permissions + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + set_selfoss_permissions ${SELFOSS_ROOT} + fi + fi +} + +service_postuninst () +{ + # Web interface removal for DSM 6 -- used by UNINSTALL and UPGRADE + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + # Remove the web interface + echo "Removing web interface" + ${RM} ${SELFOSS_ROOT} + + # Remove web configurations + TEMPDIR="${SYNOPKG_PKGTMP}/web" + ${MKDIR} ${TEMPDIR} + WS_CFG_DIR="/usr/syno/etc/packages/WebStation" + PHP_CFG_FILE="PHPSettings.json" + PHP_CFG_PATH="${WS_CFG_DIR}/${PHP_CFG_FILE}" + TMP_PHP_CFG_PATH="${TEMPDIR}/${PHP_CFG_FILE}" + RESTART_APACHE="no" + RSYNC_ARCH_ARGS="--backup --suffix=.bak --remove-source-files" + # Check for Selfoss PHP profile + if ${JQ} -e '.["com-synocommunity-packages-selfoss"]' "${PHP_CFG_PATH}" >/dev/null; then + echo "Removing PHP profile for Selfoss" + ${JQ} 'del(.["com-synocommunity-packages-selfoss"])' ${PHP_CFG_PATH} > ${TMP_PHP_CFG_PATH} + rsync -aX ${RSYNC_ARCH_ARGS} ${TMP_PHP_CFG_PATH} ${WS_CFG_DIR}/ 2>&1 + ${RM} "${WS_CFG_DIR}/php_profile/com-synocommunity-packages-selfoss" + RESTART_APACHE="yes" + fi + # Check for Selfoss Apache config + if [ -f "/usr/local/etc/apache24/sites-enabled/selfoss.conf" ]; then + echo "Removing Apache config for Selfoss" + ${RM} /usr/local/etc/apache24/sites-enabled/selfoss.conf + RESTART_APACHE="yes" + fi + # Restart Apache if configs have changed + if [ "$RESTART_APACHE" = "yes" ]; then + if ${JQ} -e 'to_entries | map(select((.key | startswith("com-synocommunity-packages-")) and .key != "com-synocommunity-packages-selfoss")) | length > 0' "${PHP_CFG_PATH}" >/dev/null; then + echo " [WARNING] Multiple PHP profiles detected, will require restart of DSM to load new configs" + else + echo "Restart Apache to load new configs" + ${SYNOSVC} --restart pkgctl-Apache2.4 + fi + fi + # Clean-up temporary files + ${RM} ${TEMPDIR} + fi +} + +validate_preinst () +{ + # Check for modification to PHP template defaults on DSM 6 + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + WS_TMPL_DIR="/var/packages/WebStation/target/misc" + WS_TMPL_FILE="php74_fpm.mustache" + WS_TMPL_PATH="${WS_TMPL_DIR}/${WS_TMPL_FILE}" + # Check for PHP template defaults + if ! grep -q -E '^user = http$' "${WS_TMPL_PATH}" || ! grep -q -E '^listen\.owner = http$' "${WS_TMPL_PATH}"; then + echo "PHP template defaults have been modified. Installation is not supported." + exit 1 + fi + fi +} + +service_save () +{ + # Backup configuration and data + [ -d ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} ] && ${RM} ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} + echo "Backup existing distribution to ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}" + ${MKDIR} ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} + rsync -aX ${SELFOSS_ROOT}/ ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} 2>&1 +} + +service_restore () +{ + # Restore data directory + echo "Restore previous data directory from ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/data" + rsync -aX --update -I ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/data ${SELFOSS_ROOT}/ 2>&1 + + # Restore the configuration file + if [ -f ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/config.ini ]; then + echo "Restore previous configuration from ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}" + rsync -aX --update -I ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/config.ini ${SELFOSS_ROOT}/ 2>&1 + fi + + # Fix permissions + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + set_selfoss_permissions ${SELFOSS_ROOT} + fi + + # Remove upgrade backup files + ${RM} ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} +} diff --git a/spk/selfoss/src/web/selfoss.conf b/spk/selfoss/src/web/selfoss.conf new file mode 100644 index 00000000000..d6b9e65dba8 --- /dev/null +++ b/spk/selfoss/src/web/selfoss.conf @@ -0,0 +1,16 @@ +Alias "/selfoss" "/var/services/web/selfoss" + + + ProxySet timeout=3600 + + + + + + SetHandler "proxy:fcgi://selfoss" + + + + DirectoryIndex index.php index.htm index.html + + diff --git a/spk/selfoss/src/web/selfoss.json b/spk/selfoss/src/web/selfoss.json new file mode 100644 index 00000000000..c23e366d82f --- /dev/null +++ b/spk/selfoss/src/web/selfoss.json @@ -0,0 +1,25 @@ +{ + "backend": 8, + "custom_open_basedir": false, + "display_errors": false, + "enable_cache": true, + "enable_xdebug": false, + "extensions": [ + "curl", + "gd", + "imagick", + "openssl", + "pdo_sqlite" + ], + "fpm_settings": { + "max_children": 20, + "max_spare_servers": 3, + "min_spare_servers": 1, + "mode": "dynamic", + "start_servers": 2 + }, + "open_basedir": "", + "php_settings": {}, + "profile_desc": "PHP Profile for Selfoss", + "profile_name": "Selfoss Profile" +} \ No newline at end of file diff --git a/spk/selfoss/src/wizard/install_uifile b/spk/selfoss/src/wizard/install_uifile deleted file mode 100644 index 8846aca0420..00000000000 --- a/spk/selfoss/src/wizard/install_uifile +++ /dev/null @@ -1,18 +0,0 @@ -[{ - "step_title": "Selfoss configuration", - "items": [{ - "type": "password", - "desc": "Enter your MySQL password.", - "subitems": [{ - "key": "wizard_mysql_password_root", - "desc": "Root password" - }] - }, { - "type": "password", - "desc": "A 'selfoss' MySQL user and database will be created. Please enter a password for the 'selfoss' user.", - "subitems": [{ - "key": "wizard_mysql_password_selfoss", - "desc": "Selfoss password" - }] - }] -}] diff --git a/spk/selfoss/src/wizard/install_uifile.sh b/spk/selfoss/src/wizard/install_uifile.sh new file mode 100644 index 00000000000..67f41cd30f3 --- /dev/null +++ b/spk/selfoss/src/wizard/install_uifile.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +quote_json () +{ + sed -e 's|\\|\\\\|g' -e 's|\"|\\\"|g' +} + +page_append () +{ + if [ -z "$1" ]; then + echo "$2" + elif [ -z "$2" ]; then + echo "$1" + else + echo "$1,$2" + fi +} + +# Check for multiple PHP profiles +check_php_profiles () +{ + PHP_CFG_PATH="/usr/syno/etc/packages/WebStation/PHPSettings.json" + if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then + if jq -e 'to_entries | map(select((.key | startswith("com-synocommunity-packages-")) and .key != "com-synocommunity-packages-selfoss")) | length > 0' "${PHP_CFG_PATH}" >/dev/null; then + return 0 # true + else + return 1 # false + fi + fi +} + +PAGE_PHP_PROFILES=$(/bin/cat< "${SYNOPKG_TEMP_LOGFILE}" +} + +main "$@" diff --git a/spk/selfoss/src/wizard/install_uifile_fre b/spk/selfoss/src/wizard/install_uifile_fre deleted file mode 100644 index 02567536b0c..00000000000 --- a/spk/selfoss/src/wizard/install_uifile_fre +++ /dev/null @@ -1,18 +0,0 @@ -[{ - "step_title": "Configuration de Selfoss", - "items": [{ - "type": "password", - "desc": "Saisissez votre mot de passe MySQL.", - "subitems": [{ - "key": "wizard_mysql_password_root", - "desc": "Mot de passe Root" - }] - }, { - "type": "password", - "desc": "Un utilisateur et une base de donnée MySQL 'selfoss' vont être créés. Saisissez un mot de passe pour l'utilisateur 'selfoss'.", - "subitems": [{ - "key": "wizard_mysql_password_selfoss", - "desc": "Mot de passe Selfoss" - }] - }] -}] diff --git a/spk/selfoss/src/wizard/install_uifile_fre.sh b/spk/selfoss/src/wizard/install_uifile_fre.sh new file mode 100644 index 00000000000..d3b1a9e9efd --- /dev/null +++ b/spk/selfoss/src/wizard/install_uifile_fre.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +quote_json () +{ + sed -e 's|\\|\\\\|g' -e 's|\"|\\\"|g' +} + +page_append () +{ + if [ -z "$1" ]; then + echo "$2" + elif [ -z "$2" ]; then + echo "$1" + else + echo "$1,$2" + fi +} + +# Check for multiple PHP profiles +check_php_profiles () +{ + PHP_CFG_PATH="/usr/syno/etc/packages/WebStation/PHPSettings.json" + if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then + if jq -e 'to_entries | map(select((.key | startswith("com-synocommunity-packages-")) and .key != "com-synocommunity-packages-selfoss")) | length > 0' "${PHP_CFG_PATH}" >/dev/null; then + return 0 # true + else + return 1 # false + fi + fi +} + +PAGE_PHP_PROFILES=$(/bin/cat< "${SYNOPKG_TEMP_LOGFILE}" +} + +main "$@" diff --git a/spk/selfoss/src/wizard/uninstall_uifile b/spk/selfoss/src/wizard/uninstall_uifile index 9962d6ffa58..130c556d8b7 100644 --- a/spk/selfoss/src/wizard/uninstall_uifile +++ b/spk/selfoss/src/wizard/uninstall_uifile @@ -1,27 +1,6 @@ [{ "step_title": "Remove selfoss database", "items": [{ - "desc": "Attention: The selfoss database will be removed during package uninstallation. All feeds will be deleted." - }, { - "type": "password", - "desc": "Enter your MySQL password", - "subitems": [{ - "key": "wizard_mysql_password_root", - "desc": "Root password" - }] - }, { - "type": "textfield", - "desc": "Optional: Provide directory for database export. Leave blank to skip export. The directory will be created if it does not exist", - "subitems": [{ - "key": "wizard_dbexport_path", - "desc": "Database export location", - "validator": { - "allowBlank": true, - "regex": { - "expr": "/^\\\/volume[0-9]+\\\//", - "errorText": "Path should begin with /volume?/ with ? the number of the volume" - } - } - }] + "desc": "Attention: The selfoss database will be deleted when uninstalling the package, resulting in the removal of all feeds. Optionally, safeguard your feeds by utilizing the 'Export sources' function in the 'Settings' menu to create a backup." }] }] diff --git a/spk/selfoss/src/wizard/uninstall_uifile_fre b/spk/selfoss/src/wizard/uninstall_uifile_fre index 173b0a408bd..14b8d1f63bd 100644 --- a/spk/selfoss/src/wizard/uninstall_uifile_fre +++ b/spk/selfoss/src/wizard/uninstall_uifile_fre @@ -1,27 +1,6 @@ [{ - "step_title": "Suppression de la base de donnée selfoss", + "step_title": "Supprimer la base de données Selfoss", "items": [{ - "desc": "Si vous supprimez la base de donnée selfoss, tous les flux seront supprimées." - }, { - "type": "password", - "desc": "Saisissez votre mot de passe MySQL", - "subitems": [{ - "key": "wizard_mysql_password_root", - "desc": "Mot de passe Root" - }] - }, { - "type": "textfield", - "desc": "Facultatif: Fournir répertoire pour l'exportation de base de données. Laissez vide pour sauter à l'exportation. Le répertoire sera créé s'il n'existe pas", - "subitems": [{ - "key": "wizard_dbexport_path", - "desc": "L'emplacement de base de données à l'exportation", - "validator": { - "allowBlank": true, - "regex": { - "expr": "/^\\\/volume[0-9]+\\\//", - "errorText": "Chemin doit commencer avec /volume?/ avec ? le numéro du volume" - } - } - }] + "desc": "Attention : La base de données selfoss sera supprimée lors de la désinstallation du package, entraînant la suppression de tous les flux. Vous pouvez éventuellement sauvegarder vos flux en utilisant la fonction « Exporter les sources » dans le menu « Paramètres » pour créer une sauvegarde." }] }]