-
-
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.
- add synology-autorun package as autorun - add workaround for corrupt ui icons - install resources from downloaded source archive - take ui and wizard files form downloaded source archive - patch the application name to match synocommunity name space framework changes: - avoid fetching github user if maintainer is not a single name - support DSM_APP_NAME in generation of dsm ui config file
- Loading branch information
Showing
12 changed files
with
275 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
PKG_NAME = synology-autorun | ||
PKG_VERS = 1.10.0 | ||
PKG_EXT = tar.gz | ||
PKG_DIST_NAME = V$(PKG_VERS).$(PKG_EXT) | ||
PKG_DIST_SITE = https://github.com/schmidhorst/synology-autorun/archive | ||
PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) | ||
PKG_DIR = $(PKG_NAME)-$(PKG_VERS) | ||
|
||
DEPENDS = | ||
|
||
HOMEPAGE = https://github.com/schmidhorst/synology-autorun | ||
COMMENT = Executes a script on external drive \(USB / eSATA\) when it\'s connected to the disk station. | ||
LICENSE = 3-clause BSD | ||
|
||
INSTALL_TARGET = synology-autorun_install | ||
|
||
include ../../mk/spksrc.install-resources.mk | ||
|
||
.PHONY: synology-autorun_install | ||
synology-autorun_install: | ||
@$(MSG) Extract the whole package | ||
@install -d -m 755 $(STAGING_INSTALL_PREFIX)/$(PKG_NAME) | ||
tar -cf - -C $(WORK_DIR)/$(PKG_DIR) . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/$(PKG_NAME) |
Empty file.
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,3 @@ | ||
synology-autorun-1.10.0.tar.gz SHA1 67a8d2269908210a1cd94f493fde3fd0c9db3675 | ||
synology-autorun-1.10.0.tar.gz SHA256 a2822dd2e5e417da661f487860779c741c8e84008f6a60d47f8a7fefb7f2c3c6 | ||
synology-autorun-1.10.0.tar.gz MD5 e89de823634797512d309d7ecec68dc0 |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
SPK_NAME = autorun | ||
SPK_VERS = 1.10.0 | ||
SPK_REV = 11 | ||
SPK_ICON = src/synology-autorun.png | ||
DSM_UI_DIR = ui | ||
|
||
DEPENDS = cross/synology-autorun | ||
|
||
MAINTAINER = "Jan Reidemeister, Horst Schmid" | ||
MAINTAINER_URL = https://github.com/schmidhorst/synology-autorun | ||
|
||
DESCRIPTION = Executes a script on external drive \(USB / eSATA\) when it\'s connected to the disk station. | ||
DISPLAY_NAME = Autorun | ||
CHANGELOG = "Initial package hosted by SynoCommunity<br/>For full changelog see https://github.com/schmidhorst/synology-autorun/blob/main/CHANGELOG" | ||
|
||
HOMEPAGE = https://github.com/schmidhorst/synology-autorun | ||
LICENSE = 3-clause BSD | ||
|
||
# Pure script package, make sure ARCH is not defined | ||
override ARCH= | ||
|
||
CONF_DIR = $(STAGING_INSTALL_PREFIX)/synology-autorun/conf | ||
WIZARDS_DIR = $(STAGING_INSTALL_PREFIX)/synology-autorun/WIZARD_UIFILES | ||
SSS_SCRIPT = $(STAGING_INSTALL_PREFIX)/synology-autorun/scripts/start-stop-status | ||
SERVICE_SETUP = src/service-setup.sh | ||
|
||
COPY_TARGET = autorun_install | ||
|
||
include ../../mk/spksrc.spk.mk | ||
|
||
# cht, krn, nor are not (yet) supported. | ||
SPK_LANGUAGES = chs cht csy dan enu fre ger hun ita jpn nld plk ptb ptg rus spn sve trk | ||
# we must escape parentheses and single quote characters for variables holding the description | ||
SUBSTITUTION = -e 's/(/\\\(/g' -e 's/)/\\\)/g' -e s/\'/\\\\\'/g | ||
|
||
.PHONY: define_descriptions | ||
define_descriptions: | ||
@$(MSG) Define language dependent descriptions | ||
$(foreach LANG, $(SPK_LANGUAGES), $(eval DESCRIPTION_$(shell echo $(LANG) | tr [:lower:] [:upper:]) := "$(shell grep descriptionINFO $(STAGING_INSTALL_PREFIX)/synology-autorun/package/ui/texts/$(LANG)/lang.txt | sed $(SUBSTITUTION) | cut -f2 -d=)")) | ||
|
||
.PHONY: autorun_install | ||
autorun_install: define_descriptions | ||
@$(MSG) Install package resources | ||
@install -m 755 -d $(STAGING_DIR)/app $(STAGING_DIR)/../WIZARD_UIFILES | ||
@tar -cf - -C $(STAGING_INSTALL_PREFIX)/synology-autorun/package . | tar -xf - -C $(STAGING_DIR) | ||
@$(MSG) temporary fix: overwrite corrupt icons | ||
@tar -cf - -C src/images . | tar -xf - -C $(STAGING_DIR)/ui/images | ||
@chmod 755 -R $(STAGING_DIR)/ui | ||
@$(MSG) Patch the application name | ||
@sed -e s/SYNO.SDS._ThirdParty.App.autorun/com.synocommunity.packages.autorun/g -i $(STAGING_DIR)/ui/config | ||
@$(MSG) Copy additional wizard files | ||
@cp -p $(STAGING_INSTALL_PREFIX)/synology-autorun/WIZARD_UIFILES/initial_config.txt $(STAGING_DIR)/../WIZARD_UIFILES/ | ||
@cp -p $(STAGING_INSTALL_PREFIX)/synology-autorun/WIZARD_UIFILES/*.json $(STAGING_DIR)/../WIZARD_UIFILES/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,181 @@ | ||
# should be migrated to ${SYNOPKG_PKGTMP} | ||
LOG="/var/tmp/${SYNOPKG_PKGNAME}.log" | ||
DTFMT="+%Y-%m-%d %H:%M:%S" | ||
CURRENT_USER=$(whoami) | ||
SCRIPTPATHTHIS="$(cd -- "$(dirname "${0}")" >/dev/null 2>&1 ; pwd -P )" | ||
|
||
|
||
# service_preinst is obsolete. | ||
# the DSM package installer already prevents to install when DSM version is less than os_min_ver. | ||
|
||
|
||
service_postinst () | ||
{ | ||
echo "$(date "${DTFMT}"): postinst V${SYNOPKG_PKGVER} started as user '${CURRENT_USER}' ...<br/>" >> "${LOG}" | ||
|
||
# need to fetch values entered by user from environment and put to the strings file for each language | ||
# configFilePathName="$(dirname "$0")/initial_config.txt" is no more available! | ||
items="$(env | grep "^config_")" | ||
|
||
# keys="config_WAIT config_BEEP config_LED_COPY config_EJECT_TIMEOUT config_LOG_MAX_LINES config_NOTIFY_USERS config_LOGLEVEL" | ||
mapfile -t itemArray < <(/bin/printf '%s' "${items}") | ||
|
||
# echo "$(date "${DTFMT}"): Config-Items from ENV: '${itemArray[*]}'" >> "${LOG}" | ||
# config_LED, Status LED usage: | ||
# 0 = not used, | ||
# 1 = orange while script is running, green when done, | ||
# 2 = orange flashing if script result is neither 0 nor 100, | ||
# 3 = orange while running, flashing if neither 0 nor 100, else green | ||
|
||
# config_LED_COPY, Copy LED usage: | ||
# 0 = not used, | ||
# 1 = on while script is running, off after end, | ||
# 2 = flashing while script is running, off after the end, | ||
# 4 = flashing if script result is neither 0 nor 100, | ||
# 5 = on while running, flashing if script result is neither 0 nor 100, else off after end. | ||
|
||
# config_ADD_NEW_FINGERPRINTS, Security configuration: | ||
# 0 = unrestricted, no hash check | ||
# 1 = clear hash list now and register the hash of each newly executed script, | ||
# 2 = allow only previously registered hashes, | ||
# 3 = register the new onces | ||
echo "$(date "${DTFMT}"): postinst: SYNOPKG_OLD_PKGVER='${SYNOPKG_OLD_PKGVER}', SYNOPKG_PKGVER='${SYNOPKG_PKGVER}'" >> "${LOG}" | ||
rm -f "${SYNOPKG_PKGVAR}/config" | ||
echo "$(date "${DTFMT}"): file pathName: '${SYNOPKG_PKGVAR}/config' will be generated now ...<br/>" >> "${LOG}" | ||
|
||
# Messages (send to ${SYNOPKG_TEMP_LOGFILE}) are not shown up!? ==> Do the checks in start-stop-status | ||
# If terminated with "exit 1" then the old setting are lost. ==> Do the checks in start-stop-status | ||
# 1) Is the ${config_SCRIPT_AFTER_EJECT} file available, and has it correct line break and UTF8-Coding? | ||
# 2) is user or group config_NOTIFY_USERS valid? Check for valid entry requires root access and is done in the start-stop-status script | ||
|
||
msg="" | ||
for item in "${itemArray[@]}"; do | ||
# eval "${item}" # e.g. ", config_NO_DSM_MESSAGE_RETURN_CODES='98'", the ";99" is lost!??? | ||
key="${item%%=*}" | ||
# Some values with, some without quotes, remove them: | ||
val="$(sed -e 's/^\"//' -e 's/\"$//' <<<"${item#*=}")" | ||
key2=${key#*config_} | ||
if [[ -n "${key2}" ]]; then | ||
echo "${key2}=\"${val}\"" >> "${SYNOPKG_PKGVAR}/config" | ||
fi | ||
# echo "${item}: ${key2}=\"${val}\"" >> "${LOG}" | ||
msg="${msg} ${key2}='${val}'" | ||
done | ||
echo "$(date "${DTFMT}"): from ENV extracted: ${msg}" >> "${LOG}" | ||
if [[ "${config_ADD_NEW_FINGERPRINTS}" -eq "1" ]]; then | ||
KNOWNSCRIPTSFILEPATHNAME="${SYNOPKG_PKGVAR}/FINGERPRINTS" | ||
res=$(rm -f "${KNOWNSCRIPTSFILEPATHNAME}") | ||
ret=$? | ||
echo "$(date "${DTFMT}"): Deletion of old fingerprints: ${ret}, ${res}" >> "${LOG}" | ||
fi | ||
|
||
chmod 755 "${SYNOPKG_PKGVAR}/config" | ||
# Distinguish between a) new Installation, b) upgrade or c) change of settings | ||
action="Installation, upgrade or change of settings" | ||
if [[ -z "${SYNOPKG_OLD_PKGVER}" ]]; then | ||
action="Installation of V${SYNOPKG_PKGVER}" | ||
elif [[ "${SYNOPKG_OLD_PKGVER}" == "${SYNOPKG_PKGVER}" ]]; then | ||
action="Re-Installation (change of settings) of V${SYNOPKG_PKGVER}" | ||
else | ||
action="Upgrade from V${oldVers} to V${SYNOPKG_PKGVER}" | ||
fi | ||
|
||
if [[ "${config_ADD_NEW_FINGERPRINTS}" -eq "1" ]]; then | ||
echo "$(date "${DTFMT}"): ${action} done, previously registered script fingerprints deleted, not yet started" >> "${SYNOPKG_PKGVAR}/execLog" | ||
else | ||
echo "$(date "${DTFMT}"): ${action} done, not yet started" >> "${SYNOPKG_PKGVAR}/execLog" | ||
fi | ||
echo "$(date "${DTFMT}"): postinst done, not yet started, ${SYNOPKG_PKGNAME} installed<br/>" >> "${LOG}" | ||
} | ||
|
||
service_preupgrade () | ||
{ | ||
echo -e "\n$(date "${DTFMT}"): $0 (${SYNOPKG_PKGVER}) started with account '${CURRENT_USER}' ..." >> "${LOG}" | ||
# preupgrade starts from an temporary folder like /volume1/@tmp/synopkg/install.XDdQUB/scripts/preupgrade | ||
# Attention: if in the WIZARD_UIFILES folder a script is used for a dynamic ..._uifile, then it's not allowed to write here somthing to ${SYNOPKG_TEMP_LOGFILE} !!! | ||
|
||
#Developer Guide 7, Page 54, Script Execution Order | ||
# Upgrade Installation Uninstall | ||
# ------------------------------------------------------------------------------------------ | ||
# newScript upgrade_uifile.sh install_uifile.sh uninstall_uifile.sh (if available) | ||
# oldScript start-stop prestop (if running) start-stop prestop (if running) | ||
# oldScript start-stop stop (if running) start-stop stop (if running) | ||
# newScript preupgrade | ||
# oldScript preuninst preuninst | ||
# @appstore/<app> and @apptemp/<app> are deleted | ||
# oldScript postuninst postuninst | ||
# newScript prereplace?? prereplace?? | ||
# newScript preinst preinst | ||
# newScript postinst postinst | ||
# newScript postreplace | ||
# newScript postupgrade | ||
# newScript start-stop prestart start-stop prestart | ||
# newScript start-stop start start-stop start | ||
|
||
# tempStorageFolder="${SYNOPKG_TEMP_UPGRADE_FOLDER}/usersettings" # alternative temp folder (DemoUiSpk7) | ||
# /volumeX/@appdata/<app> (= /var/packages/<app>/var) is preserved during upgrade! | ||
# So there is no need for an temporary stprage folder. | ||
|
||
echo "$(date "${DTFMT}"): ... preupgrade done<br/>" >> "${LOG}" | ||
} | ||
|
||
service_postupgrade () | ||
{ | ||
echo "$(date "${DTFMT}"): postupgrade V${SYNOPKG_PKGVER} started ...<br/>" >> "${LOG}" | ||
if [[ ! -f "${SYNOPKG_PKGVAR}/config" ]]; then # not e.g. preserved from uninstall | ||
tempStorageFolder="/tmp/net.reidemeister.${SYNOPKG_PKGNAME}" | ||
if [ -d "${tempStorageFolder}" ]; then | ||
echo "$(date "${DTFMT}"): temp data folder $}tempStorageFolder} found<br/>" >> "${LOG}" | ||
# restore log | ||
if [ -f "${tempStorageFolder}/log" ]; then | ||
(cp -v "${tempStorageFolder}/log" "${SYNOPKG_PKGVAR}") 2>&1 >> "${LOG}" | ||
echo "$(date "${DTFMT}"): temp logfile copied<br/>" >> "${LOG}" | ||
fi | ||
# clean-up | ||
rm -r ${tempStorageFolder} | ||
fi | ||
fi | ||
echo "$(date "${DTFMT}"): ... postupgrade done<br/>" >> "${LOG}" | ||
} | ||
|
||
post_uninst () | ||
{ | ||
echo "$(date "${DTFMT}"): postuninst V${SYNOPKG_PKGVER} started as ${CURRENT_USER}...<br/>" >> "${LOG}" | ||
# echo "$(date "${DTFMT}"): p0='$0'" >> "${LOG}" # ${app_name} is empty!! | ||
configFilePathName="${SYNOPKG_PKGVAR}/config" # ${SYNOPKG_PKGVAR} is /volume1/@appdata/autorun and is o.k., still available | ||
# echo "$(date "${DTFMT}"): configFilePathName='${configFilePathName}'" >> "${LOG}" | ||
# after uninstall is /var/packages/${SYNOPKG_PKGNAME} no more available, only /volume1/@appdata/autorun !!! | ||
# Attention: If a new version is installed, then this file from the old version | ||
# is executed before the preinst of the new version! | ||
if [[ "${pkgwizard_remove_settings}" == "true" ]] || [[ "${pkgwizard_remove_settings}" == "false" ]]; then | ||
# WIZZARD_UIFILES/uninstall_uifile_<lng> was done before! So it's a real uninstall, not an upgrade! | ||
if [[ "${bDebug}" -eq "0" ]]; then | ||
rm "${LOG}" | ||
rm "/var/tmp/resource.${SYNOPKG_PKGNAME}.*" | ||
rm "/var/log/packages/${SYNOPKG_PKGNAME}.log" | ||
rm "/var/log/packages/${SYNOPKG_PKGNAME}.log.*.xz" | ||
rm "${SYNOPKG_PKGVAR}/execLog" | ||
# echo "$(date "${DTFMT}"): Old logfiles removed" >> "${LOG}" | ||
else | ||
echo "$(date "${DTFMT}"): Logfiles preserved due to bDebug!=0" >> "${LOG}" | ||
fi | ||
fi | ||
if [[ "${pkgwizard_remove_settings}" == "true" ]]; then | ||
res=$(rm -r --interactive=never "${SYNOPKG_PKGVAR}") # remove folder | ||
ret=$? | ||
# if [[ "${bDebug}" -ne "0" ]]; then | ||
echo "$(date "${DTFMT}"): Result from 'rm -r \"${SYNOPKG_PKGVAR}\"': ${ret}, '${res}'" >> "${LOG}" | ||
# fi | ||
else | ||
if [[ -f "${SYNOPKG_PKGVAR}\config" ]]; then | ||
# put old version to config file, so that postinst can check whether its an upgrade or only settings change | ||
res=$(grep "VERSION=" "${SYNOPKG_PKGVAR}\config") | ||
if [[ -n "${res}" ]]; then | ||
res="$(sed -i "s|^VERSION=.*$|VERSION=\"${SYNOPKG_PKGVAR}\"|" "${SYNOPKG_PKGVAR}\config")" | ||
else | ||
echo "VERSION=\"${SYNOPKG_PKGVAR}\"" >> "${SYNOPKG_PKGVAR}\config" | ||
fi | ||
fi | ||
fi | ||
echo "$(date "${DTFMT}"): ... postuninst done<br/>" >> "${LOG}" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.