Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COPS: Update to v3.2.2 #6230

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cross/cops/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PKG_NAME = cops
PKG_VERS = 1.5.4
PKG_VERS = 3.2.2
mreid-tt marked this conversation as resolved.
Show resolved Hide resolved
PKG_EXT = zip
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/mikespub-org/seblucas-cops/releases/download/$(PKG_VERS)
Expand Down
6 changes: 3 additions & 3 deletions cross/cops/digests
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cops-1.5.4.zip SHA1 6fc653f9b7b83766547c420875579bd02503c98e
cops-1.5.4.zip SHA256 7fc18946c003d91e77c4a189f0b752f021224187d86e93f8813b165d9ac306c9
cops-1.5.4.zip MD5 17cb2d4ce02f7ddbd51baa27fcc26a0d
cops-3.2.2.zip SHA1 530c525cdfdb72040d089d031e8d48053d68437c
cops-3.2.2.zip SHA256 c3dbb1a310d846364e7a1c3f1453098a2273b45a80655a57fadc5a393868797b
cops-3.2.2.zip MD5 1e89e57e7862df462a1f6b397858bd4b
21 changes: 6 additions & 15 deletions spk/cops/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
SPK_NAME = cops
SPK_VERS = 1.5.4
SPK_REV = 9
SPK_VERS = 3.2.2
SPK_REV = 10
SPK_ICON = src/cops.png

DEPENDS = cross/cops
# Pure PHP package, make sure ARCH is not defined
override ARCH=

REQUIRED_MIN_DSM = 6.0
SPK_DEPENDS=WebStation:PHP7.4:Apache2.4
REQUIRED_MIN_DSM = 7.0
SPK_DEPENDS=WebStation:PHP8.2:Apache2.4

MAINTAINER = Diaoul
MAINTAINER = SynoCommunity
DESCRIPTION = Calibre OPDS and HTML PHP Server : light alternative to Calibre content server / Calibre2OPDS.
DESCRIPTION_FRE = Calibre OPDS et HTML PHP Serveur : alternative légère au serveur de contenu de Calibre et à Calibre2OPDS.
DISPLAY_NAME = COPS
CHANGELOG = "1. Update to 1.5.4"
CHANGELOG = "1. Update to v3.2.2. \(Requires PHP 8.2\)"

HOMEPAGE = https://blog.slucas.fr/en/oss/calibre-opds-php-server
LICENSE = GPLv2
Expand All @@ -30,13 +30,6 @@ DSM_UI_DIR = app
DSM_UI_CONFIG = src/app/config
CONF_DIR = src/conf/

include ../../mk/spksrc.common.mk

# Alternate conf dir for DSM 6
ifeq ($(call version_lt, ${TCVERSION}, 7.0),1)
CONF_DIR = src/conf_6/
endif

SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
STARTABLE = no
Expand All @@ -48,7 +41,5 @@ include ../../mk/spksrc.spk.mk
.PHONY: cops_extra_install
cops_extra_install:
install -m 755 -d $(STAGING_DIR)/web
install -m 644 src/web/cops.conf $(STAGING_DIR)/web/cops.conf
install -m 644 src/web/cops.json $(STAGING_DIR)/web/cops.json
@$(MSG) Install default config file
install -m 666 src/web/config_local.php.synology $(STAGING_DIR)/web/config_local.php.synology
3 changes: 2 additions & 1 deletion spk/cops/src/conf/resource
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
"display_name": "COPS",
"icon": "app/images/cops-{0}.png",
"php": {
"backend": 8,
"backend": 11,
"extensions": [
"gd",
"intl",
"pdo_sqlite",
"sqlite3",
"zip",
"zlib"
],
"group": "http",
Expand Down
11 changes: 0 additions & 11 deletions spk/cops/src/conf_6/resource

This file was deleted.

133 changes: 1 addition & 132 deletions spk/cops/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -1,99 +1,13 @@

# Package
PACKAGE="cops"
DNAME="COPS"
SC_PKG_PREFIX="com-synocommunity-packages-"
PACKAGE_NAME="${SC_PKG_PREFIX}${PACKAGE}"

# Others
SYNOSVC="/usr/syno/sbin/synoservice"
WEB_DIR="/var/services/web_packages"
# for backwards compatability
if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 7 ];then
WEB_DIR="/var/services/web"
fi
WEB_ROOT="${WEB_DIR}/${PACKAGE}"

validate_preinst ()
{
# Check for modification to PHP template defaults on DSM 6
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then
WS_TMPL_PATH="/var/packages/WebStation/target/misc"
WS_TMPL_FILE="php74_fpm.mustache"
FULL_WS_TMPL_FILE="${WS_TMPL_PATH}/${WS_TMPL_FILE}"
# Check for PHP template defaults
if ! grep -q -E '^user = http$' "${FULL_WS_TMPL_FILE}" || ! grep -q -E '^listen\.owner = http$' "${FULL_WS_TMPL_FILE}"; then
echo "PHP template defaults have been modified. Installation is not supported."
exit 1
fi
fi
}

service_postinst ()
{
# Web interface setup for DSM 6 -- used by INSTALL and UPGRADE
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then
# Install the web interface
echo "Installing web interface"
${MKDIR} ${WEB_ROOT}
rsync -aX ${SYNOPKG_PKGDEST}/share/${PACKAGE}/ ${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 ".[\"${PACKAGE_NAME}\"]" "${PHP_CFG_PATH}" >/dev/null; then
echo "Add PHP profile for ${DNAME}"
jq --slurpfile ocNode ${SYNOPKG_PKGDEST}/web/${PACKAGE}.json '.["'"${PACKAGE_NAME}"'"] = $ocNode[0]' ${PHP_CFG_PATH} > ${TMP_PHP_CFG_PATH}
rsync -aX ${RSYNC_ARCH_ARGS} ${TMP_PHP_CFG_PATH} ${WS_CFG_DIR}/ 2>&1
RESTART_APACHE="yes"
fi
# Check for Apache config
if [ ! -f "/usr/local/etc/apache24/sites-enabled/${PACKAGE}.conf" ]; then
echo "Add Apache config for ${DNAME}"
rsync -aX ${SYNOPKG_PKGDEST}/web/${PACKAGE}.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 != "'"${PACKAGE_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
# Initialize or update configuration file based on user preferences.
if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then
CFG_FILE="${WEB_ROOT}/config_local.php"
Expand All @@ -110,51 +24,6 @@ service_postinst ()
fi
}

service_postuninst ()
{
# Web interface removal for DSM 6 -- used by UNINSTALL and UPGRADE
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then
# Remove the web interface
echo "Removing web interface"
${RM} ${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 ".[\"${PACKAGE_NAME}\"]" "${PHP_CFG_PATH}" >/dev/null; then
echo "Removing PHP profile for ${DNAME}"
jq 'del(.["'"${PACKAGE_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/${PACKAGE_NAME}"
RESTART_APACHE="yes"
fi
# Check for Apache config
if [ -f "/usr/local/etc/apache24/sites-enabled/${PACKAGE}.conf" ]; then
echo "Removing Apache config for ${DNAME}"
${RM} /usr/local/etc/apache24/sites-enabled/${PACKAGE}.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 != "'"${PACKAGE_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 some stuff
Expand All @@ -172,7 +41,7 @@ service_restore ()
# Restore some stuff
echo "Restore previous data from ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${PACKAGE}"
# Restore cops configuration file
rsync -aX --update -I ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${PACKAGE}/web/config_local.php ${WEB_ROOT}/config_local.php 2>&1
rsync -aX -I ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${PACKAGE}/web/config_local.php ${WEB_ROOT}/config_local.php 2>&1
else
# Backup missing, re-initialise default values
CFG_FILE="${WEB_ROOT}/config_local.php"
Expand Down
16 changes: 0 additions & 16 deletions spk/cops/src/web/cops.conf

This file was deleted.

25 changes: 0 additions & 25 deletions spk/cops/src/web/cops.json

This file was deleted.

28 changes: 0 additions & 28 deletions spk/cops/src/wizard_templates/install_uifile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ page_append ()
fi
}

# Check for multiple PHP profiles
check_php_profiles ()
{
PACKAGE="cops"
SC_PKG_PREFIX="com-synocommunity-packages-"
PACKAGE_NAME="${SC_PKG_PREFIX}${PACKAGE}"
PHP_CFG_PATH="/usr/syno/etc/packages/WebStation/PHPSettings.json"
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ] && \
jq -e 'to_entries | map(select((.key | startswith("'"${SC_PKG_PREFIX}"'")) and .key != "'"${PACKAGE_NAME}"'")) | length > 0' "${PHP_CFG_PATH}" >/dev/null; then
return 0 # true
else
return 1 # false
fi
}

PAGE_ADMIN_CONFIG=$(/bin/cat<<EOF
{
"step_title": "{{{COPS_CONFIGURATION_FIRST_STEP_TITLE}}}",
Expand Down Expand Up @@ -83,22 +68,9 @@ PAGE_ADMIN_CONFIG=$(/bin/cat<<EOF
EOF
)

PAGE_PHP_PROFILES=$(/bin/cat<<EOF
{
"step_title": "{{{PHP_PROFILES_TITLE}}}",
"items": [{
"desc": "{{{PHP_PROFILES_DESCRIPTION}}}"
}]
}
EOF
)

main () {
local install_page=""
install_page=$(page_append "$install_page" "$PAGE_ADMIN_CONFIG")
if check_php_profiles; then
install_page=$(page_append "$install_page" "$PAGE_PHP_PROFILES")
fi
echo "[$install_page]" > "${SYNOPKG_TEMP_LOGFILE}"
}

Expand Down
3 changes: 0 additions & 3 deletions spk/cops/src/wizard_templates/install_uifile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ DO_YOU_WANT_TO_USE_COPS_WITH_A_KOBO_LABEL: "Kobo"

DSM_PERMISSIONS_TITLE: "Attention! DSM Permissions"
DSM_PERMISSIONS_TEXT: "Package user and group will not appear on most UI settings. Please read <a target=\\\"_blank\\\" href=\\\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\\\">Permission Management</a> for details."

PHP_PROFILES_TITLE: "Multiple PHP profiles"
PHP_PROFILES_DESCRIPTION: "Attention: Multiple PHP profiles detected; the package webpage will not display until a DSM restart is performed to load new configurations."
3 changes: 0 additions & 3 deletions spk/cops/src/wizard_templates/install_uifile_fre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ DO_YOU_WANT_TO_USE_COPS_WITH_A_KOBO_LABEL: "Kobo"

DSM_PERMISSIONS_TITLE: "Attention! DSM Permissions"
DSM_PERMISSIONS_TEXT: "L'utilisateur et le group du package n'apparaîtront pas sur la plupart des UI réglages. Veuillez vous référrer à <a target=\\\"_blank\\\" href=\\\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\\\">Permission Management</a> pour plus de détails."

PHP_PROFILES_TITLE: "Plusieurs profils PHP"
PHP_PROFILES_DESCRIPTION: "Attention : Plusieurs profils PHP détectés ; la page Web du package ne s'affichera pas tant qu'un redémarrage de DSM n'aura pas été effectué pour charger de nouvelles configurations."
4 changes: 0 additions & 4 deletions spk/cops/src/wizard_templates/upgrade_uifile.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/bash

WEB_DIR="/var/services/web_packages"
# for backwards compatability
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then
WEB_DIR="/var/services/web"
fi

quote_json ()
{
Expand Down