-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
228 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
rsc:share/phpMemcachedAdmin/ | ||
rsc:share/phpmemcachedadmin/ | ||
rsc:var/phpmemcachedadmin.config/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
phpMemcachedAdmin-aaf3d16a2a1e3dff72dd358f1758d96f0f174cb3.tar.gz SHA1 d6df971239f63227455d926303a627b96a550ec1 | ||
phpMemcachedAdmin-aaf3d16a2a1e3dff72dd358f1758d96f0f174cb3.tar.gz SHA256 cc420cb81367b55142aa593551e03960aca4619c359069936e1174c396bed316 | ||
phpMemcachedAdmin-aaf3d16a2a1e3dff72dd358f1758d96f0f174cb3.tar.gz MD5 4ae61787f66f4c27788a406eedf65cad | ||
phpmemcachedadmin-aaf3d16a2a1e3dff72dd358f1758d96f0f174cb3.tar.gz SHA1 d6df971239f63227455d926303a627b96a550ec1 | ||
phpmemcachedadmin-aaf3d16a2a1e3dff72dd358f1758d96f0f174cb3.tar.gz SHA256 cc420cb81367b55142aa593551e03960aca4619c359069936e1174c396bed316 | ||
phpmemcachedadmin-aaf3d16a2a1e3dff72dd358f1758d96f0f174cb3.tar.gz MD5 4ae61787f66f4c27788a406eedf65cad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,44 @@ | ||
{ | ||
"webservice": { | ||
"services": [{ | ||
"service": "phpMemcachedAdmin", | ||
"display_name": "phpMemcachedAdmin", | ||
"type": "apache_php", | ||
"root": "phpMemcachedAdmin", | ||
"icon": "app/images/phpmemcachedadmin-{0}.png", | ||
"backend": 2, | ||
"php": { | ||
"profile_name": "php-memcached-admin", | ||
"profile_desc": "PHP profile used by phpMemcachedAdmin", | ||
"backend": 8, | ||
"extensions": [ | ||
"gd", | ||
"intl", | ||
"zip" | ||
], | ||
"user": "sc-phpmemcachedadmin", | ||
"group": "http" | ||
"pkg_dir_prepare": [ | ||
{ | ||
"group": "http", | ||
"mode": "0755", | ||
"source": "/var/packages/phpmemcachedadmin/target/share/phpmemcachedadmin", | ||
"target": "phpmemcachedadmin", | ||
"user": "sc-phpmemcachedadmin" | ||
} | ||
}], | ||
], | ||
"portals": [ | ||
{ | ||
"service": "phpMemcachedAdmin", | ||
"type": "alias", | ||
"alias": "phpmemcachedadmin", | ||
"app": "com.synocommunity.packages.phpmemcachedadmin", | ||
"name": "PHP Memcached Admin", | ||
"alias": "phpMemcachedAdmin", | ||
"app": "com.synocommunity.packages.phpmemcachedadmin" | ||
"service": "phpmemcachedadmin", | ||
"type": "alias" | ||
} | ||
], | ||
"migrate": { | ||
"root": [{ | ||
"old": "phpMemcachedAdmin", | ||
"new": "phpMemcachedAdmin" | ||
}] | ||
}, | ||
"pkg_dir_prepare": [{ | ||
"source": "/var/packages/phpmemcachedadmin/target/share/phpMemcachedAdmin", | ||
"target": "phpMemcachedAdmin", | ||
"mode": "0755", | ||
"user": "sc-phpmemcachedadmin", | ||
"group": "http" | ||
}] | ||
"services": [ | ||
{ | ||
"backend": 2, | ||
"display_name": "PHP Memcached Admin", | ||
"icon": "app/images/phpmemcachedadmin-{0}.png", | ||
"php": { | ||
"backend": 8, | ||
"extensions": [ | ||
"gd", | ||
"intl", | ||
"zip" | ||
], | ||
"group": "http", | ||
"profile_desc": "PHP Profile for PHPMemcachedAdmin", | ||
"profile_name": "PHPMemcachedAdmin Profile", | ||
"user": "sc-phpmemcachedadmin" | ||
}, | ||
"root": "phpmemcachedadmin", | ||
"service": "phpmemcachedadmin", | ||
"type": "apache_php" | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,162 @@ | ||
|
||
PATH="${SYNOPKG_PKGDEST}/bin:${PATH}" | ||
CONFIG_DIR="${SYNOPKG_PKGVAR}/phpmemcachedadmin.config" | ||
|
||
# Package | ||
SC_DNAME="PHPMemcachedAdmin" | ||
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 | ||
|
||
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then | ||
# for DSM < 7 | ||
# for owner of var folder | ||
GROUP=http | ||
WEB_DIR=/var/services/web | ||
# Others | ||
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" | ||
# For owner of var folder | ||
GROUP="http" | ||
fi | ||
WEB_ROOT="${WEB_DIR}/${SYNOPKG_PKGNAME}" | ||
CONFIG_DIR="${SYNOPKG_PKGVAR}/phpmemcachedadmin.config" | ||
SYNOSVC="/usr/syno/sbin/synoservice" | ||
|
||
validate_preinst () | ||
{ | ||
# Check for modification to PHP template defaults on DSM 6 | ||
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then | ||
WS_TMPL_DIR="/var/packages/WebStation/target/misc" | ||
WS_TMPL_FILE="php74_fpm.mustache" | ||
WS_TMPL_PATH="${WS_TMPL_DIR}/${WS_TMPL_FILE}" | ||
# Check for PHP template defaults | ||
if ! grep -q -E '^user = http$' "${WS_TMPL_PATH}" || ! grep -q -E '^listen\.owner = http$' "${WS_TMPL_PATH}"; then | ||
echo "PHP template defaults have been modified. Installation is not supported." | ||
exit 1 | ||
fi | ||
fi | ||
} | ||
|
||
service_postinst () | ||
{ | ||
# create config file on demand | ||
# Create config file on demand | ||
if [ ! -e ${CONFIG_DIR}/Memcache.php ]; then | ||
echo "Create default config file Memcache.php" | ||
cp -f ${CONFIG_DIR}/Memcache.sample.php ${CONFIG_DIR}/Memcache.php | ||
fi | ||
|
||
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then | ||
|
||
# Web interface setup for DSM 6 -- used by INSTALL and UPGRADE | ||
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then | ||
# Install the web interface | ||
cp -R "${SYNOPKG_PKGDEST}/share/phpMemcachedAdmin" ${WEB_DIR} | ||
echo "Installing web interface" | ||
cp -R ${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} | ||
|
||
# make config writable by http group | ||
chmod -R g+w ${CONFIG_DIR} | ||
# Make config writable by http group | ||
chmod -R g+w ${CONFIG_DIR} 2>/dev/null | ||
|
||
# make Temp and other folders writable by http group | ||
chown -R :http ${WEB_DIR}/phpMemcachedAdmin | ||
chmod -R g+w ${WEB_DIR}/phpMemcachedAdmin | ||
# Make web folder writable by http group | ||
chown -R ${WEB_USER}:${WEB_GROUP} ${WEB_ROOT} 2>/dev/null | ||
chmod -R g+w ${WEB_ROOT} 2>/dev/null | ||
fi | ||
} | ||
|
||
service_postuninst () | ||
{ | ||
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then | ||
# Remove the web interface | ||
rm -rf ${WEB_DIR}/phpMemcachedAdmin | ||
fi | ||
# 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 ".[\"${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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Alias "/phpmemcachedadmin" "/var/services/web/phpmemcachedadmin" | ||
|
||
<Proxy "unix:/run/php-fpm/php-com-synocommunity-packages-phpmemcachedadmin.sock|fcgi://phpmemcachedadmin"> | ||
ProxySet timeout=3600 | ||
</Proxy> | ||
|
||
<Directory "/var/services/web/phpmemcachedadmin"> | ||
|
||
<FilesMatch "\.(php[345]?|phtml)$"> | ||
SetHandler "proxy:fcgi://phpmemcachedadmin" | ||
</FilesMatch> | ||
|
||
<IfModule dir_module> | ||
DirectoryIndex index.php index.htm index.html | ||
</IfModule> | ||
</Directory> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"backend": 8, | ||
"custom_open_basedir": false, | ||
"display_errors": false, | ||
"enable_cache": true, | ||
"enable_xdebug": false, | ||
"extensions": [ | ||
"gd", | ||
"intl", | ||
"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 PHPMemcachedAdmin", | ||
"profile_name": "PHPMemcachedAdmin Profile" | ||
} |