From b06a738cba570d2ceeca7493f95b2b2d9b45549a Mon Sep 17 00:00:00 2001 From: toafez Date: Sat, 30 Mar 2024 11:17:04 +0100 Subject: [PATCH] Added menu for script templates --- CHANGELOG | 11 ++ ui/execute.sh | 2 +- ui/lang/gui/lang_gui_enu.txt | 40 ++++- ui/lang/gui/lang_gui_ger.txt | 42 ++++- ui/main.sh | 220 +++++++++++++++++------ ui/modules/create_script_file.sh | 25 ++- ui/modules/custom_script_simple.template | 71 ++++++++ 7 files changed, 338 insertions(+), 73 deletions(-) create mode 100755 ui/modules/custom_script_simple.template diff --git a/CHANGELOG b/CHANGELOG index cbd07be..aa884a5 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,16 @@ AutoPilot Release Notes +Previously unpublished release + + - Deutsch + - Es wurde ein neues Menü für -benutzerdefinierte Script Templates-, sowie ein erstes, einfaches Script-Template hinzugefügt. + - Der Begriff -DiskStation- wurde in allen Texten durch den Begriff -Synology NAS- ausgetauscht. + + - English + - A new menu for -user-defined script templates- and a first, simple script template have been added. + - The term -DiskStation- has been replaced by the term -Synology NAS- in all texts. + + Version 1.1-600 vom 17.03.2024 - Deutsch diff --git a/ui/execute.sh b/ui/execute.sh index 7be1f4e..a021279 100755 --- a/ui/execute.sh +++ b/ui/execute.sh @@ -220,7 +220,7 @@ if [ -h "/usr/local/bin/${app}" ] && [[ "${result}" =~ "running" ]]; then # Execute autopilot script IFS=" " - ${scriptfile} "${log}" + ${scriptfile} "${log}" "${device}" "${mountpoint}" "${uuid}" exit_script=${?} IFS="${backupIFS}" diff --git a/ui/lang/gui/lang_gui_enu.txt b/ui/lang/gui/lang_gui_enu.txt index ecf3b1b..bc7defe 100755 --- a/ui/lang/gui/lang_gui_enu.txt +++ b/ui/lang/gui/lang_gui_enu.txt @@ -57,7 +57,7 @@ txt_help_permissions_expand_terminal="Expand app permissions using the console" txt_help_permissions_revoke_terminal="Revoke app permissions via the console" txt_help_permissions_expand_dsm="Expand app permissions via DSM Task Scheduler" txt_help_permissions_revoke_dsm="Revoke app permissions via DSM Task Scheduler" -txt_help_permissions_step_1="Login to your DiskStations console as user root and run the following command" +txt_help_permissions_step_1="Login to your Synology NAS console as user root and run the following command" txt_help_permissions_step_2="In DSM under Main Menu > Control Panel open the Task Scheduler." txt_help_permissions_step_3="In the task scheduler, use the Create > Scheduled Task > Custom Script off." txt_help_permissions_step_4="In the pop-up window that opens, enter General > General settings for the task and select root as the user. Then uncheck Enabled." @@ -107,7 +107,7 @@ txt_autopilot_is_not_installed="not installed" txt_autopilot_create_disk_01="In the following, an empty file with the name autopilot is first created for the automatic detection and execution of shell scripts on the external disk " txt_autopilot_create_disk_02=". The disk identification number " -txt_autopilot_create_disk_03=" is used to establish a unique connection to the shell script that is actually to be executed, whose name and path must be specified in the following form. If the Shell script on an internal volume of the DiskStation ensures that the content cannot be viewed or manipulated by unauthorized persons." +txt_autopilot_create_disk_03=" is used to establish a unique connection to the shell script that is actually to be executed, whose name and path must be specified in the following form. If the Shell script on an internal volume of the Synology NAS ensures that the content cannot be viewed or manipulated by unauthorized persons." txt_autopilot_sharedfolder_label="Shared Folder" txt_autopilot_targetfolder_label="Target folder (optional)" txt_autopilot_targetfolder_note="An additional target directory can be specified. The use of additional subdirectories, which are separated by a / (slash), is possible. If the target directory does not exist , it will be created automatically. Invalid characters in directory names are ~ " # % & * : &# 60; > ? / \ { | }" @@ -133,7 +133,7 @@ txt_autopilot_disconnect="After executing the linked shell script file, remove t txt_autopilot_disconnect_never="never eject" txt_autopilot_disconnect_auto="only eject if the task was processed without errors by an exit 0 return value" txt_autopilot_disconnect_manual="always eject if the task was manually terminated by an exit 100 return value" -txt_autopilot_signal="Trigger visual and audible signals from your DiskStation while AutoPilot is running" +txt_autopilot_signal="Trigger visual and audible signals from your Synology NAS while AutoPilot is running" txt_external_disks_header="External disks" txt_external_disks_not_found="No external disk connected" @@ -147,10 +147,11 @@ txt_autopilot_select_external_disk="Select external disk" txt_autopilot_note_script_overwrite="Note: Only shell scripts can be selected that have been previously connected to an external storage medium. Already existing file contents will be overwritten without asking!" txt_autopilot_change_note_step_1="Important note: From AutoPilot version 1.1-000 the content of the autopilot script file is no longer executed, but only checked whether there is an empty file with the name autopilot on the external storage medium." -txt_autopilot_change_note_step_2="Please move the contents of the current autopilot script file to a location within a shared folder on your DiskStation, give the file a new, unique name and make sure to use as the file extension .sh. Then delete the autopilot script file from this external storage medium." +txt_autopilot_change_note_step_2="Please move the contents of the current autopilot script file to a location within a shared folder on your Synology NAS, give the file a new, unique name and make sure to use as the file extension .sh. Then delete the autopilot script file from this external storage medium." txt_autopilot_updateinfo_disable="Hide information" txt_autopilot_update_scriptcontent="Script content has been revised. Please resubmit selected jobs to a shell script." +txt_autopilot_update_custom_scriptcontent="Template content has been revised." # Basic backup txt_basicbackup_header="Basic Backup jobs" @@ -192,13 +193,35 @@ txt_hyperbackup_purge_finished="Cleanup completed" txt_hyperbackup_purge_duration="Duration of cleanup job" txt_hyperbackup_purge_pid_not_found="No process identifier (PID) found for cleanup job" +# Custom Template Scripts +txt_customscripts_header="Custom Script Templates" +txt_customscripts_simple="A simple AutoPilot Script Template" +txt_customscripts_title_view_script="View AutoPilot script file for this custom script template" +txt_customscripts_package_name="Package name" +txt_customscripts_create_this_script="Pass this script template to a shell script for further processing" + +# Custom Template script log - General +txt_customscripts_execute="A custom script is executed" +txt_customscripts_script_name="Scriptname" +txt_customscripts_disk_read_out="Attention: The external disk bound to this script is read out." +txt_customscripts_check_logfile="Check if argument given for log, otherwise redirect to" +txt_customscripts_check_device="Check if argument given for the device name of the external disk, otherwise abort script" +txt_customscripts_check_mountpoint="Check if argument given for the mountpoint of the external disk, otherwise abort script" +txt_customscripts_check_uuid="Check if argument given for the uuid of the external disk, otherwise abort script" +txt_customscripts_check_example="For example:" +txt_customscripts_begin_script="Start entering your custom script here" +txt_customscripts_script_evaluation="Attention: The result of the script execution is evaluated." +txt_customscripts_no_changes="Please do not make any changes here." +txt_customscripts_finished="The custom script has been executed" +txt_customscripts_duration="Duration of execution" + # udev_device_driver.sh # ------------------------------------------------- ------------- txt_help_status_install_terminal="Install device drivers via console" txt_help_status_uninstall_terminal="Uninstall device drivers via console" txt_help_status_install_dsm="Install device drivers via DSM Task Scheduler" txt_help_status_uninstall_dsm="Uninstall device drivers via DSM Task Scheduler" -txt_help_status_step_1="Log in as user root on your DiskStations console and run the following command" +txt_help_status_step_1="Log in as user root on your Synology NAS console and run the following command" txt_help_status_step_2="Open in the DSM under Main Menu > Control Panel > Task Scheduler." txt_help_status_step_3="In the task planner, select Create > Scheduled task > Custom script." txt_help_status_step_4="In the pop-up window that now opens, enter General > General Settings give the task an individual name and select root as the user. Then you uncheck the Enabled." @@ -224,7 +247,7 @@ txt_popup_delete_logfile="Do you really want to delete the contents of the log?" # ------------------------------------------------- ------------- txt_help_setup_dsm_step_1="Install the Text Editor from the DSM Package Center." txt_help_setup_dsm_step_2="Open the text editor and use the button to create File > New a new text or shell script file. Now start writing the actual shell script." -txt_help_setup_dsm_step_3="Then save the shell script file you just created using the File > button Save as..., select a location within a shared folder on your DiskStation, give the file a unique name and use .sh as the file extension. Confirm your entries by pressing the Save button." +txt_help_setup_dsm_step_3="Then save the shell script file you just created using the File > button Save as..., select a location within a shared folder on your Synology NAS, give the file a unique name and use .sh as the file extension. Confirm your entries by pressing the Save button." txt_help_setup_dsm_step_4="To ensure that the shell script file has the Run attribute, open the File Station and switch to the corresponding storage location. By right-clicking on the file, call up the context menu and select the item Properties." txt_help_setup_dsm_step_5="You will be offered several checkboxes in the Authorization tab, which you can read about -, Write and Execute permission for Owner, Group and Other, then make sure the all checkboxes are checked. Save possible changes afterwards using the Save button." txt_help_setup_dsm_step_6="If the checkboxes just mentioned are not offered to you in the Authorization tab, then create one using the button Create a new permission. Select from the selection menu under User or Group, Everyone and under Type, Allow. Check all checkboxes under Permissions Administration, reading and writing and click on the Done button. Then save your changes using the Save button." @@ -233,8 +256,8 @@ txt_help_setup_dsm_step_8="Eject the external storage device via the DSM. The ne # setup_via_terminal.sh # ------------------------------------------------- ------------- -txt_help_setup_terminal_step_1="Log in as a user from the group of administrators or as a user root on your DiskStations console." -txt_help_setup_terminal_step_2="Switch to a location within a shared folder on your DiskStation e.g." +txt_help_setup_terminal_step_1="Log in as a user from the group of administrators or as a user root on your Synology NAS console." +txt_help_setup_terminal_step_2="Switch to a location within a shared folder on your Synology NAS e.g." txt_help_setup_terminal_step_3="Create a new shell script file, give the file a unique name, use .sh as the file extension and adjust the file permissions accordingly. ( Important: The shell script file must always have the Execute attribute." txt_help_setup_terminal_step_4="There are several options available to fill the shell script file with content. One of them would be to use the editor vim." txt_help_setup_terminal_step_5="After calling vim, you will initially be in command mode. Therefore, the contents of the still empty file autopilot will only be displayed to you. In order to be able to enter text, you must press the [ i ] key. Switch to insert mode, i.e. text insertion mode (Important: do not enter any text beforehand!). Begin now with the input." @@ -254,3 +277,4 @@ txt_help_setup_step_5="AutoPilot informs that, regardless of the exit code actua + diff --git a/ui/lang/gui/lang_gui_ger.txt b/ui/lang/gui/lang_gui_ger.txt index d6e7f3b..021a69b 100755 --- a/ui/lang/gui/lang_gui_ger.txt +++ b/ui/lang/gui/lang_gui_ger.txt @@ -57,7 +57,7 @@ txt_help_permissions_expand_terminal="App-Berechtigungen über die Konsole erwei txt_help_permissions_revoke_terminal="App-Berechtigungen über die Konsole zurücknehmen" txt_help_permissions_expand_dsm="App-Berechtigungen über den DSM Aufgabenplaner erweitern" txt_help_permissions_revoke_dsm="App-Berechtigungen über den DSM Aufgabenplaner zurücknehmen" -txt_help_permissions_step_1="Melde dich als Benutzer root auf der Konsole deiner DiskStation an und führe folgenden Befehl aus" +txt_help_permissions_step_1="Melde dich als Benutzer root auf der Konsole deiner Synology NAS an und führe folgenden Befehl aus" txt_help_permissions_step_2="Öffne im DSM unter Hauptmenü > Systemsteuerung den Aufgabenplaner." txt_help_permissions_step_3="Wähle im Aufgabenplaner über die Schaltfläche Erstellen > Geplante Aufgabe > Benutzerdefiniertes Script aus." txt_help_permissions_step_4="In dem sich nun öffnenden Pop-up-Fenster gibst du im Reiter Allgemein > Allgemeine Einstellungen der Aufgabe einen individuellen Namen und wählst als Benutzer root aus. Anschließend entfernst du noch den Haken bei Aktiviert." @@ -107,7 +107,7 @@ txt_autopilot_is_not_installed="nicht installiert" txt_autopilot_create_disk_01="Im Folgenden wird zur automatischen Erkennung und Ausführung von Shell-Scripten zunächst eine leere Datei mit dem Namen autopilot auf dem ext. Datenträger " txt_autopilot_create_disk_02=" angelegt. Anhand seiner Datenträger-Identifikationsnummer " -txt_autopilot_create_disk_03=" wird anschließend eine eindeutige Verbindung zum eigentlich auszuführenden Shell-Script hergestellt, dessen Name und Pfad im unteren Formular anzugeben ist. Befindet sich das Shell-Script dabei auf einem internen Volume der DiskStation ist sichergestellt, das für Unbefugte weder der Inhalt einsehbar, noch manipulierbar ist." +txt_autopilot_create_disk_03=" wird anschließend eine eindeutige Verbindung zum eigentlich auszuführenden Shell-Script hergestellt, dessen Name und Pfad im unteren Formular anzugeben ist. Befindet sich das Shell-Script dabei auf einem internen Volume der Synology NAS ist sichergestellt, das für Unbefugte weder der Inhalt einsehbar, noch manipulierbar ist." txt_autopilot_sharedfolder_label="Freigegebener Ordner" txt_autopilot_targetfolder_label="Zielverzeichnis (optional)" txt_autopilot_targetfolder_note="Es kann ein weiteres Zielverzeichnis angegeben werden. Die Verwendung weiterer Unterverzeichnisse, die durch einen / (Slash) getrennt werden, ist möglich. Ist das Zielverzeichnis nicht vorhanden, wird es automatisch angelegt. Ungültige Zeichen in Verzeichnisnamen sind ~ " # % & * : < > ? / \ { | }" @@ -133,7 +133,7 @@ txt_autopilot_disconnect="Nach der Ausführung der verknüpften Shell-Scriptdate txt_autopilot_disconnect_never="niemals auswerfen" txt_autopilot_disconnect_auto="nur auswerfen, wenn die Aufgabe durch einen exit 0 Rückgabewert fehlerfrei abgearbeitet wurde" txt_autopilot_disconnect_manual="immer auswerfen, wenn die Aufgabe durch einen exit 100 Rückgabewert manuell beendet wurde" -txt_autopilot_signal="Optische und akustische Signalausgaben deiner DiskStation während der Ausführung von AutoPilot auslösen" +txt_autopilot_signal="Optische und akustische Signalausgaben deiner Synology NAS während der Ausführung von AutoPilot auslösen" txt_external_disks_header="Externe Datenträger" txt_external_disks_not_found="Es ist kein externer Datenträger angeschlossen" @@ -147,10 +147,11 @@ txt_autopilot_select_external_disk="Externen Datenträger auswählen" txt_autopilot_note_script_overwrite="Hinweis: Es können nur Shell-Scripte ausgewählt werden, die im Vorfeld mit einem externen Datenträger verbunden wurden. Bereits vorhandene Dateiinhalte werden ohne Nachfrage überschrieben!" txt_autopilot_change_note_step_1="Wichtiger Hinweis: Ab AutoPilot Version 1.1-000 wird der Inhalt der autopilot Scriptdatei nicht mehr ausgeführt, sondern nur noch geprüft, ob sich eine leere Datei mit dem Namen autopilot auf dem externen Datenträger befindet." -txt_autopilot_change_note_step_2="Verschiebe daher bitte den Inhalt der aktuellen autopilot Scriptdatei an einen Ort innerhalb eines freigegebenen Ordners deiner DiskStation, gib der Datei einen neuen, eindeutigen Namen und verwende als Dateiendung zwingend .sh. Lösche anschließend die autopilot Scriptdatei von diesem externen Datenträger." +txt_autopilot_change_note_step_2="Verschiebe daher bitte den Inhalt der aktuellen autopilot Scriptdatei an einen Ort innerhalb eines freigegebenen Ordners deiner Synology NAS, gib der Datei einen neuen, eindeutigen Namen und verwende als Dateiendung zwingend .sh. Lösche anschließend die autopilot Scriptdatei von diesem externen Datenträger." txt_autopilot_updateinfo_disable="Information ausblenden" txt_autopilot_update_scriptcontent="Scriptinhalte wurden überarbeitet. Ausgewählte Aufträge bitte erneut an ein Shell-Script übergeben." +txt_autopilot_update_custom_scriptcontent="Template Inhalte wurden überarbeitet." # Basic Backup txt_basicbackup_header="Basic Backup Aufträge" @@ -158,7 +159,6 @@ txt_basicbackup_title_view_script="AutoPilot Scriptdatei für diesen Basic Backu txt_basicbackup_package_name="Paketname" txt_basicbackup_job_name="Auftragsname" - # Basic Backup script log txt_basicbackup_execute="Es wird ein Basic Backup Auftrag ausgeführt" txt_basicbackup_taskname="Name des Auftrages: " @@ -193,13 +193,36 @@ txt_hyperbackup_purge_finished="Bereinigung abgeschlossen" txt_hyperbackup_purge_duration="Dauer der Bereinigung" txt_hyperbackup_purge_pid_not_found="Keine Prozesskennung (PID) der Bereinigung gefunden" +# Custom Template Scripts +txt_customscripts_header="Benutzerdefinierte Script Templates" +txt_customscripts_simple="Ein einfaches AutoPilot Script Template" +txt_customscripts_title_view_script="AutoPilot Scriptdatei für dieses benutzerdefinierte Script Template ansehen" +txt_customscripts_package_name="Paketname" +txt_customscripts_create_this_script="Dieses Script Template zur weiteren Bearbeitung an ein Shell-Script übergeben" + +# Custom Template script log - Gerneral +txt_customscripts_execute="Es wird ein benutzerdefiniertes Script ausgeführt" +txt_customscripts_script_name="Scriptname" +txt_customscripts_disk_read_out="Achtung! Der mit diesem Skript verbundene externe Datenträger wird ausgelesen." +txt_customscripts_check_logfile="Prüfen, ob ein Argument für das Protokoll übergeben wurde, ansonsten Umleitung nach" +txt_customscripts_check_device="Prüfen, ob das Argument für den Gerätenamen des externen Datenträgers übergeben wurde, andernfalls Abbruch des Skripts." +txt_customscripts_check_mountpoint="Prüfen, ob das Argument für den Einhängepunkt des externen Datenträgers übergeben wurde, andernfalls Abbruch des Skripts." +txt_customscripts_check_uuid="Prüfen, ob das Argument für die uuid des externen Datenträges übergeben wurde, andernfalls Abbruch des Skripts." +txt_customscripts_check_example="Zum Beispiel:" +txt_customscripts_begin_script="Beginne hier mit der Eingabe deines benutzerdefinierten Skripts" +txt_customscripts_script_evaluation="Achtung! Das Ergebnis der Skriptausführung wird ausgewertet." +txt_customscripts_no_changes="Hier bitte keine Änderungen vornehmen." +txt_customscripts_finished="Das benutzerdefinierte Script wurde ausgeführt" +txt_customscripts_duration="Dauer der Ausführung" + + # udev_device_driver.sh # -------------------------------------------------------------- txt_help_status_install_terminal="Gerätetreiber über die Konsole installieren" txt_help_status_uninstall_terminal="Gerätetreiber über die Konsole deinstallieren" txt_help_status_install_dsm="Gerätetreiber über den DSM Aufgabenplaner installieren" txt_help_status_uninstall_dsm="Gerätetreiber über den DSM Aufgabenplaner deinstallieren" -txt_help_status_step_1="Melde dich als Benutzer root auf der Konsole deiner DiskStation an und führe folgenden Befehl aus" +txt_help_status_step_1="Melde dich als Benutzer root auf der Konsole deiner Synology NAS an und führe folgenden Befehl aus" txt_help_status_step_2="Öffne im DSM unter Hauptmenü > Systemsteuerung den Aufgabenplaner." txt_help_status_step_3="Wähle im Aufgabenplaner über die Schaltfläche Erstellen > Geplante Aufgabe > Benutzerdefiniertes Script aus." txt_help_status_step_4="In dem sich nun öffnenden Pop-up-Fenster gibst du im Reiter Allgemein > Allgemeine Einstellungen der Aufgabe einen individuellen Namen und wählst als Benutzer root aus. Anschließend entfernst du noch den Haken bei Aktiviert." @@ -225,7 +248,7 @@ txt_popup_delete_logfile="Soll der Inhalt des Protokolls wirklich gelöscht werd # -------------------------------------------------------------- txt_help_setup_dsm_step_1="Installiere dir den Text-Editor aus dem DSM Paket-Zentrum." txt_help_setup_dsm_step_2="Öffne den Text-Editor und erstelle über die Schaltfläche Datei > Neu eine neue Text- bzw. Shell-Scriptdatei. Beginne nun mit dem schreiben des eigentlichen Shellscriptes." -txt_help_setup_dsm_step_3="Speicher anschließend die grade erstellte Shell-Scriptdatei über die Schaltfläche Datei > Speichern unter..., wähle einen Ort innerhalb eines freigegebenen Ordners deiner DiskStation aus, gib der Datei einen eindeutigen Namen und verwende als Dateiendung zwingend .sh . Bestätige deine Eingaben durch drücken der Schaltfläche Speichern." +txt_help_setup_dsm_step_3="Speicher anschließend die grade erstellte Shell-Scriptdatei über die Schaltfläche Datei > Speichern unter..., wähle einen Ort innerhalb eines freigegebenen Ordners deiner Synology NAS aus, gib der Datei einen eindeutigen Namen und verwende als Dateiendung zwingend .sh . Bestätige deine Eingaben durch drücken der Schaltfläche Speichern." txt_help_setup_dsm_step_4="Um sicherzustellen, das die Shell-Scriptdatei das Attribut Ausführen besitzt, öffne die File Station und wechsel zu dem entsprechenden Speicherort. Ruf durch einen Rechtsklick auf die Datei das Kontextmenü auf und wähle dort den Punkt Eigenschaften aus." txt_help_setup_dsm_step_5="Werden dir im Reiter Berechtigung mehrere Checkboxen angeboten, worüber du die Lese-, Schreib- und Ausführberechtigung für Besitzer, Gruppe und Sonstige festlegen kannst, dann stell sicher, das alle Checkboxen angehakt sind. Speicher mögliche Änderungen im Anschluss über die Schaltfläche Speichern." txt_help_setup_dsm_step_6="Werden dir im Reiter Berechtigung die grade genannten Checkboxen nicht angeboten, dann erstelle über die Schaltfläche Erstellen eine neue Berechtigung. Wähle aus dem Auswahlmenü unter dem Punkt Benutzer oder Gruppe, Everyone und unter dem Punkt Typ, Zulassen aus. Hake unter dem Punkt Berechtigungen alle Checkboxen für Administration, Lesen und Schreiben an und klicke auf die Schaltfläche Fertig. Speicher deine Änderungen im Anschluss über die Schaltfläche Speichern." @@ -234,8 +257,8 @@ txt_help_setup_dsm_step_8="Werfe den externen Datenträger über den DSM aus. Be # setup_via_terminal.sh # -------------------------------------------------------------- -txt_help_setup_terminal_step_1="Melde dich mit einem Benutzer aus der Gruppe der Administratoren oder als Benutzer root auf der Konsole deiner DiskStation an." -txt_help_setup_terminal_step_2="Wechsel zu einen Ort innerhalb eines freigegebenen Ordners deiner DiskStation z.B." +txt_help_setup_terminal_step_1="Melde dich mit einem Benutzer aus der Gruppe der Administratoren oder als Benutzer root auf der Konsole deiner Synology NAS an." +txt_help_setup_terminal_step_2="Wechsel zu einen Ort innerhalb eines freigegebenen Ordners deiner Synology NAS z.B." txt_help_setup_terminal_step_3="Erstelle eine neue Shell-Scriptdatei, gib der Datei einen eindeutigen Namen, verwende als Dateiendung zwingend .sh und passe die Dateirechte entsprechend an. (Wichtig: Die Shell-Scriptdatei muss in jedem Fall das Attribut Ausführen besitzen)." txt_help_setup_terminal_step_4="Um nun die Shell-Scriptdatei mit Inhalten zu füllen stehen mehrere Möglichkeiten zur Verfügung. Eine davon wäre die Verwendung des Editors vim." txt_help_setup_terminal_step_5="Nach dem Aufruf von vim befindest du dich zunächst im Kommandomodus. Daher wird dir der Inhalt der noch leeren Datei autopilot nur angezeigt. Um nun Text eingeben zu können musst du mit der Taste [ i ] in den Insert-Modus, also dem Texteinfüge-Modus wechseln (Wichtig: vorher keinen Text eingeben!). Beginne nun mit der Eingabe." @@ -254,3 +277,4 @@ txt_help_setup_step_5="AutoPilot mitteilt, das unabhängig vom tatsächlich übe + diff --git a/ui/main.sh b/ui/main.sh index ab1a35e..0047f98 100755 --- a/ui/main.sh +++ b/ui/main.sh @@ -69,6 +69,36 @@ function external_target() unset volume share } +# Function: Select Script destination +# -------------------------------------------------------------- +function script_target () +{ + echo ' +
+
+ + +
+
+ '${txt_autopilot_note_script_overwrite}' +
+
' +} + # Load library function to generate script files of tempalte # -------------------------------------------------------------- [ -f "${app_home}/modules/create_script_file.sh" ] && source "${app_home}/modules/create_script_file.sh" @@ -432,7 +462,7 @@ if [[ "${get[page]}" == "main" && "${get[section]}" == "start" ]]; then | '${txt_basicbackup_header}'  ' - if [ -z "${basicbackup_updateinfo}"] || [[ "${basicbackup_updateinfo}" != "${app_version}" ]]; then + if [[ "${basicbackup_updateinfo}" != "${app_version}" ]]; then echo ' @@ -485,31 +515,11 @@ if [[ "${get[page]}" == "main" && "${get[section]}" == "start" ]]; then
' fi + + # Costum Script tasks + # -------------------------------------------------------------- + if [[ "${permissions}" == "true" ]]; then + echo ' +
+ +
+
+
' + + # Simple custom script + # -------------------------------------------------------------- + echo ' +
' + if [[ "${customscripts_updateinfo}" != "${app_version}" ]]; then + echo ''${txt_customscripts_simple}' Update' + else + echo ''${txt_customscripts_simple}'' + fi + echo ' +
+ + + + + + + + + + +
+
+
' + custom_script_simple_tmp_file="${app_home}/temp/custom_script_simple.tmp" + + # Function: Generate Custom Script File + custom_script_simple "${txt_customscripts_simple}" "${custom_script_simple_tmp_file}" + + echo -n '
'
+											cat "${custom_script_simple_tmp_file}"
+											echo -n '
+
+
+
' + # -------------------------------------------------------------- + + echo ' +
+
+
+
' + fi + echo '
' @@ -710,12 +803,12 @@ if [[ "${get[page]}" == "main" && "${get[section]}" == "start" ]]; then echo '
- '${txt_autopilot_options_header}'
-
+
@@ -983,6 +1076,24 @@ if [[ "${get[page]}" == "main" && "${post[section]}" == "hyperbackup" ]]; then fi fi +# Create Custom Script +# -------------------------------------------------------------- +if [[ "${get[page]}" == "main" && "${post[section]}" == "custom_script_simple" ]]; then + + scriptname="${post[scriptname]}" + scriptfile="${post[filename]}" + + if [ -f "${scriptfile}" ]; then + # Generate script file from template by replacing language specific keywords. + # Function: Generate Hyper Backup Script + custom_script_simple "${scriptname}" "${scriptfile}" + + [ -f "${get_request}" ] && rm "${get_request}" + [ -f "${post_request}" ] && rm "${post_request}" + echo '' + fi +fi + # Save AutoPilot configuration # -------------------------------------------------------------- if [[ "${get[page]}" == "main" && "${get[section]}" == "settings" ]]; then @@ -994,5 +1105,6 @@ if [[ "${get[page]}" == "main" && "${get[section]}" == "settings" ]]; then [[ "${get[switch]}" == "signal" ]] && "${set_keyvalue}" "${usr_autoconfig}" "signal" "${get[query]}" [[ "${get[switch]}" == "basicbackup_updateinfo" ]] && "${set_keyvalue}" "${usr_autoconfig}" "basicbackup_updateinfo" "${get[query]}" [[ "${get[switch]}" == "hyperbackup_updateinfo" ]] && "${set_keyvalue}" "${usr_autoconfig}" "hyperbackup_updateinfo" "${get[query]}" + [[ "${get[switch]}" == "customscripts_updateinfo" ]] && "${set_keyvalue}" "${usr_autoconfig}" "customscripts_updateinfo" "${get[query]}" echo '' fi \ No newline at end of file diff --git a/ui/modules/create_script_file.sh b/ui/modules/create_script_file.sh index b3ff37e..26484e4 100755 --- a/ui/modules/create_script_file.sh +++ b/ui/modules/create_script_file.sh @@ -48,7 +48,7 @@ function hyper_backup_script () sed -e "s/___TASK_ID___/${hyper_backup_job_id}/g" \ -e "s/___JOB_NAME___/${hyper_backup_job_name}/g" \ -e "s/___TXT_HYPERBACKUP_EXECUTE___/${txt_hyperbackup_execute}/g" \ - -e "s/___TXT_HYPERBACKUP_TASKNAME___/${txt_hyperbackup_taskname}${2}/g" \ + -e "s/___TXT_HYPERBACKUP_TASKNAME___/${txt_hyperbackup_taskname}${hyper_backup_job_name}/g" \ -e "s/___TXT_HYPERBACKUP_WAIT_FOR_START___/${txt_hyperbackup_wait_for_start}/g" \ -e "s/___TXT_HYPERBACKUP_IN_PROGRESS___/${txt_hyperbackup_in_progress}/g" \ -e "s/___TXT_HYPERBACKUP_PID_SEARCH___/${txt_hyperbackup_pid_search}/g" \ @@ -63,4 +63,27 @@ function hyper_backup_script () -e "s/___TXT_HYPERBACKUP_PURGE_DURATION___/${txt_hyperbackup_purge_duration}/g" \ -e "s/___TXT_HYPERBACKUP_PURGE_PID_NOT_FOUND___/${txt_hyperbackup_purge_pid_not_found}/g" \ "${app_home}"/modules/hyper_backup_script.template > "${hyper_backup_script_tmp_file}" +} + +# Function: Generate simple custom script +# -------------------------------------------------------------- +function custom_script_simple () +{ + custom_script_name="$1" + custom_script_simple_tmp_file="$2" + + sed -e "s/___SCRIPT_NAME___/${custom_script_name}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_EXECUTE___/${txt_customscripts_execute}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_DISK_READ_OUT___/${txt_customscripts_disk_read_out}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_SCRIPT_EVALUTION___/${txt_customscripts_script_evaluation}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_CHECK_LOGFILE___/${txt_customscripts_check_logfile}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_CHECK_DEVICE___/${txt_customscripts_check_device}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_CHECK_MOUNTPOINT___/${txt_customscripts_check_mountpoint}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_CHECK_UUID___/${txt_customscripts_check_uuid}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_CHECK_EXAMPLE___/${txt_customscripts_check_example}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_BEGIN_SCRIPT___/${txt_customscripts_begin_script}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_NO_CHANGES___/${txt_customscripts_no_changes}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_FINISHED___/${txt_customscripts_finished}/g" \ + -e "s/___TXT_CUSTOMSCRIPTS_DURATION___/${txt_customscripts_duration}/g" \ + "${app_home}"/modules/custom_script_simple.template > "${custom_script_simple_tmp_file}" } \ No newline at end of file diff --git a/ui/modules/custom_script_simple.template b/ui/modules/custom_script_simple.template new file mode 100755 index 0000000..47d0b60 --- /dev/null +++ b/ui/modules/custom_script_simple.template @@ -0,0 +1,71 @@ +#!/bin/bash +# Execute a AutoPilot custom script +# Script name: ___SCRIPT_NAME___ + +# ----------------------------------------------------------------------------- +# ___TXT_CUSTOMSCRIPTS_DISK_READ_OUT___ +# ___TXT_CUSTOMSCRIPTS_NO_CHANGES___ +# ----------------------------------------------------------------------------- + + # ___TXT_CUSTOMSCRIPTS_CHECK_LOGFILE___ /dev/null + if [ -n "$1" ]; then + logfile=$1 + else + logfile=/dev/null + fi + + # ___TXT_CUSTOMSCRIPTS_CHECK_DEVICE___ + if [ -n "$2" ]; then + # ___TXT_CUSTOMSCRIPTS_CHECK_EXAMPLE___ device="/dev/usb1p1" + device="$2" + else + exit 1 + fi + + # ___TXT_CUSTOMSCRIPTS_CHECK_MOUNTPOINT___ + if [ -n "$3" ]; then + # ___TXT_CUSTOMSCRIPTS_CHECK_EXAMPLE___ mountpoint="/volumeUSB1/usbshare" + mountpoint="$3" + else + exit 1 + fi + + # ___TXT_CUSTOMSCRIPTS_CHECK_UUID___ + if [ -n "$4" ]; then + # ___TXT_CUSTOMSCRIPTS_CHECK_EXAMPLE___ uuid="550e8400-e29b-11d4-a716-446655440000" + uuid="$4" + else + exit 1 + fi + + echo -e "___TXT_CUSTOMSCRIPTS_EXECUTE___" >> "$logfile" + timestamp_start=$(date +%s) +# ----------------------------------------------------------------------------- + + +# ----------------------------------------------------------------------------- +# ___TXT_CUSTOMSCRIPTS_BEGIN_SCRIPT___ +# ----------------------------------------------------------------------------- + # . + # .. + # ___TXT_CUSTOMSCRIPTS_CHECK_EXAMPLE___ + echo -e "Path to the log: $logfile" >> "$logfile" + echo -e "Device name of the connected disk: $device" >> "$logfile" + echo -e "Mountpoint of the connected disk: $mountpoint" >> "$logfile" + echo -e "UUID of the connected disk: $uuid" >> "$logfile" + # .. + #. +# ----------------------------------------------------------------------------- +result=$? + + +# ----------------------------------------------------------------------------- +# ___TXT_CUSTOMSCRIPTS_SCRIPT_EVALUTION___ +# ___TXT_CUSTOMSCRIPTS_NO_CHANGES___ +# ----------------------------------------------------------------------------- + echo -e "___TXT_CUSTOMSCRIPTS_FINISHED___" >> "$logfile" + + duration="$(($(date +%s) - timestamp_start))" + echo -e "___TXT_CUSTOMSCRIPTS_DURATION___: "$(printf '%dh:%dm:%ds\n' $((duration/3600)) $((duration%3600/60)) $((duration%60)))"\n" >> "$logfile" +# ----------------------------------------------------------------------------- +exit "$result"