Skip to content

Commit

Permalink
DSM 6: Appropriately enforce DSM 6 configuration logics
Browse files Browse the repository at this point in the history
  • Loading branch information
smaarn committed Nov 11, 2023
1 parent c7ee796 commit a24c7db
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
4 changes: 4 additions & 0 deletions spk/tt-rss/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
install -m 644 src/bin/7.0/settings.sh $(STAGING_DIR)/bin/settings.sh
install -m 755 src/bin/7.0/update-schema $(STAGING_DIR)/bin/update-schema
else
#ifeq ($(call version_le, ${TCVERSION}, 6.0), 1)
install -m 755 -d "$(STAGING_DIR)/web"
jq '.' "src/6.0-/tt-rss.json" $(foreach extension,$(PHP_EXTENSIONS), | jq '.extensions += ["$(extension)"]') > "$(STAGING_DIR)/web/tt-rss.json"
#endif
install -m 644 src/bin/settings.sh $(STAGING_DIR)/bin/settings.sh
install -m 755 src/bin/update-schema $(STAGING_DIR)/bin/update-schema
endif
20 changes: 20 additions & 0 deletions spk/tt-rss/src/6.0-/tt-rss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"profile_name": "tt-rss",
"profile_desc": "PHP profile used by tt-rss",
"backend": 8,
"extensions": [],
"custom_open_basedir": false,
"display_errors": false,
"enable_cache": true,
"enable_xdebug": false,
"fpm_settings": {
"max_children": 20,
"max_spare_servers": 3,
"min_spare_servers": 1,
"mode": "dynamic",
"start_servers": 2,
"user_owncloud": true
},
"open_basedir": "",
"php_settings": {}
}
57 changes: 56 additions & 1 deletion spk/tt-rss/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,67 @@ MYSQL_DATABASE="ttrss"
SVC_KEEP_LOG=y
SVC_BACKGROUND=y
SVC_WRITE_PID=y
JQ="/bin/jq"
SYNOSVC="/usr/syno/sbin/synoservice"

service_postinst ()
{
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then
# Install the web interface
${CP} "${SYNOPKG_PKGDEST}/share/${PACKAGE}" ${WEB_DIR}
${CP} "${SYNOPKG_PKGDEST}/share/${PACKAGE}" ${WEB_DIR}

TEMPDIR="${SYNOPKG_PKGTMP}/web"
${MKDIR} ${TEMPDIR}

WS_CFG_PATH="/usr/syno/etc/packages/WebStation"
WS_CFG_FILE="WebStation.json"
FULL_WS_CFG_FILE="${WS_CFG_PATH}/${WS_CFG_FILE}"
TEMP_WS_CFG_FILE="${TEMPDIR}/${WS_CFG_FILE}"
PHP_CFG_FILE="PHPSettings.json"
PHP_PROF_NAME="Default PHP 7.4 Profile"
FULL_PHP_CFG_FILE="${WS_CFG_PATH}/${PHP_CFG_FILE}"
TEMP_PHP_CFG_FILE="${TEMPDIR}/${PHP_CFG_FILE}"
NEW_WS_CONFIG_FILE_CONTENTS=$(${JQ} "." "${FULL_WS_CFG_FILE}")
WS_BACKEND=$(${JQ} -r '.default.backend' "${FULL_WS_CFG_FILE}")
WS_PHP=$(${JQ} -r '.default.php' "${FULL_WS_CFG_FILE}")
CFG_UPDATE="no"
RESTART_APACHE="no"
BACKUP_CFG_FILE="yes"
RSYNC_ARGS=-b --suffix ".bak"
# 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' "${FULL_WS_CFG_FILE}" > "${TEMP_WS_CFG_FILE}"
rsync -aX ${RSYNC_ARGS} "${TEMP_WS_CFG_FILE}" "${WS_CFG_PATH}/" 2>&1
RSYNC_ARGS=
${RM} "${TEMP_WS_CFG_FILE}"
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' "${FULL_PHP_CFG_FILE}")
${JQ} ".default.php = \"$PHP_PROF_ID\"" > "${TEMP_WS_CFG_FILE}"
rsync -aX ${RSYNC_ARGS} "${TEMP_WS_CFG_FILE}" "${WS_CFG_PATH}/" 2>&1
${RM} "${TEMP_WS_CFG_FILE}"
RESTART_APACHE="yes"
fi
# Check for tt-rss PHP profile
if ! ${JQ} -e '.["com-synocommunity-packages-tt-rss"]' "${FULL_PHP_CFG_FILE}" >/dev/null; then
echo "Add PHP profile for tt-rss"
${JQ} --slurpfile ttRssNode "${SYNOPKG_PKGDEST}/web/tt-rss.json" '.["com-synocommunity-packages-tt-rss"] = $ttRssNode[0]' "${FULL_PHP_CFG_FILE}" > "${TEMP_PHP_CFG_FILE}"
rsync -b --suffix ".bak" -aX "${TEMP_PHP_CFG_FILE}" "${WS_CFG_PATH}/" 2>&1
${RM} "${TEMP_PHP_CFG_FILE}"
RESTART_APACHE="yes"
fi
# Restart Apache if required
if [ "${RESTART_APACHE}" = "yes" ]; then
echo "Restart Apache to load new configs"
${SYNOSVC} --restart pkgctl-Apache2.4
fi
# Clean-up temporary files
${RM} "${TEMPDIR}"
fi

mkdir "-p" "${LOGS_DIR}"
Expand Down

0 comments on commit a24c7db

Please sign in to comment.