From 3ef0028b8348aa99ac2cb77009d8645f1dee7444 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sun, 21 Jan 2024 23:50:10 -0400 Subject: [PATCH 01/30] Update makefiles and digests --- cross/fengoffice/Makefile | 12 +++++----- cross/fengoffice/digests | 6 ++--- spk/fengoffice/Makefile | 46 +++++++++++++++++++++++---------------- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index e16e151775c..d4ed00cc644 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,9 +1,8 @@ PKG_NAME = fengoffice -PKG_VERS = 2.5.1.2 -PKG_EXT = zip -PKG_DIST_NAME = $(PKG_NAME)_$(PKG_VERS).$(PKG_EXT) -PKG_DIST_SITE = https://sourceforge.net/projects/opengoo/files/$(PKG_NAME)/$(PKG_NAME)_$(PKG_VERS) -PKG_DIR = $(PKG_NAME)-$(PKG_VERS) +PKG_VERS = 3.10.8.3 +PKG_EXT = tar.gz +PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) DEPENDS = @@ -11,7 +10,6 @@ HOMEPAGE = https://www.fengoffice.com COMMENT = Feng Office is a Collaboration Platform and Project Management System. LICENSE = AGPL -EXTRACT_PATH = $(WORK_DIR)/$(PKG_DIR) CONFIGURE_TARGET = nop COMPILE_TARGET = nop INSTALL_TARGET = fengoffice_install @@ -21,5 +19,5 @@ include ../../mk/spksrc.cross-cc.mk .PHONY: fengoffice_install fengoffice_install: mkdir -p $(STAGING_INSTALL_PREFIX)/share/fengoffice - tar -cf - -C $(WORK_DIR)/$(PKG_DIR)/$(PKG_NAME) . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/fengoffice + tar -cf - -C $(WORK_DIR)/$(PKG_NAME)-$(PKG_VERS) . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/fengoffice install -m 644 src/install_helper.php $(STAGING_INSTALL_PREFIX)/share/fengoffice/public/install/install_helper.php diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index dcb6686b4ed..88fe1322b56 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice_2.5.1.2.zip SHA1 86972fee42a48879d6da80e858407945a028d260 -fengoffice_2.5.1.2.zip SHA256 1c3dfc9ae529cd7a39105d6029fb49d5f1936d77e17aa9af8a97df8888508969 -fengoffice_2.5.1.2.zip MD5 5746ab690c818f36be9b4b7fb4206c2e +fengoffice-3.10.8.3.tar.gz SHA1 329c58cd7f9e8f6095e31e4b2ace5d5298f40690 +fengoffice-3.10.8.3.tar.gz SHA256 e32c1f7ba2ea8a519a2538be28bf074be7503b6e4fd8107bf1a26d577c0d2956 +fengoffice-3.10.8.3.tar.gz MD5 98487fee2e63b00a42e29584e01e6b8e diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index 0cd7ce6a5ff..d4af1fcd850 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,41 +1,49 @@ SPK_NAME = fengoffice -SPK_VERS = 2.5.1.2 -SPK_REV = 3 +SPK_VERS = 3.10.8.3 +SPK_REV = 4 SPK_ICON = src/fengoffice.png -DSM_UI_DIR = app -DEPENDS = cross/busybox cross/$(SPK_NAME) +DEPENDS = cross/$(SPK_NAME) +# Pure PHP package, make sure ARCH is not defined +override ARCH= + +# Due to not obvious WebStation handling requirements +REQUIRED_MIN_DSM = 6.0 +SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = moneytoo DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. -ADMIN_URL = /fengoffice/ DISPLAY_NAME = Feng Office -CHANGELOG = "1. DSM 5.0 compatibility" +CHANGELOG = "1. Update to v3.10.8.3." + +HOMEPAGE = https://www.fengoffice.com/ +LICENSE = AGPL + +STARTABLE = yes +SERVICE_USER = auto +SERVICE_SETUP = src/service-setup.sh -HOMEPAGE = https://www.fengoffice.com/ -LICENSE = AGPL +ADMIN_URL = /fengoffice/ WIZARDS_DIR = src/wizard/ -CONF_DIR = src/conf/ +SYSTEM_GROUP = http -INSTALLER_SCRIPT = src/installer.sh -SSS_SCRIPT = src/dsm-control.sh +DSM_UI_DIR = app +DSM_UI_CONFIG = src/app/config +CONF_DIR = src/conf/ -INSTALL_DEP_SERVICES = apache-web mysql -START_DEP_SERVICES = apache-web mysql +include ../../mk/spksrc.common.mk -INSTALL_PREFIX = /usr/local/$(SPK_NAME) +# Alternate conf dir for DSM 6 +ifeq ($(call version_lt, ${TCVERSION}, 7.0),1) +CONF_DIR = src/conf_6/ +endif POST_STRIP_TARGET = fengoffice_extra_install -BUSYBOX_CONFIG = daemon nice -ENV += BUSYBOX_CONFIG="$(BUSYBOX_CONFIG)" - include ../../mk/spksrc.spk.mk .PHONY: fengoffice_extra_install fengoffice_extra_install: - install -m 755 -d $(STAGING_DIR)/var - install -m 755 src/fengoffice.sh $(STAGING_DIR)/bin/ install -m 755 -d $(STAGING_DIR)/app install -m 644 src/app/config $(STAGING_DIR)/app/config From 9ea559cc6bf6e0ffd8baa3b6214cf8ab6c3a9a11 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:42:41 -0400 Subject: [PATCH 02/30] Update service scripts --- spk/fengoffice/src/dsm-control.sh | 78 -------------- spk/fengoffice/src/fengoffice.sh | 18 ---- spk/fengoffice/src/installer.sh | 144 -------------------------- spk/fengoffice/src/service-setup.sh | 153 ++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+), 240 deletions(-) delete mode 100644 spk/fengoffice/src/dsm-control.sh delete mode 100644 spk/fengoffice/src/fengoffice.sh delete mode 100755 spk/fengoffice/src/installer.sh create mode 100755 spk/fengoffice/src/service-setup.sh diff --git a/spk/fengoffice/src/dsm-control.sh b/spk/fengoffice/src/dsm-control.sh deleted file mode 100644 index 0e96fbbc46d..00000000000 --- a/spk/fengoffice/src/dsm-control.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -# Package -PACKAGE="fengoffice" -DNAME="Feng Office" - -# 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)" -FENGOFFICE="${INSTALL_DIR}/bin/fengoffice.sh" -PID_FILE="${INSTALL_DIR}/var/fengoffice.pid" - - -start_daemon () -{ - start-stop-daemon -S -q -m -b -N 10 -x ${FENGOFFICE} -c ${USER} -u ${USER} -p ${PID_FILE} > /dev/null -} - -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/fengoffice/src/fengoffice.sh b/spk/fengoffice/src/fengoffice.sh deleted file mode 100644 index 79298346a95..00000000000 --- a/spk/fengoffice/src/fengoffice.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e - -PHP="php" -FENGOFFICE="/var/services/web/fengoffice/cron.php" -SLEEP_TIME="600" - -# Main loop -while true; do - # Update - echo "Updating..." - ${PHP} ${FENGOFFICE} - - # Wait - echo "Waiting ${SLEEP_TIME} seconds..." - sleep ${SLEEP_TIME} -done diff --git a/spk/fengoffice/src/installer.sh b/spk/fengoffice/src/installer.sh deleted file mode 100755 index 34feceb6075..00000000000 --- a/spk/fengoffice/src/installer.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/sh - -# Package -PACKAGE="fengoffice" -DNAME="Feng Office" -VERSION="2.5.1.2" - -# 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="fengoffice" -MYSQL_DATABASE="fengoffice" - - -preinst () -{ - 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} - - # 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 run installer - 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_fengoffice:=fengoffice}';" - cd ${WEB_DIR}/${PACKAGE}/public/install/ && QUERY_STRING="script_installer_storage[database_type]=mysql&script_installer_storage[database_host]=localhost&script_installer_storage[database_user]=${MYSQL_USER}&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=fengoffice}&script_installer_storage[database_name]=${MYSQL_DATABASE}&script_installer_storage[database_prefix]=fo_&script_installer_storage[database_engine]=InnoDB&script_installer_storage[absolute_url]=http://${wizard_domain_name:=`hostname`}/${PACKAGE}&script_installer_storage[plugins][]=core_dimensions&script_installer_storage[plugins][]=workspaces&script_installer_storage[plugins][]=mail&submited=submited" php install_helper.php > /dev/null - fi - - # Fix permissions - chown -R ${USER} ${WEB_DIR}/${PACKAGE}/config - chown -R ${USER} ${WEB_DIR}/${PACKAGE}/cache - chown -R ${USER} ${WEB_DIR}/${PACKAGE}/upload - chown -R ${USER} ${WEB_DIR}/${PACKAGE}/tmp - - 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 configuration and files - rm -fr ${TMP_DIR}/${PACKAGE} - mkdir -p ${TMP_DIR}/${PACKAGE} - mv ${WEB_DIR}/${PACKAGE}/config/config.php ${TMP_DIR}/${PACKAGE}/ - mv ${WEB_DIR}/${PACKAGE}/config/installed_version.php ${TMP_DIR}/${PACKAGE}/ - mkdir ${TMP_DIR}/${PACKAGE}/upload/ - cp -r ${WEB_DIR}/${PACKAGE}/upload/*/ ${TMP_DIR}/${PACKAGE}/upload/ - - exit 0 -} - -postupgrade () -{ - # Detect old version - INSTALLED_VERSION=`sed -n "s|return '\(.*\)';|\1|p" ${TMP_DIR}/${PACKAGE}/installed_version.php | xargs` - - # Restore configuration - mv ${TMP_DIR}/${PACKAGE}/config.php ${WEB_DIR}/${PACKAGE}/config/ - cp -r ${TMP_DIR}/${PACKAGE}/upload/*/ ${WEB_DIR}/${PACKAGE}/upload/ - rm -fr ${TMP_DIR}/${PACKAGE} - - # Fix permissions - chown -R ${USER} ${WEB_DIR}/${PACKAGE}/upload - - # Run update scripts - php ${WEB_DIR}/${PACKAGE}/public/upgrade/console.php ${INSTALLED_VERSION} ${VERSION} > /dev/null - php ${WEB_DIR}/${PACKAGE}/public/install/plugin-console.php update_all > /dev/null - - exit 0 -} diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh new file mode 100755 index 00000000000..b0f880c66b4 --- /dev/null +++ b/spk/fengoffice/src/service-setup.sh @@ -0,0 +1,153 @@ + +# Package +SVC_KEEP_LOG=y +SVC_BACKGROUND=y +SVC_WRITE_PID=y + +# Others +MYSQL="/usr/local/mariadb10/bin/mysql" +MYSQLDUMP="/usr/local/mariadb10/bin/mysqldump" +MYSQL_USER="fengoffice" +MYSQL_DATABASE="fengoffice" +PHP="/usr/local/bin/php74" +if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -ge 7 ]; then + WEB_DIR="/var/services/web_packages" +else + WEB_DIR="/var/services/web" + # DSM 6 file and process ownership + WEB_USER="http" + WEB_GROUP="http" +fi + +service_prestart () +{ + FENGOFFICE="${WEB_DIR}/${SYNOPKG_PKGNAME}/cron.php" + COMMAND="${PHP} ${FENGOFFICE}" + SLEEP_TIME="600" + # Main loop + while true; do + # Update + echo "Updating..." + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" >> ${LOG_FILE} 2>&1 + else + $COMMAND >> ${LOG_FILE} 2>&1 + fi + # Wait + echo "Waiting ${SLEEP_TIME} seconds..." + sleep ${SLEEP_TIME} + done & + echo "$!" > "${PID_FILE}" +} + +validate_preinst () +{ + 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 +} + +service_postinst () +{ + # Install the web interface + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + cp -pR ${SYNOPKG_PKGDEST}/share/${SYNOPKG_PKGNAME} ${WEB_DIR} + fi + + # Setup database and run installer + 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_fengoffice:=fengoffice}';" + cd ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/ && QUERY_STRING="script_installer_storage[database_type]=mysql&script_installer_storage[database_host]=localhost&script_installer_storage[database_user]=${MYSQL_USER}&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=fengoffice}&script_installer_storage[database_name]=${MYSQL_DATABASE}&script_installer_storage[database_prefix]=fo_&script_installer_storage[database_engine]=InnoDB&script_installer_storage[absolute_url]=http://${wizard_domain_name:=$(hostname)}/${SYNOPKG_PKGNAME}&script_installer_storage[plugins][]=core_dimensions&script_installer_storage[plugins][]=workspaces&script_installer_storage[plugins][]=mail&submited=submited" php install_helper.php > /dev/null + fi + + # Fix permissions + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/config + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/cache + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/upload + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/tmp + fi +} + +service_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" ] && [ -n "${wizard_dbexport_path}" ]; then + if [ -f "${wizard_dbexport_path}" ] || [ -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 +} + +service_postuninst () +{ + # 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 + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + rm -fr ${WEB_DIR}/${SYNOPKG_PKGNAME} + fi +} + +service_save () +{ + # Save configuration and files + rm -fr ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} + mkdir -p ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} + mv ${WEB_DIR}/${SYNOPKG_PKGNAME}/config/config.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ + mv ${WEB_DIR}/${SYNOPKG_PKGNAME}/config/installed_version.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ + mkdir ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/ + cp -r ${WEB_DIR}/${SYNOPKG_PKGNAME}/upload/*/ ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/ +} + +service_restore () +{ + # Detect package version + PACKAGE_VERSION=$(echo ${SYNOPKG_PKGVER} | cut -d '-' -f 1) + # Detect old version + INSTALLED_VERSION=$(sed -n "s|return '\(.*\)';|\1|p" ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/installed_version.php | xargs) + + # Restore configuration + mv ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/config.php ${WEB_DIR}/${SYNOPKG_PKGNAME}/config/ + cp -r ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/*/ ${WEB_DIR}/${SYNOPKG_PKGNAME}/upload/ + rm -fr ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} + + # Fix permissions + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/upload + fi + + # Run update scripts + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + /bin/su "$WEB_USER" -s /bin/sh -c "${PHP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/upgrade/console.php ${INSTALLED_VERSION} ${PACKAGE_VERSION}" >> ${LOG_FILE} 2>&1 + /bin/su "$WEB_USER" -s /bin/sh -c "${PHP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/plugin-console.php update_all" >> ${LOG_FILE} 2>&1 + else + ${PHP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/upgrade/console.php ${INSTALLED_VERSION} ${PACKAGE_VERSION} >> ${LOG_FILE} 2>&1 + ${PHP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/plugin-console.php update_all >> ${LOG_FILE} 2>&1 + fi +} From 01d1bf310ad744ddd743a52fc71c4f470322b35b Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Fri, 26 Jan 2024 16:10:55 -0400 Subject: [PATCH 03/30] Add resource workers --- spk/fengoffice/src/conf/PKG_DEPS | 2 - spk/fengoffice/src/conf/resource | 68 +++++++++++++++++++++++++++++ spk/fengoffice/src/conf_6/privilege | 53 ++++++++++++++++++++++ spk/fengoffice/src/conf_6/resource | 20 +++++++++ spk/fengoffice/src/service-setup.sh | 6 +-- 5 files changed, 143 insertions(+), 6 deletions(-) delete mode 100644 spk/fengoffice/src/conf/PKG_DEPS create mode 100644 spk/fengoffice/src/conf/resource create mode 100644 spk/fengoffice/src/conf_6/privilege create mode 100644 spk/fengoffice/src/conf_6/resource diff --git a/spk/fengoffice/src/conf/PKG_DEPS b/spk/fengoffice/src/conf/PKG_DEPS deleted file mode 100644 index 9f832e23f1a..00000000000 --- a/spk/fengoffice/src/conf/PKG_DEPS +++ /dev/null @@ -1,2 +0,0 @@ -[MariaDB] -dsm_min_ver=5.0-4300 diff --git a/spk/fengoffice/src/conf/resource b/spk/fengoffice/src/conf/resource new file mode 100644 index 00000000000..fb702fea7e0 --- /dev/null +++ b/spk/fengoffice/src/conf/resource @@ -0,0 +1,68 @@ +{ + "mariadb10-db": { + "admin-account-m10": "root", + "admin-pw-m10": "{{wizard_mysql_password_root}}", + "create-db": { + "db-collision": "error", + "db-name": "fengoffice", + "flag": true + }, + "drop-db-uninst": true, + "drop-user-uninst": true, + "grant-user": { + "db-name": "fengoffice", + "flag": true, + "host": "localhost", + "user-name": "fengoffice", + "user-pw": "{{wizard_mysql_password_fengoffice}}" + } + }, + "webservice": { + "pkg_dir_prepare": [ + { + "group": "http", + "mode": "0755", + "source": "/var/packages/fengoffice/target/share/fengoffice", + "target": "fengoffice", + "user": "sc-fengoffice" + } + ], + "portals": [ + { + "alias": "fengoffice", + "app": "com.synocommunity.packages.fengoffice", + "name": "Feng Office", + "service": "fengoffice", + "type": "alias" + } + ], + "services": [ + { + "backend": 2, + "display_name": "Feng Office", + "icon": "app/images/fengoffice-{0}.png", + "php": { + "backend": 8, + "extensions": [ + "curl", + "gd", + "imagick", + "imap", + "intl", + "mysqli", + "pdo_mysql", + "xmlrpc", + "zip" + ], + "group": "http", + "profile_desc": "PHP Profile for fengoffice", + "profile_name": "fengoffice Profile", + "user": "sc-fengoffice" + }, + "root": "fengoffice", + "service": "fengoffice", + "type": "apache_php" + } + ] + } +} diff --git a/spk/fengoffice/src/conf_6/privilege b/spk/fengoffice/src/conf_6/privilege new file mode 100644 index 00000000000..032e695040d --- /dev/null +++ b/spk/fengoffice/src/conf_6/privilege @@ -0,0 +1,53 @@ +{ + "defaults": { + "run-as": "package" + }, + "username": "sc-fengoffice", + "ctrl-script": [ + { + "action": "preinst", + "run-as": "root" + }, + { + "action": "postinst", + "run-as": "root" + }, + { + "action": "preuninst", + "run-as": "root" + }, + { + "action": "postuninst", + "run-as": "root" + }, + { + "action": "preupgrade", + "run-as": "root" + }, + { + "action": "postupgrade", + "run-as": "root" + }, + { + "action": "start", + "run-as": "root" + }, + { + "action": "stop", + "run-as": "root" + }, + { + "action": "status", + "run-as": "root" + }, + { + "action": "prestart", + "run-as": "root" + }, + { + "action": "prestop", + "run-as": "root" + } + ], + "join-groupname": "http" +} diff --git a/spk/fengoffice/src/conf_6/resource b/spk/fengoffice/src/conf_6/resource new file mode 100644 index 00000000000..de154c311cc --- /dev/null +++ b/spk/fengoffice/src/conf_6/resource @@ -0,0 +1,20 @@ +{ + "mariadb10-db": { + "admin-account-m10": "root", + "admin-pw-m10": "{{wizard_mysql_password_root}}", + "create-db": { + "db-collision": "error", + "db-name": "fengoffice", + "flag": true + }, + "drop-db-uninst": true, + "drop-user-uninst": true, + "grant-user": { + "db-name": "fengoffice", + "flag": true, + "host": "localhost", + "user-name": "fengoffice", + "user-pw": "{{wizard_mysql_password_fengoffice}}" + } + } +} diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index b0f880c66b4..3c3932363e9 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -65,9 +65,8 @@ service_postinst () cp -pR ${SYNOPKG_PKGDEST}/share/${SYNOPKG_PKGNAME} ${WEB_DIR} fi - # Setup database and run installer + # Run installer 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_fengoffice:=fengoffice}';" cd ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/ && QUERY_STRING="script_installer_storage[database_type]=mysql&script_installer_storage[database_host]=localhost&script_installer_storage[database_user]=${MYSQL_USER}&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=fengoffice}&script_installer_storage[database_name]=${MYSQL_DATABASE}&script_installer_storage[database_prefix]=fo_&script_installer_storage[database_engine]=InnoDB&script_installer_storage[absolute_url]=http://${wizard_domain_name:=$(hostname)}/${SYNOPKG_PKGNAME}&script_installer_storage[plugins][]=core_dimensions&script_installer_storage[plugins][]=workspaces&script_installer_storage[plugins][]=mail&submited=submited" php install_helper.php > /dev/null fi @@ -99,13 +98,12 @@ service_preuninst () service_postuninst () { - # Export and remove database + # Export 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 From 1a163d2b8f607d518d1e6e13161d7f60b2b1ea63 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sat, 27 Jan 2024 00:22:00 -0400 Subject: [PATCH 04/30] Amend installer with PHP extensions --- spk/fengoffice/Makefile | 7 ++++--- spk/fengoffice/src/service-setup.sh | 16 +++++++++++++- spk/fengoffice/src/web/fengoffice.conf | 16 ++++++++++++++ spk/fengoffice/src/web/fengoffice.json | 29 ++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 spk/fengoffice/src/web/fengoffice.conf create mode 100644 spk/fengoffice/src/web/fengoffice.json diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index d4af1fcd850..91eb8c1262c 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -44,6 +44,7 @@ POST_STRIP_TARGET = fengoffice_extra_install include ../../mk/spksrc.spk.mk .PHONY: fengoffice_extra_install -fengoffice_extra_install: - install -m 755 -d $(STAGING_DIR)/app - install -m 644 src/app/config $(STAGING_DIR)/app/config +fengoffice_extra_install: + install -m 755 -d $(STAGING_DIR)/web + install -m 644 src/web/fengoffice.conf $(STAGING_DIR)/web/fengoffice.conf + install -m 644 src/web/fengoffice.json $(STAGING_DIR)/web/fengoffice.json diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index 3c3932363e9..e9704e64c3e 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -67,7 +67,21 @@ service_postinst () # Run installer if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then - cd ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/ && QUERY_STRING="script_installer_storage[database_type]=mysql&script_installer_storage[database_host]=localhost&script_installer_storage[database_user]=${MYSQL_USER}&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=fengoffice}&script_installer_storage[database_name]=${MYSQL_DATABASE}&script_installer_storage[database_prefix]=fo_&script_installer_storage[database_engine]=InnoDB&script_installer_storage[absolute_url]=http://${wizard_domain_name:=$(hostname)}/${SYNOPKG_PKGNAME}&script_installer_storage[plugins][]=core_dimensions&script_installer_storage[plugins][]=workspaces&script_installer_storage[plugins][]=mail&submited=submited" php install_helper.php > /dev/null + # Define the resource file + RESOURCE_FILE="${SYNOPKG_PKGDEST}/web/fengoffice.json" + # Extract extensions and assign to variable + PHP_EXTENSIONS=$(jq -r '.extensions[] | "-dextension=" + . + ".so"' "$RESOURCE_FILE") + # Setup parameters for installation script + QUERY_STRING="script_installer_storage[database_type]=mysql&script_installer_storage[database_host]=localhost&script_installer_storage[database_user]=${MYSQL_USER}&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=fengoffice}&script_installer_storage[database_name]=${MYSQL_DATABASE}&script_installer_storage[database_prefix]=fo_&script_installer_storage[database_engine]=InnoDB&script_installer_storage[absolute_url]=http://${wizard_domain_name:=$(hostname)}/${SYNOPKG_PKGNAME}&script_installer_storage[plugins][]=core_dimensions&script_installer_storage[plugins][]=workspaces&script_installer_storage[plugins][]=mail&submited=submited" + # Prepare environment + COMMAND="${PHP} ${PHP_EXTENSIONS} install_helper.php" + cd ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/ || exit 1 + # Execute based on DSM version + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" >> ${LOG_FILE} 2>&1 + else + $COMMAND >> ${LOG_FILE} 2>&1 + fi fi # Fix permissions diff --git a/spk/fengoffice/src/web/fengoffice.conf b/spk/fengoffice/src/web/fengoffice.conf new file mode 100644 index 00000000000..57ca65aafdf --- /dev/null +++ b/spk/fengoffice/src/web/fengoffice.conf @@ -0,0 +1,16 @@ +Alias "/fengoffice" "/var/services/web/fengoffice" + + + ProxySet timeout=3600 + + + + + + SetHandler "proxy:fcgi://fengoffice" + + + + DirectoryIndex index.php index.htm index.html + + diff --git a/spk/fengoffice/src/web/fengoffice.json b/spk/fengoffice/src/web/fengoffice.json new file mode 100644 index 00000000000..6dd55a85200 --- /dev/null +++ b/spk/fengoffice/src/web/fengoffice.json @@ -0,0 +1,29 @@ +{ + "backend": 8, + "custom_open_basedir": false, + "display_errors": false, + "enable_cache": true, + "enable_xdebug": false, + "extensions": [ + "curl", + "gd", + "imagick", + "imap", + "intl", + "mysqli", + "pdo_mysql", + "xmlrpc", + "zip" + ], + "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 fengoffice", + "profile_name": "fengoffice Profile" +} From 66e7fcb7cbbe4a710408415ad12cf2b32814819e Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sat, 27 Jan 2024 11:05:11 -0400 Subject: [PATCH 05/30] Amend service setup formatting and logging --- spk/fengoffice/src/service-setup.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index e9704e64c3e..2c6c3d3873d 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -72,15 +72,27 @@ service_postinst () # Extract extensions and assign to variable PHP_EXTENSIONS=$(jq -r '.extensions[] | "-dextension=" + . + ".so"' "$RESOURCE_FILE") # Setup parameters for installation script - QUERY_STRING="script_installer_storage[database_type]=mysql&script_installer_storage[database_host]=localhost&script_installer_storage[database_user]=${MYSQL_USER}&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=fengoffice}&script_installer_storage[database_name]=${MYSQL_DATABASE}&script_installer_storage[database_prefix]=fo_&script_installer_storage[database_engine]=InnoDB&script_installer_storage[absolute_url]=http://${wizard_domain_name:=$(hostname)}/${SYNOPKG_PKGNAME}&script_installer_storage[plugins][]=core_dimensions&script_installer_storage[plugins][]=workspaces&script_installer_storage[plugins][]=mail&submited=submited" + QUERY_STRING="\ +script_installer_storage[database_type]=mysqli\ +&script_installer_storage[database_host]=localhost\ +&script_installer_storage[database_user]=${MYSQL_USER}\ +&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=fengoffice}\ +&script_installer_storage[database_name]=${MYSQL_DATABASE}\ +&script_installer_storage[database_prefix]=fo_\ +&script_installer_storage[database_engine]=InnoDB\ +&script_installer_storage[absolute_url]=http://${wizard_domain_name:=$(hostname)}/${SYNOPKG_PKGNAME}\ +&script_installer_storage[plugins][]=core_dimensions\ +&script_installer_storage[plugins][]=mail\ +&script_installer_storage[plugins][]=workspaces\ +&submited=submited" # Prepare environment COMMAND="${PHP} ${PHP_EXTENSIONS} install_helper.php" cd ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/ || exit 1 # Execute based on DSM version if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" >> ${LOG_FILE} 2>&1 + /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" > /dev/null else - $COMMAND >> ${LOG_FILE} 2>&1 + $COMMAND > /dev/null fi fi From 50ea9e81621eadaf1867178bdc601b337c2f2251 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:46:33 -0400 Subject: [PATCH 06/30] Add PHP profiles for DSM 6 --- spk/fengoffice/src/service-setup.sh | 189 ++++++++++++++++++++++------ 1 file changed, 154 insertions(+), 35 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index 2c6c3d3873d..ec345757eca 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -1,5 +1,8 @@ # Package +SC_DNAME="Feng Office" +SC_PKG_PREFIX="com-synocommunity-packages-" +SC_PKG_NAME="${SC_PKG_PREFIX}${SYNOPKG_PKGNAME}" SVC_KEEP_LOG=y SVC_BACKGROUND=y SVC_WRITE_PID=y @@ -18,10 +21,11 @@ else WEB_USER="http" WEB_GROUP="http" fi +WEB_ROOT="${WEB_DIR}/${SYNOPKG_PKGNAME}" service_prestart () { - FENGOFFICE="${WEB_DIR}/${SYNOPKG_PKGNAME}/cron.php" + FENGOFFICE="${WEB_ROOT}/cron.php" COMMAND="${PHP} ${FENGOFFICE}" SLEEP_TIME="600" # Main loop @@ -42,6 +46,18 @@ service_prestart () 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 + 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" @@ -60,9 +76,68 @@ validate_preinst () service_postinst () { - # Install the web interface + # Web interface setup for DSM 6 -- used by INSTALL and UPGRADE if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - cp -pR ${SYNOPKG_PKGDEST}/share/${SYNOPKG_PKGNAME} ${WEB_DIR} + # Install the web interface + echo "Installing web interface" + ${MKDIR} ${WEB_ROOT} + rsync -aX ${SYNOPKG_PKGDEST}/share/${SYNOPKG_PKGNAME}/ ${WEB_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 PHP profile + if ! jq -e ".[\"${SC_PKG_NAME}\"]" "${PHP_CFG_PATH}" >/dev/null; then + echo "Add PHP profile for ${SC_DNAME}" + jq --slurpfile newProfile ${SYNOPKG_PKGDEST}/web/${SYNOPKG_PKGNAME}.json '.["'"${SC_PKG_NAME}"'"] = $newProfile[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 Apache config + if [ ! -f "/usr/local/etc/apache24/sites-enabled/${SYNOPKG_PKGNAME}.conf" ]; then + echo "Add Apache config for ${SC_DNAME}" + rsync -aX ${SYNOPKG_PKGDEST}/web/${SYNOPKG_PKGNAME}.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("'"${SC_PKG_PREFIX}"'")) and .key != "'"${SC_PKG_NAME}"'")) | 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 # Run installer @@ -87,7 +162,7 @@ script_installer_storage[database_type]=mysqli\ &submited=submited" # Prepare environment COMMAND="${PHP} ${PHP_EXTENSIONS} install_helper.php" - cd ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/ || exit 1 + cd ${WEB_ROOT}/public/install/ || exit 1 # Execute based on DSM version if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" > /dev/null @@ -98,10 +173,10 @@ script_installer_storage[database_type]=mysqli\ # Fix permissions if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/config - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/cache - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/upload - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/tmp + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/config + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/cache + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/upload + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/tmp fi } @@ -113,40 +188,84 @@ service_preuninst () exit 1 fi - # Check database export location - if [ "${SYNOPKG_PKG_STATUS}" = "UNINSTALL" ] && [ -n "${wizard_dbexport_path}" ]; then - if [ -f "${wizard_dbexport_path}" ] || [ -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 -} - -service_postuninst () -{ - # Export database if [ "${SYNOPKG_PKG_STATUS}" = "UNINSTALL" ]; then + # Check export directory if [ -n "${wizard_dbexport_path}" ]; then - mkdir -p ${wizard_dbexport_path} + if [ ! -d "${wizard_dbexport_path}" ]; then + # If the export path directory does not exist, create it + ${MKDIR} "${wizard_dbexport_path}" || { + # If mkdir fails, print an error message and exit + echo "Error: Unable to create directory ${wizard_dbexport_path}. Check permissions." + exit 1 + } + elif [ ! -w "${wizard_dbexport_path}" ]; then + # If the export path directory is not writable, print an error message and exit + echo "Error: Unable to write to directory ${wizard_dbexport_path}. Check permissions." + exit 1 + elif [ -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 + # Export database ${MYSQLDUMP} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} > ${wizard_dbexport_path}/${MYSQL_DATABASE}.sql fi fi +} - # Remove the web interface +service_postuninst () +{ + # Web interface removal for DSM 6 -- used by UNINSTALL and UPGRADE if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - rm -fr ${WEB_DIR}/${SYNOPKG_PKGNAME} + # Remove the web interface + echo "Removing web interface" + ${RM} ${WEB_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 PHP profile + if jq -e ".[\"${SC_PKG_NAME}\"]" "${PHP_CFG_PATH}" >/dev/null; then + echo "Removing PHP profile for ${SC_DNAME}" + jq 'del(.["'"${SC_PKG_NAME}"'"])' ${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/${SC_PKG_NAME}" + RESTART_APACHE="yes" + fi + # Check for Apache config + if [ -f "/usr/local/etc/apache24/sites-enabled/${SYNOPKG_PKGNAME}.conf" ]; then + echo "Removing Apache config for ${SC_DNAME}" + ${RM} /usr/local/etc/apache24/sites-enabled/${SYNOPKG_PKGNAME}.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("'"${SC_PKG_PREFIX}"'")) and .key != "'"${SC_PKG_NAME}"'")) | 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 } service_save () { # Save configuration and files - rm -fr ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} + [ -d ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} ] && ${RM} ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} mkdir -p ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} - mv ${WEB_DIR}/${SYNOPKG_PKGNAME}/config/config.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ - mv ${WEB_DIR}/${SYNOPKG_PKGNAME}/config/installed_version.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ + mv ${WEB_ROOT}/config/config.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ + mv ${WEB_ROOT}/config/installed_version.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ mkdir ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/ - cp -r ${WEB_DIR}/${SYNOPKG_PKGNAME}/upload/*/ ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/ + cp -r ${WEB_ROOT}/upload/*/ ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/ } service_restore () @@ -157,21 +276,21 @@ service_restore () INSTALLED_VERSION=$(sed -n "s|return '\(.*\)';|\1|p" ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/installed_version.php | xargs) # Restore configuration - mv ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/config.php ${WEB_DIR}/${SYNOPKG_PKGNAME}/config/ - cp -r ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/*/ ${WEB_DIR}/${SYNOPKG_PKGNAME}/upload/ - rm -fr ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} + mv ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/config.php ${WEB_ROOT}/config/ + cp -r ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/*/ ${WEB_ROOT}/upload/ + ${RM} ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} # Fix permissions if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/upload + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/upload fi # Run update scripts if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - /bin/su "$WEB_USER" -s /bin/sh -c "${PHP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/upgrade/console.php ${INSTALLED_VERSION} ${PACKAGE_VERSION}" >> ${LOG_FILE} 2>&1 - /bin/su "$WEB_USER" -s /bin/sh -c "${PHP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/plugin-console.php update_all" >> ${LOG_FILE} 2>&1 + /bin/su "$WEB_USER" -s /bin/sh -c "${PHP} ${WEB_ROOT}/public/upgrade/console.php ${INSTALLED_VERSION} ${PACKAGE_VERSION}" >> ${LOG_FILE} 2>&1 + /bin/su "$WEB_USER" -s /bin/sh -c "${PHP} ${WEB_ROOT}/public/install/plugin-console.php update_all" >> ${LOG_FILE} 2>&1 else - ${PHP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/upgrade/console.php ${INSTALLED_VERSION} ${PACKAGE_VERSION} >> ${LOG_FILE} 2>&1 - ${PHP} ${WEB_DIR}/${SYNOPKG_PKGNAME}/public/install/plugin-console.php update_all >> ${LOG_FILE} 2>&1 + ${PHP} ${WEB_ROOT}/public/upgrade/console.php ${INSTALLED_VERSION} ${PACKAGE_VERSION} >> ${LOG_FILE} 2>&1 + ${PHP} ${WEB_ROOT}/public/install/plugin-console.php update_all >> ${LOG_FILE} 2>&1 fi } From e65ffd5f586e8a17fdaa4b9a750bbcccbdd0ea8b Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sat, 27 Jan 2024 13:43:14 -0400 Subject: [PATCH 07/30] Amend install for database --- spk/fengoffice/src/conf/resource | 6 +++--- spk/fengoffice/src/conf_6/resource | 6 +++--- spk/fengoffice/src/service-setup.sh | 4 ++-- spk/fengoffice/src/wizard/install_uifile | 13 +++++++++++++ spk/fengoffice/src/wizard/upgrade_uifile | 19 +++++++++++++++++++ 5 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 spk/fengoffice/src/wizard/upgrade_uifile diff --git a/spk/fengoffice/src/conf/resource b/spk/fengoffice/src/conf/resource index fb702fea7e0..5c3fe2eb81b 100644 --- a/spk/fengoffice/src/conf/resource +++ b/spk/fengoffice/src/conf/resource @@ -3,15 +3,15 @@ "admin-account-m10": "root", "admin-pw-m10": "{{wizard_mysql_password_root}}", "create-db": { - "db-collision": "error", + "db-collision": "skip", "db-name": "fengoffice", - "flag": true + "flag": "{{wizard_create_db}}" }, "drop-db-uninst": true, "drop-user-uninst": true, "grant-user": { "db-name": "fengoffice", - "flag": true, + "flag": "{{mysql_grant_user}}", "host": "localhost", "user-name": "fengoffice", "user-pw": "{{wizard_mysql_password_fengoffice}}" diff --git a/spk/fengoffice/src/conf_6/resource b/spk/fengoffice/src/conf_6/resource index de154c311cc..495e04d9bf6 100644 --- a/spk/fengoffice/src/conf_6/resource +++ b/spk/fengoffice/src/conf_6/resource @@ -3,15 +3,15 @@ "admin-account-m10": "root", "admin-pw-m10": "{{wizard_mysql_password_root}}", "create-db": { - "db-collision": "error", + "db-collision": "skip", "db-name": "fengoffice", - "flag": true + "flag": "{{wizard_create_db}}" }, "drop-db-uninst": true, "drop-user-uninst": true, "grant-user": { "db-name": "fengoffice", - "flag": true, + "flag": "{{mysql_grant_user}}", "host": "localhost", "user-name": "fengoffice", "user-pw": "{{wizard_mysql_password_fengoffice}}" diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index ec345757eca..fa4326a6649 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -165,9 +165,9 @@ script_installer_storage[database_type]=mysqli\ cd ${WEB_ROOT}/public/install/ || exit 1 # Execute based on DSM version if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" > /dev/null + /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" > /dev/null 2>&1 else - $COMMAND > /dev/null + $COMMAND > /dev/null 2>&1 fi fi diff --git a/spk/fengoffice/src/wizard/install_uifile b/spk/fengoffice/src/wizard/install_uifile index 1a18c3ee0d1..bfbe2506ffa 100644 --- a/spk/fengoffice/src/wizard/install_uifile +++ b/spk/fengoffice/src/wizard/install_uifile @@ -24,5 +24,18 @@ "key": "wizard_domain_name", "desc": "Domain name" }] + }, { + "type": "multiselect", + "subitems": [{ + "key": "wizard_create_db", + "desc": "Creates initial DB", + "defaultValue": true, + "hidden": true + }, { + "key": "mysql_grant_user", + "desc": "Configures user rights", + "defaultValue": true, + "hidden": true + }] }] }] diff --git a/spk/fengoffice/src/wizard/upgrade_uifile b/spk/fengoffice/src/wizard/upgrade_uifile new file mode 100644 index 00000000000..f1dadd4a59f --- /dev/null +++ b/spk/fengoffice/src/wizard/upgrade_uifile @@ -0,0 +1,19 @@ +[{ + "step_title": "Feng Office upgrade", + "items": [{ + "desc": "The upgrading process ensures that your configurations and files are saved prior to updating your setup." + }, { + "type": "multiselect", + "subitems": [{ + "key": "wizard_create_db", + "desc": "Creates initial DB", + "defaultValue": false, + "hidden": true + }, { + "key": "mysql_grant_user", + "desc": "Initializes user rights", + "defaultValue": false, + "hidden": true + }] + }] +}] From 2e0555576c9c5d3782f660676b8963fca3435b8e Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sun, 28 Jan 2024 20:53:23 -0400 Subject: [PATCH 08/30] Enhance install wizard --- spk/fengoffice/src/wizard/install_uifile | 41 ------- spk/fengoffice/src/wizard/install_uifile.sh | 124 ++++++++++++++++++++ 2 files changed, 124 insertions(+), 41 deletions(-) delete mode 100644 spk/fengoffice/src/wizard/install_uifile create mode 100644 spk/fengoffice/src/wizard/install_uifile.sh diff --git a/spk/fengoffice/src/wizard/install_uifile b/spk/fengoffice/src/wizard/install_uifile deleted file mode 100644 index bfbe2506ffa..00000000000 --- a/spk/fengoffice/src/wizard/install_uifile +++ /dev/null @@ -1,41 +0,0 @@ -[{ - "step_title": "Feng Office database configuration", - "items": [{ - "type": "password", - "desc": "Enter your MySQL password.", - "subitems": [{ - "key": "wizard_mysql_password_root", - "desc": "Root password" - }] - }, { - "type": "password", - "desc": "A 'fengoffice' MySQL user and database will be created. Please enter a password for the 'fengoffice' user.", - "subitems": [{ - "key": "wizard_mysql_password_fengoffice", - "desc": "fengoffice password" - }] - }] -}, { - "step_title": "Feng Office configuration", - "items": [{ - "type": "textfield", - "desc": "Domain name of your DiskStation. For example: you.synology.me.", - "subitems": [{ - "key": "wizard_domain_name", - "desc": "Domain name" - }] - }, { - "type": "multiselect", - "subitems": [{ - "key": "wizard_create_db", - "desc": "Creates initial DB", - "defaultValue": true, - "hidden": true - }, { - "key": "mysql_grant_user", - "desc": "Configures user rights", - "defaultValue": true, - "hidden": true - }] - }] -}] diff --git a/spk/fengoffice/src/wizard/install_uifile.sh b/spk/fengoffice/src/wizard/install_uifile.sh new file mode 100644 index 00000000000..675006ce00a --- /dev/null +++ b/spk/fengoffice/src/wizard/install_uifile.sh @@ -0,0 +1,124 @@ +#!/bin/bash + +INTERNAL_IP=$(ip -4 route get 8.8.8.8 | awk '/8.8.8.8/ && /src/ {print $NF}') + +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 +} + +getPasswordValidator() +{ + validator=$(/bin/cat< 0' "${PHP_CFG_PATH}" >/dev/null; then + return 0 # true + else + return 1 # false + fi +} + +PAGE_INSTALL_CONFIG=$(/bin/cat< "${SYNOPKG_TEMP_LOGFILE}" +} + +main "$@" From 4c8231b3ede3c60c64ddd896c9f0e1bda141d196 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sun, 28 Jan 2024 21:06:32 -0400 Subject: [PATCH 09/30] Enhance uninstall wizard --- spk/fengoffice/src/wizard/uninstall_uifile | 27 ------ spk/fengoffice/src/wizard/uninstall_uifile.sh | 91 +++++++++++++++++++ 2 files changed, 91 insertions(+), 27 deletions(-) delete mode 100644 spk/fengoffice/src/wizard/uninstall_uifile create mode 100644 spk/fengoffice/src/wizard/uninstall_uifile.sh diff --git a/spk/fengoffice/src/wizard/uninstall_uifile b/spk/fengoffice/src/wizard/uninstall_uifile deleted file mode 100644 index 717cbe2e203..00000000000 --- a/spk/fengoffice/src/wizard/uninstall_uifile +++ /dev/null @@ -1,27 +0,0 @@ -[{ - "step_title": "Remove fengoffice database", - "items": [{ - "desc": "Attention: The fengoffice database will be removed during package uninstallation. All users and projects 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" - } - } - }] - }] -}] diff --git a/spk/fengoffice/src/wizard/uninstall_uifile.sh b/spk/fengoffice/src/wizard/uninstall_uifile.sh new file mode 100644 index 00000000000..0dda7cd4d63 --- /dev/null +++ b/spk/fengoffice/src/wizard/uninstall_uifile.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +# for backwards compatability +if [ "$SYNOPKG_DSM_VERSION_MAJOR" -lt 7 ] && [ -z "${SYNOPKG_PKGDEST_VOL}" ]; then + SYNOPKG_PKGDEST_VOL="/volume1" +fi + +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 +} + +ERROR_TEXT="Path should begin with /volume?/ with ? the number of the volume" + +getValidPath() +{ + VALID_PATH=$(/bin/cat< "${SYNOPKG_TEMP_LOGFILE}" +} + +main "$@" From 2e2a71a4cbf705659f40e8a55142312ba13a5822 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Mon, 29 Jan 2024 01:20:02 -0400 Subject: [PATCH 10/30] Miscellaneous fixes - Add variable for synoservice - Simplify DSM 6 permissions - Fix mysqli default socket in DSM 6 - Add PHP extension zlib - Amend uninstall wizard text --- spk/fengoffice/src/conf/resource | 3 ++- spk/fengoffice/src/service-setup.sh | 22 ++++++++++--------- spk/fengoffice/src/web/fengoffice.json | 7 ++++-- spk/fengoffice/src/wizard/uninstall_uifile.sh | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/spk/fengoffice/src/conf/resource b/spk/fengoffice/src/conf/resource index 5c3fe2eb81b..24c4770f090 100644 --- a/spk/fengoffice/src/conf/resource +++ b/spk/fengoffice/src/conf/resource @@ -52,7 +52,8 @@ "mysqli", "pdo_mysql", "xmlrpc", - "zip" + "zip", + "zlib" ], "group": "http", "profile_desc": "PHP Profile for fengoffice", diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index fa4326a6649..07a0167cdcb 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -22,6 +22,7 @@ else WEB_GROUP="http" fi WEB_ROOT="${WEB_DIR}/${SYNOPKG_PKGNAME}" +SYNOSVC="/usr/syno/sbin/synoservice" service_prestart () { @@ -140,12 +141,21 @@ service_postinst () ${RM} ${TEMPDIR} fi + # Fix permissions + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT} + fi + # Run installer if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then # Define the resource file RESOURCE_FILE="${SYNOPKG_PKGDEST}/web/fengoffice.json" # Extract extensions and assign to variable - PHP_EXTENSIONS=$(jq -r '.extensions[] | "-dextension=" + . + ".so"' "$RESOURCE_FILE") + PHP_SETTINGS=$(jq -r '.extensions[] | "-d extension=" + . + ".so"' "$RESOURCE_FILE") + # Fix for mysqli default socket on DSM 6 + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + PHP_SETTINGS="${PHP_SETTINGS} -d mysqli.default_socket=/run/mysqld/mysqld10.sock" + fi # Setup parameters for installation script QUERY_STRING="\ script_installer_storage[database_type]=mysqli\ @@ -161,7 +171,7 @@ script_installer_storage[database_type]=mysqli\ &script_installer_storage[plugins][]=workspaces\ &submited=submited" # Prepare environment - COMMAND="${PHP} ${PHP_EXTENSIONS} install_helper.php" + COMMAND="${PHP} ${PHP_SETTINGS} install_helper.php" cd ${WEB_ROOT}/public/install/ || exit 1 # Execute based on DSM version if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then @@ -170,14 +180,6 @@ script_installer_storage[database_type]=mysqli\ $COMMAND > /dev/null 2>&1 fi fi - - # Fix permissions - if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/config - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/cache - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/upload - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT}/tmp - fi } service_preuninst () diff --git a/spk/fengoffice/src/web/fengoffice.json b/spk/fengoffice/src/web/fengoffice.json index 6dd55a85200..7d288462557 100644 --- a/spk/fengoffice/src/web/fengoffice.json +++ b/spk/fengoffice/src/web/fengoffice.json @@ -13,7 +13,8 @@ "mysqli", "pdo_mysql", "xmlrpc", - "zip" + "zip", + "zlib" ], "fpm_settings": { "max_children": 20, @@ -23,7 +24,9 @@ "start_servers": 2 }, "open_basedir": "", - "php_settings": {}, + "php_settings": { + "mysqli.default_socket": "/run/mysqld/mysqld10.sock" + }, "profile_desc": "PHP Profile for fengoffice", "profile_name": "fengoffice Profile" } diff --git a/spk/fengoffice/src/wizard/uninstall_uifile.sh b/spk/fengoffice/src/wizard/uninstall_uifile.sh index 0dda7cd4d63..3b83a4f19d8 100644 --- a/spk/fengoffice/src/wizard/uninstall_uifile.sh +++ b/spk/fengoffice/src/wizard/uninstall_uifile.sh @@ -60,7 +60,7 @@ PAGE_UNINSTALL_CONFIG=$(/bin/cat< Date: Mon, 29 Jan 2024 12:22:41 -0400 Subject: [PATCH 11/30] Add PHP script launcher --- spk/fengoffice/src/service-setup.sh | 56 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index 07a0167cdcb..afc28fa3def 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -12,7 +12,6 @@ MYSQL="/usr/local/mariadb10/bin/mysql" MYSQLDUMP="/usr/local/mariadb10/bin/mysqldump" MYSQL_USER="fengoffice" MYSQL_DATABASE="fengoffice" -PHP="/usr/local/bin/php74" if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -ge 7 ]; then WEB_DIR="/var/services/web_packages" else @@ -24,20 +23,38 @@ fi WEB_ROOT="${WEB_DIR}/${SYNOPKG_PKGNAME}" SYNOSVC="/usr/syno/sbin/synoservice" +exec_php() { + PHP="/usr/local/bin/php74" + # Define the resource file + RESOURCE_FILE="${SYNOPKG_PKGDEST}/web/fengoffice.json" + # Extract extensions and assign to variable + if [ -f "$RESOURCE_FILE" ]; then + PHP_SETTINGS=$(jq -r '.extensions | map("-d extension=" + . + ".so") | join(" ")' "$RESOURCE_FILE") + else + PHP_SETTINGS="" + fi + # Fix for mysqli default socket on DSM 6 + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + PHP_SETTINGS="${PHP_SETTINGS} -d mysqli.default_socket=/run/mysqld/mysqld10.sock" + fi + COMMAND="${PHP} ${PHP_SETTINGS} $*" + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" >> ${LOG_FILE} 2>&1 + else + $COMMAND >> ${LOG_FILE} 2>&1 + fi + return $? +} + service_prestart () { FENGOFFICE="${WEB_ROOT}/cron.php" - COMMAND="${PHP} ${FENGOFFICE}" SLEEP_TIME="600" # Main loop while true; do # Update echo "Updating..." - if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" >> ${LOG_FILE} 2>&1 - else - $COMMAND >> ${LOG_FILE} 2>&1 - fi + exec_php "${FENGOFFICE}" # Wait echo "Waiting ${SLEEP_TIME} seconds..." sleep ${SLEEP_TIME} @@ -148,14 +165,6 @@ service_postinst () # Run installer if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then - # Define the resource file - RESOURCE_FILE="${SYNOPKG_PKGDEST}/web/fengoffice.json" - # Extract extensions and assign to variable - PHP_SETTINGS=$(jq -r '.extensions[] | "-d extension=" + . + ".so"' "$RESOURCE_FILE") - # Fix for mysqli default socket on DSM 6 - if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - PHP_SETTINGS="${PHP_SETTINGS} -d mysqli.default_socket=/run/mysqld/mysqld10.sock" - fi # Setup parameters for installation script QUERY_STRING="\ script_installer_storage[database_type]=mysqli\ @@ -171,14 +180,10 @@ script_installer_storage[database_type]=mysqli\ &script_installer_storage[plugins][]=workspaces\ &submited=submited" # Prepare environment - COMMAND="${PHP} ${PHP_SETTINGS} install_helper.php" cd ${WEB_ROOT}/public/install/ || exit 1 # Execute based on DSM version - if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - /bin/su "$WEB_USER" -s /bin/sh -c "${COMMAND}" > /dev/null 2>&1 - else - $COMMAND > /dev/null 2>&1 - fi + echo "Run ${SC_DNAME} installer" + exec_php "install_helper.php" fi } @@ -288,11 +293,6 @@ service_restore () fi # Run update scripts - if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - /bin/su "$WEB_USER" -s /bin/sh -c "${PHP} ${WEB_ROOT}/public/upgrade/console.php ${INSTALLED_VERSION} ${PACKAGE_VERSION}" >> ${LOG_FILE} 2>&1 - /bin/su "$WEB_USER" -s /bin/sh -c "${PHP} ${WEB_ROOT}/public/install/plugin-console.php update_all" >> ${LOG_FILE} 2>&1 - else - ${PHP} ${WEB_ROOT}/public/upgrade/console.php ${INSTALLED_VERSION} ${PACKAGE_VERSION} >> ${LOG_FILE} 2>&1 - ${PHP} ${WEB_ROOT}/public/install/plugin-console.php update_all >> ${LOG_FILE} 2>&1 - fi + exec_php "${WEB_ROOT}/public/upgrade/console.php" "${INSTALLED_VERSION}" "${PACKAGE_VERSION}" + exec_php "${WEB_ROOT}/public/install/plugin-console.php" "update_all" } From b796db78d0aaa94ecf34dd39e686758692f704c9 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Thu, 1 Feb 2024 20:25:04 -0400 Subject: [PATCH 12/30] Bump to v3.10.8.6 --- cross/fengoffice/Makefile | 2 +- cross/fengoffice/digests | 6 +++--- spk/fengoffice/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index d4ed00cc644..fdbed848750 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,5 +1,5 @@ PKG_NAME = fengoffice -PKG_VERS = 3.10.8.3 +PKG_VERS = 3.10.8.6 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index 88fe1322b56..448f429f79c 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice-3.10.8.3.tar.gz SHA1 329c58cd7f9e8f6095e31e4b2ace5d5298f40690 -fengoffice-3.10.8.3.tar.gz SHA256 e32c1f7ba2ea8a519a2538be28bf074be7503b6e4fd8107bf1a26d577c0d2956 -fengoffice-3.10.8.3.tar.gz MD5 98487fee2e63b00a42e29584e01e6b8e +fengoffice-3.10.8.6.tar.gz SHA1 bbd92daa43b6e2ba6078d6022268dbc917556579 +fengoffice-3.10.8.6.tar.gz SHA256 4a7613999ad825ace067673a8de7623265170eebff2395e0125f11e35aaa65e6 +fengoffice-3.10.8.6.tar.gz MD5 ee13d759db08ed1344af0028d2f9cc96 diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index 91eb8c1262c..f403681c843 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,5 +1,5 @@ SPK_NAME = fengoffice -SPK_VERS = 3.10.8.3 +SPK_VERS = 3.10.8.6 SPK_REV = 4 SPK_ICON = src/fengoffice.png @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = moneytoo DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.10.8.3." +CHANGELOG = "1. Update to v3.10.8.6.
2. Add PHP profiles for DSM 6." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL From 9fadfa59dbc821e3bf6da2defa9f9763db30c3be Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:48:58 -0400 Subject: [PATCH 13/30] Bump to v3.10.8.21 --- cross/fengoffice/Makefile | 2 +- cross/fengoffice/digests | 6 +++--- spk/fengoffice/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index fdbed848750..9680eb4fbbd 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,5 +1,5 @@ PKG_NAME = fengoffice -PKG_VERS = 3.10.8.6 +PKG_VERS = 3.10.8.21 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index 448f429f79c..dea4a1b18a1 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice-3.10.8.6.tar.gz SHA1 bbd92daa43b6e2ba6078d6022268dbc917556579 -fengoffice-3.10.8.6.tar.gz SHA256 4a7613999ad825ace067673a8de7623265170eebff2395e0125f11e35aaa65e6 -fengoffice-3.10.8.6.tar.gz MD5 ee13d759db08ed1344af0028d2f9cc96 +fengoffice-3.10.8.21.tar.gz SHA1 89ca4018bcf68f486babcebbebb4bf485172c7f5 +fengoffice-3.10.8.21.tar.gz SHA256 96c012fdd1cc6433011763c04a0c89f09d8e9ea7052eee6d312b2159777d79fd +fengoffice-3.10.8.21.tar.gz MD5 de08c2cfa00bfa5c4add5882003721ce diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index f403681c843..cc90bb92704 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,5 +1,5 @@ SPK_NAME = fengoffice -SPK_VERS = 3.10.8.6 +SPK_VERS = 3.10.8.21 SPK_REV = 4 SPK_ICON = src/fengoffice.png @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = moneytoo DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.10.8.6.
2. Add PHP profiles for DSM 6." +CHANGELOG = "1. Update to v3.10.8.21.
2. Add PHP profiles for DSM 6." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL From 0af9b445d4f39ece681d474e9183f8a7330bddb8 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sun, 7 Apr 2024 15:46:38 -0400 Subject: [PATCH 14/30] Simplify DSM6 privilage file --- spk/fengoffice/src/conf_6/privilege | 48 +---------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/spk/fengoffice/src/conf_6/privilege b/spk/fengoffice/src/conf_6/privilege index 032e695040d..1491ce3109b 100644 --- a/spk/fengoffice/src/conf_6/privilege +++ b/spk/fengoffice/src/conf_6/privilege @@ -1,53 +1,7 @@ { "defaults": { - "run-as": "package" + "run-as": "root" }, "username": "sc-fengoffice", - "ctrl-script": [ - { - "action": "preinst", - "run-as": "root" - }, - { - "action": "postinst", - "run-as": "root" - }, - { - "action": "preuninst", - "run-as": "root" - }, - { - "action": "postuninst", - "run-as": "root" - }, - { - "action": "preupgrade", - "run-as": "root" - }, - { - "action": "postupgrade", - "run-as": "root" - }, - { - "action": "start", - "run-as": "root" - }, - { - "action": "stop", - "run-as": "root" - }, - { - "action": "status", - "run-as": "root" - }, - { - "action": "prestart", - "run-as": "root" - }, - { - "action": "prestop", - "run-as": "root" - } - ], "join-groupname": "http" } From 288372e0c6dbdded33fdee60245dd3e456847182 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:13:31 -0400 Subject: [PATCH 15/30] Bump to v3.11.1.2 --- cross/fengoffice/Makefile | 2 +- cross/fengoffice/digests | 6 +++--- spk/fengoffice/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index 9680eb4fbbd..5e2efaeafbf 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,5 +1,5 @@ PKG_NAME = fengoffice -PKG_VERS = 3.10.8.21 +PKG_VERS = 3.11.1.2 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index dea4a1b18a1..73c5390cf2d 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice-3.10.8.21.tar.gz SHA1 89ca4018bcf68f486babcebbebb4bf485172c7f5 -fengoffice-3.10.8.21.tar.gz SHA256 96c012fdd1cc6433011763c04a0c89f09d8e9ea7052eee6d312b2159777d79fd -fengoffice-3.10.8.21.tar.gz MD5 de08c2cfa00bfa5c4add5882003721ce +fengoffice-3.11.1.2.tar.gz SHA1 8bd215af898a0e95c256ffaf042e3946f4371a0a +fengoffice-3.11.1.2.tar.gz SHA256 21719faadee76351b6ab7e2fccdfb1c9b0db909c82091bae6e139d636f24aed3 +fengoffice-3.11.1.2.tar.gz MD5 5ef5f1c457225fb5d37e4ff984bf98bf diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index cc90bb92704..b2c373a69e7 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,5 +1,5 @@ SPK_NAME = fengoffice -SPK_VERS = 3.10.8.21 +SPK_VERS = 3.11.1.2 SPK_REV = 4 SPK_ICON = src/fengoffice.png @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = moneytoo DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.10.8.21.
2. Add PHP profiles for DSM 6." +CHANGELOG = "1. Update to v3.11.1.2.
2. Add PHP profiles for DSM 6." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL From fea4c5eb70a6ad8cc34fa11bea382adba91bae2e Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Tue, 10 Sep 2024 21:30:31 -0400 Subject: [PATCH 16/30] Bump to v3.11.1.19 --- cross/fengoffice/Makefile | 2 +- cross/fengoffice/digests | 6 +++--- spk/fengoffice/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index 5e2efaeafbf..b8b283ce7b2 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,5 +1,5 @@ PKG_NAME = fengoffice -PKG_VERS = 3.11.1.2 +PKG_VERS = 3.11.1.19 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index 73c5390cf2d..8bc87a4c522 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice-3.11.1.2.tar.gz SHA1 8bd215af898a0e95c256ffaf042e3946f4371a0a -fengoffice-3.11.1.2.tar.gz SHA256 21719faadee76351b6ab7e2fccdfb1c9b0db909c82091bae6e139d636f24aed3 -fengoffice-3.11.1.2.tar.gz MD5 5ef5f1c457225fb5d37e4ff984bf98bf +fengoffice-3.11.1.19.tar.gz SHA1 5f611493ec274f55365a16c4fb04ead8c298f3bc +fengoffice-3.11.1.19.tar.gz SHA256 61fef62313ae9e9ec014a93b28b904be4bf1e2b254170e89a29af779c369210b +fengoffice-3.11.1.19.tar.gz MD5 098317a5f15731001f33cd6e81b4c8c1 diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index b2c373a69e7..cc4f1d6ba39 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,5 +1,5 @@ SPK_NAME = fengoffice -SPK_VERS = 3.11.1.2 +SPK_VERS = 3.11.1.19 SPK_REV = 4 SPK_ICON = src/fengoffice.png @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = moneytoo DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.11.1.2.
2. Add PHP profiles for DSM 6." +CHANGELOG = "1. Update to v3.11.1.19.
2. Add PHP profiles for DSM 6." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL From d769ace6264b2582bb8e9e7e87b4aee3841471bf Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Tue, 10 Sep 2024 23:19:04 -0400 Subject: [PATCH 17/30] Implement backup function --- spk/fengoffice/src/service-setup.sh | 68 +++++++++++++++---- spk/fengoffice/src/wizard/uninstall_uifile.sh | 8 +-- 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index afc28fa3def..5bb0cd145da 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -23,7 +23,8 @@ fi WEB_ROOT="${WEB_DIR}/${SYNOPKG_PKGNAME}" SYNOSVC="/usr/syno/sbin/synoservice" -exec_php() { +exec_php () +{ PHP="/usr/local/bin/php74" # Define the resource file RESOURCE_FILE="${SYNOPKG_PKGDEST}/web/fengoffice.json" @@ -46,6 +47,26 @@ exec_php() { return $? } +get_installed_version () +{ + PHP="/usr/local/bin/php74" + INST_VER="${WEB_ROOT}/config/installed_version.php" + + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + # Prefix the command to change the running user + COMMAND="/bin/su \"$WEB_USER\" -s /bin/sh -c \"${PHP} -r 'echo include \\\"${INST_VER}\\\";'\"" + else + # Run the command directly + COMMAND="${PHP} -r 'echo include \"${INST_VER}\";'" + fi + + # Execute the command and capture the output + INSTALLED_VERSION=$(eval $COMMAND) + + # Output the installed version + echo $INSTALLED_VERSION +} + service_prestart () { FENGOFFICE="${WEB_ROOT}/cron.php" @@ -197,24 +218,47 @@ service_preuninst () if [ "${SYNOPKG_PKG_STATUS}" = "UNINSTALL" ]; then # Check export directory - if [ -n "${wizard_dbexport_path}" ]; then - if [ ! -d "${wizard_dbexport_path}" ]; then + if [ -n "${wizard_export_path}" ]; then + if [ ! -d "${wizard_export_path}" ]; then # If the export path directory does not exist, create it - ${MKDIR} "${wizard_dbexport_path}" || { + ${MKDIR} "${wizard_export_path}" || { # If mkdir fails, print an error message and exit - echo "Error: Unable to create directory ${wizard_dbexport_path}. Check permissions." + echo "Error: Unable to create directory ${wizard_export_path}. Check permissions." exit 1 } - elif [ ! -w "${wizard_dbexport_path}" ]; then + elif [ ! -w "${wizard_export_path}" ]; then # If the export path directory is not writable, print an error message and exit - echo "Error: Unable to write to directory ${wizard_dbexport_path}. Check permissions." - exit 1 - elif [ -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" + echo "Error: Unable to write to directory ${wizard_export_path}. Check permissions." exit 1 fi - # Export database - ${MYSQLDUMP} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} > ${wizard_dbexport_path}/${MYSQL_DATABASE}.sql + + # Prepare archive structure + FENG_VER=$(get_installed_version) + TEMPDIR="${SYNOPKG_PKGTMP}/${SYNOPKG_PKGNAME}_backup_v${FENG_VER}_$(date +"%Y%m%d")" + ${MKDIR} "${TEMPDIR}" + + # Backup Directories + echo "Copying previous configuration and data from ${WEB_ROOT}" + rsync -aX "${WEB_ROOT}" "${TEMPDIR}/" 2>&1 + + # Backup the Database + echo "Copying previous database from ${MYSQL_DATABASE}" + ${MKDIR} "${TEMPDIR}/database" + ${MYSQLDUMP} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} > ${TEMPDIR}/database/${MYSQL_DATABASE}-dbbackup.sql 2>&1 + + # Create backup archive + archive_name="$(basename "$TEMPDIR").tar.gz" + echo "Creating compressed archive of ${SC_DNAME} data in file $archive_name" + tar -C "$TEMPDIR" -czf "${SYNOPKG_PKGTMP}/$archive_name" . 2>&1 + + # Move archive to export directory + RSYNC_BAK_ARGS="--backup --suffix=.bak" + rsync -aX ${RSYNC_BAK_ARGS} "${SYNOPKG_PKGTMP}/$archive_name" "${wizard_export_path}/" 2>&1 + echo "Backup file copied successfully to ${wizard_export_path}" + + # Clean-up temporary files + ${RM} "${TEMPDIR}" + ${RM} "${SYNOPKG_PKGTMP}/$archive_name" fi fi } diff --git a/spk/fengoffice/src/wizard/uninstall_uifile.sh b/spk/fengoffice/src/wizard/uninstall_uifile.sh index 3b83a4f19d8..0bd6548adf1 100644 --- a/spk/fengoffice/src/wizard/uninstall_uifile.sh +++ b/spk/fengoffice/src/wizard/uninstall_uifile.sh @@ -60,11 +60,11 @@ PAGE_UNINSTALL_CONFIG=$(/bin/cat< Date: Wed, 11 Sep 2024 12:20:14 -0400 Subject: [PATCH 18/30] Implement restore function --- spk/fengoffice/src/service-setup.sh | 83 +++++++---- spk/fengoffice/src/wizard/install_uifile.sh | 148 +++++++++++++++++--- 2 files changed, 185 insertions(+), 46 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index 5bb0cd145da..e753a9af53c 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -47,26 +47,6 @@ exec_php () return $? } -get_installed_version () -{ - PHP="/usr/local/bin/php74" - INST_VER="${WEB_ROOT}/config/installed_version.php" - - if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - # Prefix the command to change the running user - COMMAND="/bin/su \"$WEB_USER\" -s /bin/sh -c \"${PHP} -r 'echo include \\\"${INST_VER}\\\";'\"" - else - # Run the command directly - COMMAND="${PHP} -r 'echo include \"${INST_VER}\";'" - fi - - # Execute the command and capture the output - INSTALLED_VERSION=$(eval $COMMAND) - - # Output the installed version - echo $INSTALLED_VERSION -} - service_prestart () { FENGOFFICE="${WEB_ROOT}/cron.php" @@ -110,6 +90,22 @@ validate_preinst () echo "MySQL database ${MYSQL_DATABASE} already exists" exit 1 fi + + # Check for valid backup to restore + if [ "${wizard_fengoffice_restore}" = "true" ] && [ -n "${wizard_backup_file}" ]; then + if [ ! -f "${wizard_backup_file}" ]; then + echo "The backup file path specified is incorrect or not accessible" + exit 1 + fi + # Check backup file prefix + filename=$(basename "${wizard_backup_file}") + expected_prefix="${SYNOPKG_PKGNAME}_backup_v" + + if [ "${filename#"$expected_prefix"}" = "$filename" ]; then + echo "The backup filename does not start with the expected prefix" + exit 1 + fi + fi fi } @@ -181,13 +177,39 @@ service_postinst () # Fix permissions if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT} + chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT} 2>/dev/null fi - # Run installer if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then - # Setup parameters for installation script - QUERY_STRING="\ + # Check restore action + if [ "${wizard_rengoffice_restore}" = "true" ]; then + echo "The backup file is valid, performing restore" + # Extract archive to temp folder + TEMPDIR="${SYNOPKG_PKGTMP}/${SYNOPKG_PKGNAME}" + ${MKDIR} "${TEMPDIR}" + tar -xzf "${wizard_backup_file}" -C "${TEMPDIR}" 2>&1 + # Fix file ownership + if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then + chown -R ${WEB_USER}:${WEB_GROUP} ${TEMPDIR} 2>/dev/null + fi + + # Restore configuration and data + [ -d ${WEB_DIR}/${SYNOPKG_PKGNAME} ] && ${RM} ${WEB_DIR}/${SYNOPKG_PKGNAME} + echo "Restoring configuration and data to ${WEB_DIR}" + rsync -aX --update -I "${TEMPDIR}/${SYNOPKG_PKGNAME}" "${WEB_DIR}/" 2>&1 + + # Update database password + sed -i "s/^\(\s*define('DB_PASS',\s*'\).*\(');*\)$/\1${wizard_mysql_password_fengoffice}\2/" ${WEB_ROOT}/config/config.php + + # Restore the Database + echo "Restoring database to ${MYSQL_DATABASE}" + ${MYSQL} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} < ${TEMPDIR}/database/${MYSQL_DATABASE}-dbbackup.sql 2>&1 + + # Clean-up temporary files + ${RM} "${TEMPDIR}" + else + # Setup parameters for installation script + QUERY_STRING="\ script_installer_storage[database_type]=mysqli\ &script_installer_storage[database_host]=localhost\ &script_installer_storage[database_user]=${MYSQL_USER}\ @@ -200,11 +222,12 @@ script_installer_storage[database_type]=mysqli\ &script_installer_storage[plugins][]=mail\ &script_installer_storage[plugins][]=workspaces\ &submited=submited" - # Prepare environment - cd ${WEB_ROOT}/public/install/ || exit 1 - # Execute based on DSM version - echo "Run ${SC_DNAME} installer" - exec_php "install_helper.php" + # Prepare environment + cd ${WEB_ROOT}/public/install/ || exit 1 + # Execute based on DSM version + echo "Run ${SC_DNAME} installer" + exec_php "install_helper.php" + fi fi } @@ -233,7 +256,7 @@ service_preuninst () fi # Prepare archive structure - FENG_VER=$(get_installed_version) + FENG_VER=$(sed -n "s|return '\(.*\)';|\1|p" ${WEB_ROOT}/config/installed_version.php | xargs) TEMPDIR="${SYNOPKG_PKGTMP}/${SYNOPKG_PKGNAME}_backup_v${FENG_VER}_$(date +"%Y%m%d")" ${MKDIR} "${TEMPDIR}" diff --git a/spk/fengoffice/src/wizard/install_uifile.sh b/spk/fengoffice/src/wizard/install_uifile.sh index 675006ce00a..e62751d1bdb 100644 --- a/spk/fengoffice/src/wizard/install_uifile.sh +++ b/spk/fengoffice/src/wizard/install_uifile.sh @@ -18,6 +18,92 @@ page_append () fi } +RESTORE_BACKUP_FILE="wizard_rengoffice_restore" +BACKUP_FILE_PATH="wizard_backup_file" +RESTORE_ERROR_TEXT="An empty file path is not allowed when restore is enabled." +INSTALL_NEW_INSTANCE="wizard_rengoffice_install" +DOMAIN_NAME="wizard_domain_name" +INSTALL_ERROR_TEXT="An empty domain name is not allowed when install is enabled." + +checkNewInstall() +{ + CHECK_NEW_INSTALL=$(/bin/cat< Date: Wed, 11 Sep 2024 12:27:56 -0400 Subject: [PATCH 19/30] Minor fix for install wizard --- spk/fengoffice/src/wizard/install_uifile.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spk/fengoffice/src/wizard/install_uifile.sh b/spk/fengoffice/src/wizard/install_uifile.sh index e62751d1bdb..c1b009d248e 100644 --- a/spk/fengoffice/src/wizard/install_uifile.sh +++ b/spk/fengoffice/src/wizard/install_uifile.sh @@ -1,5 +1,9 @@ #!/bin/bash +# for backwards compatability +if [ -z ${SYNOPKG_PKGDEST_VOL} ]; then + SYNOPKG_PKGDEST_VOL="/volume1" +fi INTERNAL_IP=$(ip -4 route get 8.8.8.8 | awk '/8.8.8.8/ && /src/ {print $NF}') quote_json () @@ -52,7 +56,9 @@ checkDomainName() var step = arguments[2]; var domainName = step.getComponent("${DOMAIN_NAME}"); if (installNew) { - domainName.setValue("${DOMAIN_NAME}"); + if (domainName.getValue() === "") { + domainName.setValue("${INTERNAL_IP}"); + } domainName.setDisabled(false); } else { domainName.setValue(""); From b26991856a68d0ebfdebf2bdcfcad6e067831d2d Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:59:57 -0400 Subject: [PATCH 20/30] Minor fix for install scripts --- spk/fengoffice/src/service-setup.sh | 14 +++++++++++--- spk/fengoffice/src/wizard/install_uifile.sh | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index e753a9af53c..99b1b4fe5cd 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -182,7 +182,7 @@ service_postinst () if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then # Check restore action - if [ "${wizard_rengoffice_restore}" = "true" ]; then + if [ "${wizard_fengoffice_restore}" = "true" ]; then echo "The backup file is valid, performing restore" # Extract archive to temp folder TEMPDIR="${SYNOPKG_PKGTMP}/${SYNOPKG_PKGNAME}" @@ -194,17 +194,25 @@ service_postinst () fi # Restore configuration and data - [ -d ${WEB_DIR}/${SYNOPKG_PKGNAME} ] && ${RM} ${WEB_DIR}/${SYNOPKG_PKGNAME} echo "Restoring configuration and data to ${WEB_DIR}" rsync -aX --update -I "${TEMPDIR}/${SYNOPKG_PKGNAME}" "${WEB_DIR}/" 2>&1 # Update database password - sed -i "s/^\(\s*define('DB_PASS',\s*'\).*\(');*\)$/\1${wizard_mysql_password_fengoffice}\2/" ${WEB_ROOT}/config/config.php + sed -i "s/^\(\s*define('DB_PASS',\s*'\).*\(');\s*\)$/\1${wizard_mysql_password_fengoffice}\2/" ${WEB_ROOT}/config/config.php # Restore the Database echo "Restoring database to ${MYSQL_DATABASE}" ${MYSQL} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} < ${TEMPDIR}/database/${MYSQL_DATABASE}-dbbackup.sql 2>&1 + # Detect package version + PACKAGE_VERSION=$(echo ${SYNOPKG_PKGVER} | cut -d '-' -f 1) + # Detect old version + INSTALLED_VERSION=$(sed -n "s|return '\(.*\)';|\1|p" ${WEB_ROOT}/config/installed_version.php | xargs) + + # Run update scripts + exec_php "${WEB_ROOT}/public/upgrade/console.php" "${INSTALLED_VERSION}" "${PACKAGE_VERSION}" + exec_php "${WEB_ROOT}/public/install/plugin-console.php" "update_all" + # Clean-up temporary files ${RM} "${TEMPDIR}" else diff --git a/spk/fengoffice/src/wizard/install_uifile.sh b/spk/fengoffice/src/wizard/install_uifile.sh index c1b009d248e..a529445c03d 100644 --- a/spk/fengoffice/src/wizard/install_uifile.sh +++ b/spk/fengoffice/src/wizard/install_uifile.sh @@ -22,10 +22,10 @@ page_append () fi } -RESTORE_BACKUP_FILE="wizard_rengoffice_restore" +RESTORE_BACKUP_FILE="wizard_fengoffice_restore" BACKUP_FILE_PATH="wizard_backup_file" RESTORE_ERROR_TEXT="An empty file path is not allowed when restore is enabled." -INSTALL_NEW_INSTANCE="wizard_rengoffice_install" +INSTALL_NEW_INSTANCE="wizard_fengoffice_install" DOMAIN_NAME="wizard_domain_name" INSTALL_ERROR_TEXT="An empty domain name is not allowed when install is enabled." From 4838bce4a899ba0b51fd7f62ee918a89abb4d3f8 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:42:32 -0400 Subject: [PATCH 21/30] Revert "Bump to v3.11.1.19" This reverts commit fea4c5eb70a6ad8cc34fa11bea382adba91bae2e. --- cross/fengoffice/Makefile | 2 +- cross/fengoffice/digests | 6 +++--- spk/fengoffice/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index b8b283ce7b2..5e2efaeafbf 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,5 +1,5 @@ PKG_NAME = fengoffice -PKG_VERS = 3.11.1.19 +PKG_VERS = 3.11.1.2 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index 8bc87a4c522..73c5390cf2d 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice-3.11.1.19.tar.gz SHA1 5f611493ec274f55365a16c4fb04ead8c298f3bc -fengoffice-3.11.1.19.tar.gz SHA256 61fef62313ae9e9ec014a93b28b904be4bf1e2b254170e89a29af779c369210b -fengoffice-3.11.1.19.tar.gz MD5 098317a5f15731001f33cd6e81b4c8c1 +fengoffice-3.11.1.2.tar.gz SHA1 8bd215af898a0e95c256ffaf042e3946f4371a0a +fengoffice-3.11.1.2.tar.gz SHA256 21719faadee76351b6ab7e2fccdfb1c9b0db909c82091bae6e139d636f24aed3 +fengoffice-3.11.1.2.tar.gz MD5 5ef5f1c457225fb5d37e4ff984bf98bf diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index cc4f1d6ba39..b2c373a69e7 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,5 +1,5 @@ SPK_NAME = fengoffice -SPK_VERS = 3.11.1.19 +SPK_VERS = 3.11.1.2 SPK_REV = 4 SPK_ICON = src/fengoffice.png @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = moneytoo DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.11.1.19.
2. Add PHP profiles for DSM 6." +CHANGELOG = "1. Update to v3.11.1.2.
2. Add PHP profiles for DSM 6." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL From a8e48c18ed90b326d8017810a8fa3f2e7dd02ed5 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Wed, 11 Sep 2024 17:29:46 -0400 Subject: [PATCH 22/30] Fix uninstall validation --- spk/fengoffice/src/service-setup.sh | 90 +++++++++++++++-------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index 99b1b4fe5cd..4a9aa9c139e 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -231,7 +231,7 @@ script_installer_storage[database_type]=mysqli\ &script_installer_storage[plugins][]=workspaces\ &submited=submited" # Prepare environment - cd ${WEB_ROOT}/public/install/ || exit 1 + cd ${WEB_ROOT}/public/install/ || return # Execute based on DSM version echo "Run ${SC_DNAME} installer" exec_php "install_helper.php" @@ -239,58 +239,60 @@ script_installer_storage[database_type]=mysqli\ fi } -service_preuninst () +validate_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 - - if [ "${SYNOPKG_PKG_STATUS}" = "UNINSTALL" ]; then - # Check export directory - if [ -n "${wizard_export_path}" ]; then - if [ ! -d "${wizard_export_path}" ]; then - # If the export path directory does not exist, create it - ${MKDIR} "${wizard_export_path}" || { - # If mkdir fails, print an error message and exit - echo "Error: Unable to create directory ${wizard_export_path}. Check permissions." - exit 1 - } - elif [ ! -w "${wizard_export_path}" ]; then - # If the export path directory is not writable, print an error message and exit - echo "Error: Unable to write to directory ${wizard_export_path}. Check permissions." + # Check export directory + if [ "${SYNOPKG_PKG_STATUS}" = "UNINSTALL" ] && [ -n "${wizard_export_path}" ]; then + if [ ! -d "${wizard_export_path}" ]; then + # If the export path directory does not exist, create it + ${MKDIR} "${wizard_export_path}" || { + # If mkdir fails, print an error message and exit + echo "Error: Unable to create directory ${wizard_export_path}. Check permissions." exit 1 - fi - - # Prepare archive structure - FENG_VER=$(sed -n "s|return '\(.*\)';|\1|p" ${WEB_ROOT}/config/installed_version.php | xargs) - TEMPDIR="${SYNOPKG_PKGTMP}/${SYNOPKG_PKGNAME}_backup_v${FENG_VER}_$(date +"%Y%m%d")" - ${MKDIR} "${TEMPDIR}" - - # Backup Directories - echo "Copying previous configuration and data from ${WEB_ROOT}" - rsync -aX "${WEB_ROOT}" "${TEMPDIR}/" 2>&1 - - # Backup the Database - echo "Copying previous database from ${MYSQL_DATABASE}" - ${MKDIR} "${TEMPDIR}/database" - ${MYSQLDUMP} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} > ${TEMPDIR}/database/${MYSQL_DATABASE}-dbbackup.sql 2>&1 - - # Create backup archive - archive_name="$(basename "$TEMPDIR").tar.gz" - echo "Creating compressed archive of ${SC_DNAME} data in file $archive_name" - tar -C "$TEMPDIR" -czf "${SYNOPKG_PKGTMP}/$archive_name" . 2>&1 + } + elif [ ! -w "${wizard_export_path}" ]; then + # If the export path directory is not writable, print an error message and exit + echo "Error: Unable to write to directory ${wizard_export_path}. Check permissions." + exit 1 + fi + fi +} - # Move archive to export directory - RSYNC_BAK_ARGS="--backup --suffix=.bak" - rsync -aX ${RSYNC_BAK_ARGS} "${SYNOPKG_PKGTMP}/$archive_name" "${wizard_export_path}/" 2>&1 - echo "Backup file copied successfully to ${wizard_export_path}" +service_preuninst () +{ + if [ "${SYNOPKG_PKG_STATUS}" = "UNINSTALL" ] && [ -n "${wizard_export_path}" ]; then + # Prepare archive structure + FENG_VER=$(sed -n "s|return '\(.*\)';|\1|p" ${WEB_ROOT}/config/installed_version.php | xargs) + TEMPDIR="${SYNOPKG_PKGTMP}/${SYNOPKG_PKGNAME}_backup_v${FENG_VER}_$(date +"%Y%m%d")" + ${MKDIR} "${TEMPDIR}" + + # Backup Directories + echo "Copying previous configuration and data from ${WEB_ROOT}" + rsync -aX "${WEB_ROOT}" "${TEMPDIR}/" 2>&1 + + # Backup the Database + echo "Copying previous database from ${MYSQL_DATABASE}" + ${MKDIR} "${TEMPDIR}/database" + ${MYSQLDUMP} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} > ${TEMPDIR}/database/${MYSQL_DATABASE}-dbbackup.sql 2>&1 + + # Create backup archive + archive_name="$(basename "$TEMPDIR").tar.gz" + echo "Creating compressed archive of ${SC_DNAME} data in file $archive_name" + tar -C "$TEMPDIR" -czf "${SYNOPKG_PKGTMP}/$archive_name" . 2>&1 + + # Move archive to export directory + RSYNC_BAK_ARGS="--backup --suffix=.bak" + rsync -aX ${RSYNC_BAK_ARGS} "${SYNOPKG_PKGTMP}/$archive_name" "${wizard_export_path}/" 2>&1 + echo "Backup file copied successfully to ${wizard_export_path}" - # Clean-up temporary files - ${RM} "${TEMPDIR}" - ${RM} "${SYNOPKG_PKGTMP}/$archive_name" - fi + # Clean-up temporary files + ${RM} "${TEMPDIR}" + ${RM} "${SYNOPKG_PKGTMP}/$archive_name" fi } From 99b047527222d3044e5060458fb58df320db16bb Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:01:17 -0400 Subject: [PATCH 23/30] Reapply "Bump to v3.11.1.19" This reverts commit 4838bce4a899ba0b51fd7f62ee918a89abb4d3f8. --- cross/fengoffice/Makefile | 2 +- cross/fengoffice/digests | 6 +++--- spk/fengoffice/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index 5e2efaeafbf..b8b283ce7b2 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,5 +1,5 @@ PKG_NAME = fengoffice -PKG_VERS = 3.11.1.2 +PKG_VERS = 3.11.1.19 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index 73c5390cf2d..8bc87a4c522 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice-3.11.1.2.tar.gz SHA1 8bd215af898a0e95c256ffaf042e3946f4371a0a -fengoffice-3.11.1.2.tar.gz SHA256 21719faadee76351b6ab7e2fccdfb1c9b0db909c82091bae6e139d636f24aed3 -fengoffice-3.11.1.2.tar.gz MD5 5ef5f1c457225fb5d37e4ff984bf98bf +fengoffice-3.11.1.19.tar.gz SHA1 5f611493ec274f55365a16c4fb04ead8c298f3bc +fengoffice-3.11.1.19.tar.gz SHA256 61fef62313ae9e9ec014a93b28b904be4bf1e2b254170e89a29af779c369210b +fengoffice-3.11.1.19.tar.gz MD5 098317a5f15731001f33cd6e81b4c8c1 diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index b2c373a69e7..cc4f1d6ba39 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,5 +1,5 @@ SPK_NAME = fengoffice -SPK_VERS = 3.11.1.2 +SPK_VERS = 3.11.1.19 SPK_REV = 4 SPK_ICON = src/fengoffice.png @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = moneytoo DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.11.1.2.
2. Add PHP profiles for DSM 6." +CHANGELOG = "1. Update to v3.11.1.19.
2. Add PHP profiles for DSM 6." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL From 05a0b99e440e19840e73df262459ea11c906686c Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Wed, 11 Sep 2024 20:02:40 -0400 Subject: [PATCH 24/30] Update maintainer --- spk/fengoffice/Makefile | 2 +- spk/fengoffice/src/wizard/uninstall_uifile.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index cc4f1d6ba39..2136e6b4c62 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -11,7 +11,7 @@ override ARCH= REQUIRED_MIN_DSM = 6.0 SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" -MAINTAINER = moneytoo +MAINTAINER = SynoCommunity DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office CHANGELOG = "1. Update to v3.11.1.19.
2. Add PHP profiles for DSM 6." diff --git a/spk/fengoffice/src/wizard/uninstall_uifile.sh b/spk/fengoffice/src/wizard/uninstall_uifile.sh index 0bd6548adf1..c400eb714e0 100644 --- a/spk/fengoffice/src/wizard/uninstall_uifile.sh +++ b/spk/fengoffice/src/wizard/uninstall_uifile.sh @@ -1,8 +1,13 @@ #!/bin/bash # for backwards compatability -if [ "$SYNOPKG_DSM_VERSION_MAJOR" -lt 7 ] && [ -z "${SYNOPKG_PKGDEST_VOL}" ]; then - SYNOPKG_PKGDEST_VOL="/volume1" +if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 7 ]; then + if [ -z ${SYNOPKG_PKGDEST_VOL} ]; then + SYNOPKG_PKGDEST_VOL="/volume1" + fi + if [ -z ${SYNOPKG_PKGNAME} ]; then + SYNOPKG_PKGNAME="fengoffice" + fi fi quote_json () From 4b8ce2886447ca2e7598cd93e1d9f01a3ec8efc0 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:11:08 -0400 Subject: [PATCH 25/30] Refine upgrade script --- spk/fengoffice/src/service-setup.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index 4a9aa9c139e..3315649b599 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -204,13 +204,8 @@ service_postinst () echo "Restoring database to ${MYSQL_DATABASE}" ${MYSQL} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} < ${TEMPDIR}/database/${MYSQL_DATABASE}-dbbackup.sql 2>&1 - # Detect package version - PACKAGE_VERSION=$(echo ${SYNOPKG_PKGVER} | cut -d '-' -f 1) - # Detect old version - INSTALLED_VERSION=$(sed -n "s|return '\(.*\)';|\1|p" ${WEB_ROOT}/config/installed_version.php | xargs) - # Run update scripts - exec_php "${WEB_ROOT}/public/upgrade/console.php" "${INSTALLED_VERSION}" "${PACKAGE_VERSION}" + exec_php "${WEB_ROOT}/public/upgrade/console.php" exec_php "${WEB_ROOT}/public/install/plugin-console.php" "update_all" # Clean-up temporary files @@ -267,7 +262,11 @@ service_preuninst () { if [ "${SYNOPKG_PKG_STATUS}" = "UNINSTALL" ] && [ -n "${wizard_export_path}" ]; then # Prepare archive structure - FENG_VER=$(sed -n "s|return '\(.*\)';|\1|p" ${WEB_ROOT}/config/installed_version.php | xargs) + if [ -f "${WEB_ROOT}/config/installed_version.php" ]; then + FENG_VER=$(sed -n "s|return '\(.*\)';|\1|p" ${WEB_ROOT}/config/installed_version.php | xargs) + else + FENG_VER=$(sed -n "s|return '\(.*\)';|\1|p" ${WEB_ROOT}/version.php | xargs) + fi TEMPDIR="${SYNOPKG_PKGTMP}/${SYNOPKG_PKGNAME}_backup_v${FENG_VER}_$(date +"%Y%m%d")" ${MKDIR} "${TEMPDIR}" @@ -347,18 +346,15 @@ service_save () [ -d ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} ] && ${RM} ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} mkdir -p ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME} mv ${WEB_ROOT}/config/config.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ - mv ${WEB_ROOT}/config/installed_version.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ + if [ -f "${WEB_ROOT}/config/installed_version.php" ]; then + mv ${WEB_ROOT}/config/installed_version.php ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/ + fi mkdir ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/ cp -r ${WEB_ROOT}/upload/*/ ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/ } service_restore () { - # Detect package version - PACKAGE_VERSION=$(echo ${SYNOPKG_PKGVER} | cut -d '-' -f 1) - # Detect old version - INSTALLED_VERSION=$(sed -n "s|return '\(.*\)';|\1|p" ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/installed_version.php | xargs) - # Restore configuration mv ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/config.php ${WEB_ROOT}/config/ cp -r ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${SYNOPKG_PKGNAME}/upload/*/ ${WEB_ROOT}/upload/ @@ -370,6 +366,6 @@ service_restore () fi # Run update scripts - exec_php "${WEB_ROOT}/public/upgrade/console.php" "${INSTALLED_VERSION}" "${PACKAGE_VERSION}" + exec_php "${WEB_ROOT}/public/upgrade/console.php" exec_php "${WEB_ROOT}/public/install/plugin-console.php" "update_all" } From 30c2d6458b70f319a3f2c2de9cadd1b143132cc7 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Sun, 15 Sep 2024 09:01:00 -0400 Subject: [PATCH 26/30] Update changelog --- spk/fengoffice/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index 2136e6b4c62..50a3c9f0427 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = SynoCommunity DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.11.1.19.
2. Add PHP profiles for DSM 6." +CHANGELOG = "1. Update to v3.11.1.19.
2. Add PHP profiles for DSM 6.
3. Add backup and restore functions." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL From 139a9e2c4eabf0d1af3f4c46f1bdbdd21638c4d0 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:42:13 -0400 Subject: [PATCH 27/30] Minor wizard amendment --- spk/fengoffice/src/wizard/install_uifile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spk/fengoffice/src/wizard/install_uifile.sh b/spk/fengoffice/src/wizard/install_uifile.sh index a529445c03d..813fbc889fb 100644 --- a/spk/fengoffice/src/wizard/install_uifile.sh +++ b/spk/fengoffice/src/wizard/install_uifile.sh @@ -200,7 +200,7 @@ PAGE_INSTALL_CONFIG=$(/bin/cat< Date: Mon, 23 Sep 2024 12:52:46 -0400 Subject: [PATCH 28/30] Bump to v3.11.2.7 --- cross/fengoffice/Makefile | 2 +- cross/fengoffice/digests | 6 +++--- spk/fengoffice/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index b8b283ce7b2..adb8c3c0582 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,5 +1,5 @@ PKG_NAME = fengoffice -PKG_VERS = 3.11.1.19 +PKG_VERS = 3.11.2.7 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index 8bc87a4c522..27dade395b5 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice-3.11.1.19.tar.gz SHA1 5f611493ec274f55365a16c4fb04ead8c298f3bc -fengoffice-3.11.1.19.tar.gz SHA256 61fef62313ae9e9ec014a93b28b904be4bf1e2b254170e89a29af779c369210b -fengoffice-3.11.1.19.tar.gz MD5 098317a5f15731001f33cd6e81b4c8c1 +fengoffice-3.11.2.7.tar.gz SHA1 ec63ec70aa65c18baa4771bc2b4ec2ec5a74589a +fengoffice-3.11.2.7.tar.gz SHA256 be118fe08c438c992cfdb1addac13be4987df3acff7dfe37111bfbd04bf27ec3 +fengoffice-3.11.2.7.tar.gz MD5 d406db0a2395732f5f9ab68620f3dc4c diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index 50a3c9f0427..d25461a1a83 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,5 +1,5 @@ SPK_NAME = fengoffice -SPK_VERS = 3.11.1.19 +SPK_VERS = 3.11.2.7 SPK_REV = 4 SPK_ICON = src/fengoffice.png @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = SynoCommunity DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.11.1.19.
2. Add PHP profiles for DSM 6.
3. Add backup and restore functions." +CHANGELOG = "1. Update to v3.11.2.7.
2. Add PHP profiles for DSM 6.
3. Add backup and restore functions." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL From ffeba68d0167a3c88059e2aaedab1f270f098ad0 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Tue, 24 Sep 2024 06:15:18 -0400 Subject: [PATCH 29/30] Refine descriptions in wizards --- spk/fengoffice/src/service-setup.sh | 14 +++++++------- spk/fengoffice/src/wizard/install_uifile.sh | 10 +++++----- spk/fengoffice/src/wizard/uninstall_uifile.sh | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spk/fengoffice/src/service-setup.sh b/spk/fengoffice/src/service-setup.sh index 3315649b599..8edab5b015c 100755 --- a/spk/fengoffice/src/service-setup.sh +++ b/spk/fengoffice/src/service-setup.sh @@ -10,8 +10,8 @@ SVC_WRITE_PID=y # Others MYSQL="/usr/local/mariadb10/bin/mysql" MYSQLDUMP="/usr/local/mariadb10/bin/mysqldump" -MYSQL_USER="fengoffice" -MYSQL_DATABASE="fengoffice" +MYSQL_USER="${SYNOPKG_PKGNAME}" +MYSQL_DATABASE="${SYNOPKG_PKGNAME}" if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -ge 7 ]; then WEB_DIR="/var/services/web_packages" else @@ -79,15 +79,15 @@ validate_preinst () 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" + 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" + 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" + echo "MySQL database '${MYSQL_DATABASE}' already exists" exit 1 fi @@ -216,7 +216,7 @@ service_postinst () script_installer_storage[database_type]=mysqli\ &script_installer_storage[database_host]=localhost\ &script_installer_storage[database_user]=${MYSQL_USER}\ -&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=fengoffice}\ +&script_installer_storage[database_pass]=${wizard_mysql_password_fengoffice:=${SYNOPKG_PKGNAME}}\ &script_installer_storage[database_name]=${MYSQL_DATABASE}\ &script_installer_storage[database_prefix]=fo_\ &script_installer_storage[database_engine]=InnoDB\ @@ -238,7 +238,7 @@ validate_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" + echo "Incorrect MySQL 'root' password" exit 1 fi # Check export directory diff --git a/spk/fengoffice/src/wizard/install_uifile.sh b/spk/fengoffice/src/wizard/install_uifile.sh index 813fbc889fb..6de92198ef6 100644 --- a/spk/fengoffice/src/wizard/install_uifile.sh +++ b/spk/fengoffice/src/wizard/install_uifile.sh @@ -1,7 +1,7 @@ #!/bin/bash # for backwards compatability -if [ -z ${SYNOPKG_PKGDEST_VOL} ]; then +if [ -z "${SYNOPKG_PKGDEST_VOL}" ]; then SYNOPKG_PKGDEST_VOL="/volume1" fi INTERNAL_IP=$(ip -4 route get 8.8.8.8 | awk '/8.8.8.8/ && /src/ {print $NF}') @@ -187,20 +187,20 @@ PAGE_INSTALL_CONFIG=$(/bin/cat< Date: Thu, 26 Sep 2024 08:13:55 -0400 Subject: [PATCH 30/30] Bump to v3.11.2.8 --- cross/fengoffice/Makefile | 2 +- cross/fengoffice/digests | 6 +++--- spk/fengoffice/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cross/fengoffice/Makefile b/cross/fengoffice/Makefile index adb8c3c0582..46e3821636f 100644 --- a/cross/fengoffice/Makefile +++ b/cross/fengoffice/Makefile @@ -1,5 +1,5 @@ PKG_NAME = fengoffice -PKG_VERS = 3.11.2.7 +PKG_VERS = 3.11.2.8 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/fengoffice/$(PKG_NAME)/archive/$(PKG_VERS) diff --git a/cross/fengoffice/digests b/cross/fengoffice/digests index 27dade395b5..4e81cd978d0 100644 --- a/cross/fengoffice/digests +++ b/cross/fengoffice/digests @@ -1,3 +1,3 @@ -fengoffice-3.11.2.7.tar.gz SHA1 ec63ec70aa65c18baa4771bc2b4ec2ec5a74589a -fengoffice-3.11.2.7.tar.gz SHA256 be118fe08c438c992cfdb1addac13be4987df3acff7dfe37111bfbd04bf27ec3 -fengoffice-3.11.2.7.tar.gz MD5 d406db0a2395732f5f9ab68620f3dc4c +fengoffice-3.11.2.8.tar.gz SHA1 b700ff65ec7bac41f27fc50866cd81dffca79f36 +fengoffice-3.11.2.8.tar.gz SHA256 b146bba574349d0480407a101b4f4924f876425ff5955470c515efbc953b8b6c +fengoffice-3.11.2.8.tar.gz MD5 766ac490d2aeb1ca9a2868a35fcf1300 diff --git a/spk/fengoffice/Makefile b/spk/fengoffice/Makefile index d25461a1a83..68a666575d0 100644 --- a/spk/fengoffice/Makefile +++ b/spk/fengoffice/Makefile @@ -1,5 +1,5 @@ SPK_NAME = fengoffice -SPK_VERS = 3.11.2.7 +SPK_VERS = 3.11.2.8 SPK_REV = 4 SPK_ICON = src/fengoffice.png @@ -14,7 +14,7 @@ SPK_DEPENDS = "WebStation:PHP7.4:MariaDB10:Apache2.4" MAINTAINER = SynoCommunity DESCRIPTION = Feng Office is a Collaboration Platform and Project Management System. DISPLAY_NAME = Feng Office -CHANGELOG = "1. Update to v3.11.2.7.
2. Add PHP profiles for DSM 6.
3. Add backup and restore functions." +CHANGELOG = "1. Update to v3.11.2.8.
2. Add PHP profiles for DSM 6.
3. Add backup and restore functions." HOMEPAGE = https://www.fengoffice.com/ LICENSE = AGPL