Skip to content

Commit

Permalink
Folder issue for debug logfile fixed
Browse files Browse the repository at this point in the history
For the debug logfile the folder /var/log/tmp was used. But this is a link to /var/tmp, which is not on all machines available. Now /var/tmp is used
  • Loading branch information
schmidhorst committed Dec 22, 2022
1 parent e518cb5 commit 9636497
Show file tree
Hide file tree
Showing 18 changed files with 23 additions and 26 deletions.
8 changes: 3 additions & 5 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

- Eject USB Drive (at exit code 100) reworked, so that it works also on DSM 7.x
- Allow to use the status LED and/or the copy LED
- Logfile for installation/upgrade actions moved from @appstore (target) to /var/log/tmp/autorun.log folder
- Debug logfile for installation/upgrade actions moved from @appstore (target) to /var/tmp/autorun.log folder
- Logfile for drive connect and drive eject actions added (in @appdata / var folder)
- Config files moved from @appstore (target) to @appdata (var) folder
- At upgrade the WIZARD is used like during the 1st installation, but the presets are read from actual configuration
Expand All @@ -13,13 +13,11 @@
- A new GUI added
- Desktop notification implemented again
- Internationalization done with machine tranlations via DeepL

- The script, which is started after external drive mounting can now be located either on the external drive or internally.

- note: for DSM 6.x use the version 1.7, which can be found
at https://github.com/reidemei/synology-autorun/releases/tag/v1.7

Known Issues:
- The Web pages do not use the language setting of the actual user but the general DSM language setting
as the file /volume1/@userpreference/<user>/usersettings is not accessible.

1.8.x/1.9
Forks from Jip-Hop (https://github.com/Jip-Hop/synology-autorun) and JC-23 (https://github.com/JC-23/synology-autorun)
Expand Down
2 changes: 1 addition & 1 deletion INFO.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [[ "$1" == "" ]]; then # Generation with toolkit scripts
source /pkgscripts-ng/include/pkg_util.sh
fi
package="autorun"
version="1.10.0-0007"
version="1.10.0-0008"
beta="yes"
arch="noarch"
os_min_ver="7.0-40000"
Expand Down
6 changes: 3 additions & 3 deletions WIZARD_UIFILES/install_uifile.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash
# $SYNOPKG_PKGNAME is available if pre-processing was well done!
LOG="/var/log/tmp/autorun.log"
LOG="/var/tmp/autorun.log"
DTFMT="+%Y-%m-%d %H:%M:%S"
SCRIPTPATHTHIS="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
user=$(whoami)
scriptpathParent=${SCRIPTPATHTHIS%/*}
echo "$(date "$DTFMT"): Start of $0 to put values from config file (if available) to '$SYNOPKG_TEMP_LOGFILE', which replaces install_uifile (as $user)" >> "$LOG"
if [[ -z "$SYNOPKG_PKGNAME" ]]; then
LOG="/var/log/tmp/autorun.log"
LOG="/var/tmp/autorun.log"
echo "$(date "$DTFMT"): Error: SYNOPKG_PKGNAME is not set in install_uifile.sh !!!???" >> "$LOG"
else
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log"
echo "$(date "$DTFMT"): install_uifile.sh SYNOPKG_PKGNAME is available: '$SYNOPKG_PKGNAME'" >> "$LOG"
fi

Expand Down
2 changes: 1 addition & 1 deletion WIZARD_UIFILES/upgrade_uifile.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log"
DTFMT="+%Y-%m-%d %H:%M:%S"
user=$(whoami)
echo "$(date "$DTFMT"): Start of $0 to put values from config file to $SYNOPKG_TEMP_LOGFILE, which replaces upgrade_uifile (as $user)" >> "$LOG"
Expand Down
2 changes: 1 addition & 1 deletion package/common
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ if [[ -z "$LOGFILE" ]]; then
# LOGFILE="$APPDATA/log" # equal to /volumeX/@appdata/<app>
# LOGFILE="/var/log/packages/$APPNAME.log" # permission denied
# /var/log/$APPNAME.log: Permission denied
LOGFILE="/var/log/tmp/$APPNAME.log" # A link /var/packages/$SYNOPKG_PKGNAME/var/detailLog is set to this (see start-stop-status script)
LOGFILE="/var/tmp/$APPNAME.log" # A link /var/packages/$SYNOPKG_PKGNAME/var/detailLog is set to this (see start-stop-status script)
# echo "common LOGFILE changed, now='$LOGFILE'"
fi
LOG="$LOGFILE"
Expand Down
2 changes: 1 addition & 1 deletion package/udev
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SCRIPTPATHTHIS="$( cd -- "$(/bin/dirname "$0")" >/dev/null 2>&1 ; /bin/pwd -P )"
APPNAME=${SCRIPTPATHTHIS##*/} # APPNAME="autorun"
source "$SCRIPTPATHTHIS/common" udev # e.g. $APPDATA = "/var/packages/$APPNAME/var" is setup there
echo "$(date "$DTFMT"): udev after common, LOG is now '$LOG'"
# LOG="/var/log/tmp/$APPNAME.log"
# LOG="/var/tmp/$APPNAME.log"

TMPPATH="/tmp/net.reidemeister.$APPNAME.$1" # Marker-File for time stamp to filter events
if [[ -z "$DTFMT" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions package/ui/index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ app_name=${app_link##*/} # "<appName>"
user=$(whoami) # EnvVar $USER may be not well set, user is '<appName>'
# REQUEST_URI=/webman/3rdparty/<appName>/index.cgi
# SCRIPT_FILENAME=/usr/syno/synoman/webman/3rdparty/<appName>/index.cgi
LOG="/var/log/tmp/${app_name}.log" # no permission if default -rw-r--r-- root:root was not changed
LOG="/var/tmp/${app_name}.log" # no permission if default -rw-r--r-- root:root was not changed
DTFMT="+%Y-%m-%d %H:%M:%S" # may be overwritten by parse_hlp
# $SHELL' is here "/sbin/nologin"
echo -e "\n$(date "$DTFMT"): App '$app_name' file '$0' started as user '$user' with parameters '$QUERY_STRING' ..." >> "$LOG"
Expand Down Expand Up @@ -303,7 +303,7 @@ if [[ -n "${QUERY_STRING}" ]]; then
get[$key]=$val
if [[ "$key" == "action" ]]; then
if [[ "$val" == "showDetailLog" ]] || [[ "$val" == "delDetailLog" ]] || [[ "$val" == "reloadDetailLog" ]] || [[ "$val" == "downloadDetailLog" ]] || [[ "$val" == "chgDetailLogLevel" ]] || [[ "$val" == "SupportEMail" ]]; then
logfile="$appCfgDataPath/detailLog" # Link to /var/log/tmp/autorun.log
logfile="$appCfgDataPath/detailLog" # Link to /var/tmp/autorun.log
pageTitle=$(echo "$logTitleDetail") # with actual LOGLEVEL
fi
if [[ "$val" == "delSimpleLog" ]] || [[ "$val" == "delDetailLog" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion package/ui/modules/parse_language.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ else
app_name=${app_link##*/} # "<appName>"
fi

LOG="/var/log/tmp/${app_name}.log"
LOG="/var/tmp/${app_name}.log"
logInfoNoEcho 6 "parse_language.sh started with param1='$1', whoami=$(whoami) ..."
if [[ "$bDebugPL" -eq "1" ]]; then
echo "see $LOG"
Expand Down
2 changes: 1 addition & 1 deletion package/ui/settings.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ user=$(whoami) # EnvVar $USER may be not well set, user is '<appName>'
# REQUEST_URI=/webman/3rdparty/<appName>/settings.cgi
# SCRIPT_FILENAME=/usr/syno/synoman/webman/3rdparty/<appName>/settings.cgi
display_name="Tool for an script autorun at storage (USB or eSATA) to DSM 7" # used as title of Page
LOG="/var/log/tmp/${app_name}.log" # no permission if default -rw-r--r-- root:root was not changed
LOG="/var/tmp/${app_name}.log" # no permission if default -rw-r--r-- root:root was not changed
DTFMT="+%Y-%m-%d %H:%M:%S" # may be overwritten by parse_hlp
echo -e "\n$(date "$DTFMT"): App '$app_name' file '$0' started as user '$user' ..." >> "$LOG"
echo -e "$(date "$DTFMT"): with parameters '$QUERY_STRING'" >> "$LOG" # e.g. "action=copyLedOff"
Expand Down
2 changes: 1 addition & 1 deletion package/ui/texts/enu/lang.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ settingFingerprint="The with root access executed script is a security risk, esp
settingSecurityWarning="<span style="color:red"><b>Attention:</b></span> Combining script variant a) (script on external USB/eSATA device) with fingerprint setting 0 or 2 can be a critical security risk: Scripts with arbitrary content on the external storage device are executed when plugged in and have access to everything! Plugging it in can be enough to destroy or steal the data on your Synology NAS!"
settingScript="Variant a: The script is located in the root directory of the external storage device and set as executable for the user 'root'. Given is the pure script name without any path or slash.<br>Variant b: The script is given with it's full path and is located on the NAS.<br>It gets the mount point of the device (e.g. /volumeUSB1/usbshare/) as the first parameter (\$1) and the device partition (e.g. usb1p1) as the second (\$2). It needs to be executable for 'root'. For 'root' is in DSM 7 the shell 'ash' used. But /bin/ash may be a link to 'bash' (at least on a DS220+). The script it's started with an empty environment! So no PATH is set. You have to use for each command the full path (e.g. /bin/echo "...", /bin/printf ...). Your script may stop with the exit code 2 if a command is not found due to a missing path. In the first lines of your script, you may use an 'unset PATH' to have in debugging runs of the script the same conditions. Or you add a line like 'PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin' to the beginning of your script."
settingScriptAfter="If the script exits with the exit code 100, then autorun will eject that storage device and afterwards call this 2nd script. This is optional. Typical usage is to power down an HDD with external supply via a smart power adapter."
settingTries="The time (in seconds) how long autorun should search for a mounted drive. Increase this value when you get the \"unable to find mount point\" error."
settingTries="The time (in seconds) how long autorun should search for a mounted drive. Increase this value when you get the 'unable to find mount point' error."
settingWait="An additional wait time (in seconds) after mounting is detected before starting the script. In some cases a few seconds delay is required for proper drive access."
settingBeep="If set to 'true', there is a short beep when a script is found. And a triple long beep in case of an error."
settingLedStatus="The status LED can be used to show the script status.<br>0: The status LED is used by this package.<br>1: 1: Green while running, green flashing during eject, OFF if finished with 0 or 100, orange flashing for other results or failed eject<br/>2: Green flashing while script is running or ejecting, green if finished with 0 or 100, orange flashing for other results or failed eject<br/>3: Green while script is running and during eject, OFF when finished, orange flashing if ejection failed."
Expand Down
2 changes: 1 addition & 1 deletion package/ui/texts/ger/lang.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ settingFingerprint="Das mit Root-Zugriff ausgeführte Skript stellt ein Sicherhe
settingSecurityWarning="<span style=\"color:red\"><b>Achtung:</b></span> Die Kombination der Skriptvariante a) (Skript auf externem USB/eSATA-Gerät) mit der Fingerprint-Einstellung 0 oder 2 kann ein kritisches Sicherheitsrisiko darstellen: Skripte mit beliebigem Inhalt auf dem externen Speichergerät werden beim Einstecken ausgeführt und haben Zugriff auf alles! Das Einstecken des Geräts kann ausreichen, um die Daten auf Ihrem Synology NAS zu zerstören oder zu stehlen!"
settingScript="Variante a: Das Skript befindet sich im Stammverzeichnis des externen Speichermediums und ist als ausführbar für den Benutzer 'root' eingestellt. Angegeben wird der reine Skriptname ohne Pfad oder Schrägstrich.<br>Variante b: Das Skript wird mit seinem vollständigen Pfad angegeben und befindet sich auf dem NAS.<br>Es erhält den Einhängepunkt des Geräts (z.B. /volumeUSB1/usbshare/) als ersten Parameter ($1) und die Gerätepartition (z.B. usb1p1) als zweiten ($2). Es muss für 'root' ausführbar sein. Für 'root' wird in DSM 7 die Shell 'ash' verwendet. Aber /bin/ash kann ein Link zu 'bash' sein (zumindest auf einer DS220 ). Das Skript wird mit einer leeren Umgebung gestartet! Es ist also kein PATH gesetzt. Sie müssen für jeden Befehl den vollen Pfad verwenden (z.B. /bin/echo "...", /bin/printf ...). Ihr Skript kann mit dem Exit-Code 2 abbrechen, wenn ein Befehl aufgrund eines fehlenden Pfades nicht gefunden wird. In den ersten Zeilen Ihres Skripts können Sie ein 'unset PATH' verwenden, um bei Debugging-Läufen des Skripts die gleichen Bedingungen zu haben. Oder Sie fügen eine Zeile wie 'PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin' an den Anfang Ihres Skripts."
settingScriptAfter="Wenn das Skript mit dem Exit-Code 100 beendet wird, wirft Autorun das Speichermedium aus und ruft anschließend dieses zweite Skript auf. Dies ist optional. Typische Anwendung ist das Ausschalten einer Festplatte mit externer Stromversorgung über einen Smart Power Adapter."
settingTries="Die Zeit (in Sekunden), wie lange Autorun nach einem gemounteten Laufwerk suchen soll. Erhöhen Sie diesen Wert, wenn Sie die Fehlermeldung "Einhängepunkt nicht gefunden" erhalten."
settingTries="Die Zeit (in Sekunden), wie lange Autorun nach einem gemounteten Laufwerk suchen soll. Erhöhen Sie diesen Wert, wenn Sie die Fehlermeldung 'Einhängepunkt nicht gefunden' erhalten."
settingWait="Eine zusätzliche Wartezeit (in Sekunden) nach dem Einhängen wird vor dem Start des Skripts erkannt. In einigen Fällen ist eine Verzögerung von einigen Sekunden für einen ordnungsgemäßen Laufwerkszugriff erforderlich."
settingBeep="Bei der Einstellung \"true\" ertönt ein kurzer Piepton, wenn ein Skript gefunden wird. Im Falle eines Fehlers ertönt ein dreifach langer Signalton."
settingLedStatus="Die Status-LED kann verwendet werden, um den Status des Skripts anzuzeigen.<br>0: Die Status-LED wird von diesem Paket verwendet.<br>1: 1: Grün, während das Skript läuft, grünes Blinken während des Auswerfens, AUS, wenn es mit 0 oder 100 beendet wurde, orangefarbenes Blinken bei anderen Ergebnissen oder fehlgeschlagenem Auswerfen<br/>2: Grünes Blinken, während das Skript läuft oder ausgeworfen wird, grün, wenn es mit 0 oder 100 beendet wurde, orangefarbenes Blinken bei anderen Ergebnissen oder fehlgeschlagenem Auswerfen<br/>3: Grün, während das Skript läuft und während des Auswerfens, AUS, wenn es beendet wurde, orangefarbenes Blinken bei fehlgeschlagenem Auswerfen."
Expand Down
2 changes: 1 addition & 1 deletion scripts/postinst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log"
DTFMT="+%Y-%m-%d %H:%M:%S"
user=$(whoami) # EnvVar $USER may be not well set
echo "$(date "$DTFMT"): postinst V$SYNOPKG_PKGVER started as user '$user' ...<br/>" >> "$LOG"
Expand Down
3 changes: 1 addition & 2 deletions scripts/postuninst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
bDebug=0 # 0: delete log files, 1: preserve log files
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log"
DTFMT="+%Y-%m-%d %H:%M:%S"
# SCRIPTPATHTHIS="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" # /var/packages/autorun/scripts/
user=$(whoami)
Expand All @@ -16,7 +16,6 @@ if [[ "${pkgwizard_remove_settings}" == "true" ]] || [[ "${pkgwizard_remove_sett
if [[ "$bDebug" -eq "0" ]]; then
rm "$LOG"
rm "/var/tmp/resource.$SYNOPKG_PKGNAME.*"
rm "/var/log/tmp/resource.$SYNOPKG_PKGNAME.*"
rm "/var/log/packages/$SYNOPKG_PKGNAME.log"
rm "/var/log/packages/$SYNOPKG_PKGNAME.log.*.xz"
rm "${SYNOPKG_PKGVAR}/execLog"
Expand Down
2 changes: 1 addition & 1 deletion scripts/postupgrade
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
# executed after postinst!
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log"
DTFMT="+%Y-%m-%d %H:%M:%S"
echo "$(date "$DTFMT"): postupgrade V$SYNOPKG_PKGVER started ...<br/>" >> "$LOG"
if [[ ! -f "${SYNOPKG_PKGVAR}/config" ]]; then # not e.g. preserved from uninstall
Expand Down
2 changes: 1 addition & 1 deletion scripts/preinst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log" # /var/log/tmp is a link to /var/tmp !!
DTFMT="+%Y-%m-%d %H:%M:%S"
SCRIPTPATHTHIS="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
# preinst starts from an temporary folder like /volume1/@tmp/synopkg/install.XDdQUB/scripts/preinst
Expand Down
2 changes: 1 addition & 1 deletion scripts/preuninst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log"
# real uninstall: uninstall wizzard was done and $pkgwizard_remove_settings setup
# update: uninstall wizzard was not done! $pkgwizard_remove_settings was not setup!
if [ "${pkgwizard_remove_settings}" == "true" ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/preupgrade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log"
DTFMT="+%Y-%m-%d %H:%M:%S"
user=$(whoami)
echo -e "\n$(date "$DTFMT"): $0 ($SYNOPKG_PKGVER) started with account '$user' ..." >> "$LOG"
Expand Down
2 changes: 1 addition & 1 deletion scripts/start-stop-status
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
user=$(whoami) # EnvVar $USER may be not well set
# user = "root" if the sudo cp /var/packages/$SYNOPKG_PKGNAME/conf/privilege.root /var/packages/$SYNOPKG_PKGNAME/conf/privilege
# user = "$SYNOPKG_PKGNAME" = '<appName>' if the copy was not done
LOG="/var/log/tmp/$SYNOPKG_PKGNAME.log"
LOG="/var/tmp/$SYNOPKG_PKGNAME.log"
DTFMT="+%Y-%m-%d %H:%M:%S"
SCRIPTPATHTHIS="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; /bin/pwd -P )" # /var/packages/autorun/scripts !!

Expand Down

0 comments on commit 9636497

Please sign in to comment.