-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Package Request] Autorun script on external Storage connect (USB, eSATA) #5577
Comments
@schmidhorst as far as I understand (AFAIU) you want us to host the autorun package that you forked from https://github.com/reidemei/synology-autorun? This is ok, as @reidemei does no further development (declared in https://github.com/reidemei/synology-autorun/blob/main/README.md). To host packages on https://synocommunity.com those must be created by our dev. environment. I see two options
both variants will need some investigations... |
@schmidhorst I started to create a package and found, that the icons (*.png) in the provided source archive (https://github.com/schmidhorst/synology-autorun/archive/refs/tags/V1.10.0.tar.gz) are corrupt (invalid png files) As some
|
@schmidhorst I have a second issue: Except the icons and the help files I have a working PoC. |
Hello,
Best regards |
@schmidhorst hi Horst, just pushed my work in progress. As you can see in #5659 I have created the src/service-setup.sh file containing the code from the installation steps files. Everything installs so far, except that the config file ist not created (var/config). Some other findings:
|
Hello,
thank you very much for your effort!!
Sorry for a few days delay in the response
About the “invalid package format”:
On my DS220+ with DSM 7.1.1-42962 Update 4 and also on a DSM installation (same version) in the virtual machine manager my package (https://github.com/schmidhorst/synology-autorun/releases/download/V1.10.0/autorun-1.10.0-0010.spk ) can be installed without problems to volume1. No such invalid message! In the moment I don’t know, what I can change to solve the problem:
“synoscgi_SYNO.Core.Package.Installation_1_upload[21602]: process.cpp:237 Failed to run ***@***.***/UYHM67/WIZARD_UIFILES/upgrade_uifile.sh, ret=[-1], Permission denied”?
Do you have any idea?
Should I use in during package build something else than “tar --owner=0 --group=0 …” to overcome the issue? As far I have evaluated, the account autorun is created first and the install_uifile.sh or upgrade_uifile.sh is executed as user autorun.
Besides the “normal manual package installation” via the package center I have also tried to install via command line:
sudo /usr/syno/bin/synopkg install /tmp/autorun-1.10.0-0012.spk
sudo cp /var/packages/autorun/conf/privilege.root /var/packages/autorun/conf/privilege
sudo /usr/syno/bin/synopkg start autorun
This is also working on my DSM installations. It is using the default settings of all the items asked by the WIZARD in a normal installation.
About the /bin/sh, /bin/bash and /bin/ash:
I have had some problems and found several interesting things:
* A cat /etc/shells reports on my DS220+ the availability of a lot of different shells: sh, bash, bash2, ash bsh, tcsh, csh, ksh, zsh.
As far I have read, all that shells listed in this file should be available on the machine! But that is not true for the DSM! Some of those shells are not available! I think, Synology should correct that file in the next version!
* sh and ash are redirected to bash on DSM 7.1. See
ls -l /bin/sh
or e.g.
sh -version.
Both are telling me that BASH is running!
Are there some DSM 7 disks stations running with a different shell, not using BASH?
* I have had problems with the “process substitution”, e.g. in “mapfile -d "/" -t pathItems < <(/bin/printf '%s' "$filePath")”.
If the script is started from an interactive command shell, then it was well running with #!/bin/sh.
But if the script is started from the udev daemon with that shebang #!/bin/sh, then the script was not executed due to a syntax error, which was reported in /var/log/bash_err.log !
Finally I have found the reason: The bash with the shebang /bin/sh and initiated from udev deamon is running in POSIX-compatibility mode, where the process substitution is a syntax error!
See https://stackoverflow.com/questions/25815861/why-does-using-in-a-shell-script-cause-a-syntax-error/25815924
Therefore I have changed all my shebang to #!/bin/bash!
About the problem with items="$(env | grep "^config_")":
* My install_uifile.sh (or upgrade_uifile.sh) copies the appropriate wizard_xxx.json (depending on the user language) file to $SYNOPKG_TEMP_LOGFILE. And it replaces all the “defaultValue” placeholders (e.g. ***@***.***@” for the item "key": "config_SCRIPT") by either the value from the actual installation (file /var/packages/autorun/var/config), the configuration of a previous installation (then found only under ***@***.***/autorun/config, no more via the link /var/packages/autorun/var/config) or, if there not found from /WIZARD_UIFILES/initial_config.txt.
In the DSM_Developer_Guide_ <https://global.download.synology.com/download/Document/Software/DeveloperGuide/Firmware/DSM/6.0/enu/DSM_Developer_Guide_6_0.pdf> 6_0.pdf in the chapter 3.6 WIZARD_UIFILES it’s said:
If you would like to run a script to generate the wizard dynamically, you can add install_uifile.sh, upgrade_uifile.sh and uninstall_uifile.sh files, they are run before installing, upgrading, and uninstalling a package respectively to generate UI components in JSON format and write to SYNOPKG_TEMP_LOGFILE. Script environment variables in these scripts can be gotten in these scripts.
Please refer to "Script Environment Variables" for more information.
This is, what I am using and it’s working well on my installations of DSM 7.1!
Hint: in the DSM_Developer_Guide_7_0.pdf the chapter WIZARD_UIFILES is totally missing.
* During the execution of the Synology Installation Wizard, that WIZARD writes then the entered values to the environment and uses the “key” as name (e.g. config_SCRIPT) and the entered value.
* postinst pulls that values from the environment and writes them to /var/packages/autorun/var/config.
Screenshots of the WIZARD pages I (with user language set to German) have added as Attachment.
If the install_uifile.sh could not be executed due to some permission problem, then all that WIZARD screens are not done and the items entered to the wizard are missing afterwards in the environment! And the file /var/packages/autorun/var/config is not setup!
In the next days I will look to your <#5659> #5659. (#5659 )
Thanks in advance!
Horst Schmid
Von: hgy59 ***@***.***>
Gesendet: Sonntag, 12. März 2023 18:32
An: SynoCommunity/spksrc ***@***.***>
Cc: schmidhorst ***@***.***>; Mention ***@***.***>
Betreff: Re: [SynoCommunity/spksrc] [Package Request] Autorun script on external Storage connect (USB, eSATA) (Issue #5577)
<https://github.com/schmidhorst> @schmidhorst hi Horst, just pushed my work in progress.
As you can see in <#5659> #5659 I have created the src/service-setup.sh file containing the code from the installation steps files.
Furthermore I took all the files downloaded from the release of your repository.
I special handling was needed to bring the langage dependent package descriptions into variables for our INFO file creation rule.
Everything installs so far, except that the config file ist not created (var/config).
This is caused by the empty items variable: items="$(env | grep "^config_")" - I have not a clue, where the "config_*" variables are put to the environment (did not find any related code in the wizard files).
Some other findings:
* it is obsolete to check against the os_min_ver in service preinst, as the DSM package installer validates this requirement.
* the installers of synocommunity use the shell of /bin/sh (and your scripts use /bin/bash). I temp. changed this to /bin/bash but could not see any difference.
* at uninstall, there is a checkbox to remove all related files, but this does not remove the following files
* /var/tmp/autorun.log
* ***@***.***/autorun/autorun.log ***@***.***/autorun/autorun.log>
* ***@***.***/autorun/config
* ***@***.***/autorun/detailLog (link to /var/tmp/autorun.log)
* ***@***.***/autorun/execLog
* ***@***.***/autorun/.wget-hsts ***@***.***/autorun/.wget-hsts>
* as you mentioned alread, the package update does not work (on DSM 7: invalid package format).
—
Reply to this email directly, <#5577 (comment)> view it on GitHub, or <https://github.com/notifications/unsubscribe-auth/AA67Y7JVBLU3FDZVPQQTI6LW3YB75ANCNFSM6AAAAAAUEK47WU> unsubscribe.
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AA67Y7ON6XXJFC4E2CD4IGTW3YB75A5CNFSM6AAAAAAUEK47WWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSXKYBUU.gif> Message ID: < ***@***.***> ***@***.***>
|
Software Name
Autorun
Brief Description
Executes a script when connecting external storages (USB / eSATA) on a Synology NAS with DSM 7.x. Typical use is to copy or backup some files. In Synology's Task Scheduler there is the possibility to create triggered tasks. But for the trigger event there are only Boot-up and Shutdown available. There are no events 'External storage mounted' available. This deficit is compensated by this tool.
Website
https://github.com/schmidhorst/synology-autorun
Documentation
https://github.com/schmidhorst/synology-autorun#autorun-package-v110-for-synology-nas
Build/Installation documentation
https://github.com/schmidhorst/synology-autorun#build-and-installation
Source code
https://github.com/schmidhorst/synology-autorun
OpenSource License
other (please specify below)
Other License
bsd-3-clause
The text was updated successfully, but these errors were encountered: