Skip to content

Commit

Permalink
Upgrade cops 1.0.1 => 1.1.3 + DSM 7 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
smaarn committed Apr 3, 2022
1 parent 71aa89e commit d1a193b
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 84 deletions.
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.0.1
PKG_VERS = 1.1.3
PKG_EXT = zip
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/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.0.1.zip SHA1 b5c595cfe37e4d427dd36edde22489e921da71c0
cops-1.0.1.zip SHA256 564ab72cee8355df13271e2e25d5ce68541a5c2f802637a5aa4a94def05029dd
cops-1.0.1.zip MD5 a688dfd66d31674637106f8430ca1103
cops-1.1.3.zip SHA1 43f4838b5c5f46cf9e57bc4a480f4579494bc7ec
cops-1.1.3.zip SHA256 68c9efb340ab30989cd89a19a173c45872d33ed85dd02674f8af08b7748cbc77
cops-1.1.3.zip MD5 461c2b2fdd6ae6be27ba192d97188fda
16 changes: 10 additions & 6 deletions spk/cops/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPK_NAME = cops
SPK_VERS = 1.0.1
SPK_REV = 5
SPK_VERS = 1.1.3
SPK_REV = 6
SPK_ICON = src/cops.png
DSM_UI_DIR = app

Expand All @@ -11,25 +11,29 @@ DESCRIPTION = Calibre OPDS and HTML PHP Server : light alternative to Calibre co
DESCRIPTION_FRE = Calibre OPDS et HTML PHP Serveur : alternative légère au serveur de contenu de Calibre et à Calibre2OPDS.
ADMIN_URL = /cops/
DISPLAY_NAME = COPS
CHANGELOG = "1. Update to 1.0.1<br>2. Improved DSM6 compatibility"
CHANGELOG = "1. Update to 1.1.3<br>2. Improved DSM7 compatibility"

SPK_DEPENDS=WebStation

SYSTEM_GROUP = http

BETA=1

HOMEPAGE = https://blog.slucas.fr/en/oss/calibre-opds-php-server
LICENSE = GPL

REQUIRED_DSM = 6.0

WIZARDS_DIR = src/wizard/
CONF_DIR = src/conf/

INSTALLER_SCRIPT = src/installer.sh
SSS_SCRIPT = src/dsm-control.sh
STARTABLE = no

INSTALL_DEP_SERVICES = apache-web
START_DEP_SERVICES = apache-web
INSTUNINST_RESTART_SERVICES = apache-web

INSTALL_PREFIX = /usr/local/$(SPK_NAME)

POST_STRIP_TARGET = cops_extra_install

# Pure PHP package, make sure ARCH is not defined
Expand Down
5 changes: 0 additions & 5 deletions spk/cops/src/conf/PKG_DEPS

This file was deleted.

46 changes: 46 additions & 0 deletions spk/cops/src/conf/resources
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"webservice": {
"services": [{
"service": "cops",
"display_name": "COPS",
"type": "apache_php",
"root": "cops",
"backend": 2,
"php": {
"profile_name": "cops",
"profile_desc": "PHP profile used by cops",
"backend": 6,
"extensions": [
"gd",
"sqlite3",
"intl",
"zip"
],
"user": "sc-cops",
"group": "http"
}
}],
"portals": [
{
"service": "cops",
"type": "alias",
"name": "COPS",
"alias": "cops",
"app": "com.synocommunity.packages.cops"
}
],
"migrate": {
"root": [{
"old": "cops",
"new": "cops"
}]
},
"pkg_dir_prepare": [{
"source": "/var/packages/cops/target/share/cops",
"target": "cops",
"mode": "0755",
"user": "sc-cops",
"group": "http"
}]
}
}
43 changes: 0 additions & 43 deletions spk/cops/src/dsm-control.sh

This file was deleted.

66 changes: 40 additions & 26 deletions spk/cops/src/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ DNAME="COPS"
PACKAGE_NAME="com.synocommunity.packages.${PACKAGE}"

# Others
INSTALL_DIR="/usr/local/${PACKAGE}"
INSTALL_DIR="/var/packages/${PACKAGE}"
DEFAULT_CFG_FILE="/usr/local/${PACKAGE}/config_local.php.synology"
WEB_DIR="/var/services/web"
DSM6_WEB_DIR="/var/services/web"
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -ge 7 ]; then
WEB_DIR="/var/services/web_packages"
else
WEB_DIR="${DSM6_WEB_DIR}"
fi
CFG_FILE="${WEB_DIR}/${PACKAGE}/config_local.php"
TMP_DIR="${SYNOPKG_PKGDEST}/../../@tmp"
BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)"
Expand Down Expand Up @@ -53,31 +58,35 @@ preinst ()

postinst ()
{
# Link
ln -s ${SYNOPKG_PKGDEST} ${INSTALL_DIR}

# Install the web interface
cp -pR ${INSTALL_DIR}/share/${PACKAGE} ${WEB_DIR}


# Configure open_basedir
if [ "${USER}" == "nobody" ]; then
echo -e "<Directory \"${WEB_DIR}/${PACKAGE}\">\nphp_admin_value open_basedir none\n</Directory>" > /usr/syno/etc/sites-enabled-user/${PACKAGE}.conf
else
echo -e "[PATH=${WEB_DIR}/${PACKAGE}]\nopen_basedir = Null" > ${PHP_CONFIG_LOCATION}/${PACKAGE_NAME}.ini
fi
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then
# Link
ln -s "${SYNOPKG_PKGDEST}" "${INSTALL_DIR}"

# Install the web interface
cp -pR "${INSTALL_DIR}/share/${PACKAGE}" "${WEB_DIR}"


# Configure open_basedir
if [ "${USER}" == "nobody" ]; then
echo -e "<Directory \"${WEB_DIR}/${PACKAGE}\">\nphp_admin_value open_basedir none\n</Directory>" > /usr/syno/etc/sites-enabled-user/${PACKAGE}.conf
else
echo -e "[PATH=${WEB_DIR}/${PACKAGE}]\nopen_basedir = Null" > ${PHP_CONFIG_LOCATION}/${PACKAGE_NAME}.ini
fi
fi

if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
# Create a default configuration file
if [ ! -f ${CFG_FILE} ]; then
cp ${DEFAULT_CFG_FILE} ${CFG_FILE}
cp "${DEFAULT_CFG_FILE}" "${CFG_FILE}"
url_rewriting=$([ "${wizard_use_url_rewriting}" == "true" ] && echo "1" || echo "0")
sed -i -e "s|@calibre_dir@|${wizard_calibre_dir:=/volume1/calibre/}|g" ${CFG_FILE}
sed -i -e "s|@cops_title@|${wizard_cops_title:=COPS}|g" ${CFG_FILE}
sed -i -e "s|@use_url_rewriting@|${url_rewriting:=0}|g" ${CFG_FILE}
chmod ga+w ${CFG_FILE}
chmod ga+w "${CFG_FILE}"
fi

if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then

# Set permissions
if [ "${BUILDNUMBER}" -ge "4458" ]; then
# DSM5+
Expand All @@ -94,6 +103,7 @@ postinst ()
chown ${USER} ${wizard_calibre_dir:=/volume1/calibre/}/metadata.db
chmod u+rw ${wizard_calibre_dir:=/volume1/calibre/}/metadata.db
fi
fi
fi

exit 0
Expand All @@ -106,15 +116,19 @@ preuninst ()

postuninst ()
{
# Remove link
rm -f ${INSTALL_DIR}

# Remove open_basedir configuration
rm -f /usr/syno/etc/sites-enabled-user/${PACKAGE}.conf
rm -f ${PHP_CONFIG_LOCATION}/${PACKAGE_NAME}.ini

# Remove the web interface
rm -fr ${WEB_DIR}/${PACKAGE}
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then

# Remove link
rm -f ${INSTALL_DIR}

# Remove open_basedir configuration
rm -f /usr/syno/etc/sites-enabled-user/${PACKAGE}.conf
rm -f ${PHP_CONFIG_LOCATION}/${PACKAGE_NAME}.ini

# Remove the web interface
rm -fr ${WEB_DIR}/${PACKAGE}

fi

exit 0
}
Expand Down

0 comments on commit d1a193b

Please sign in to comment.