Module: Yast
- Defined in:
- ../../library/general/src/modules/Hooks.rb,
../../library/general/src/modules/AsciiFile.rb,
../../library/general/src/modules/ValueBrowser.rb,
../../library/general/src/modules/Stage.rb,
../../library/general/src/modules/CustomDialogs.rb,
../../library/general/src/modules/Directory.rb,
../../library/general/src/modules/Syslog.rb,
../../library/general/src/modules/Call.rb,
../../library/general/src/modules/Report.rb,
../../library/general/src/modules/UIHelper.rb,
../../library/general/src/modules/Misc.rb,
../../library/general/src/modules/Crash.rb,
../../library/general/src/modules/ConfigHistory.rb,
../../library/general/src/modules/Mode.rb,
../../library/general/src/modules/Arch.rb,
../../library/general/src/modules/Version.rb,
../../library/general/src/modules/Event.rb,
../../library/general/src/modules/Encoding.rb,
../../library/general/src/modules/Label.rb,
../../library/general/src/modules/MailAliases.rb,
../../library/general/src/modules/XVersion.rb,
../../library/general/src/modules/FileUtils.rb,
../../library/general/src/modules/Distro.rb,
../../library/general/src/modules/ContextMenu.rb,
../../library/general/src/modules/Summary.rb,
../../library/general/src/modules/DontShowAgain.rb,
../../library/general/src/modules/OSRelease.rb,
../../library/general/src/modules/Assert.rb,
../../library/general/src/modules/Icon.rb,
../../library/general/src/modules/Linuxrc.rb,
../../library/general/src/modules/Popup.rb,
../../library/general/src/modules/PackagesProposal.rb,
../../library/general/src/modules/Message.rb
Overview
Description
Main goal of hooks is to execute a third party code within the workflow of installation, system update or some other process. Hook files must be executable files written in bash, ruby or anything else available in inst-sys environment.
The module provides method #run which creates a hook and executes it instantly.
This includes following actions: * adding the hook into the hooks collection - every hook is identified by unique name which should be self-descriptive * looking up the files matching the hook script pattern: hook_name[0-9]* * executing the identified hook files * storing the results returned by the scripts for further inspection later if needed; this might be useful if some of the files has failed and we want to show it the user.
If a hook script returns non-zero result, the whole hook is considered as failed. By default the hooks are searched for in /var/lib/YaST2/hooks directory. This path can be modified globally for all hooks before they get called.
Example
-
using a hook within a yast client
module Yast import 'Hooks'
class MyFavoriteClient < Client def main # this will change the search path to /var/lib/YaST2/hooks/personal Hooks.search_path.join!('personal') # and this will set a completely different path Hooks.search_path.set “/root/hooks” hook = Hooks.run 'before_showing_ui' # Lot of beautiful and useful code follows here. # If needed make use of: # * hook.failed? # * hook.succeeded? # * hook.name # * hook.results # * hook.files # * hook.search_path # * Hooks.last.failed? # * Hooks.last.succeeded? # * Hooks.last.name # * Hooks.last.search_path # * Hooks.last.results # * Hooks.last.files Hooks.run 'after_showing_ui' # reset the search path if needed Hooks.search_path.reset end end end
Defined Under Namespace
Classes: ArchClass, AsciiFileClass, AssertClass, CallClass, ConfigHistoryClass, ContextMenuClass, CrashClass, CustomDialogsClass, DirectoryClass, DistroClass, DontShowAgainClass, EncodingClass, EventClass, FileUtilsClass, HooksClass, IconClass, LabelClass, LinuxrcClass, MailAliasesClass, MessageClass, MiscClass, ModeClass, OSReleaseClass, OSReleaseFileMissingError, PackagesProposalClass, PopupClass, ReportClass, StageClass, SummaryClass, SyslogClass, UIHelperClass, ValueBrowserClass, VersionClass, XVersionClass
Constant Summary
- AsciiFile =
AsciiFileClass.new
- ValueBrowser =
ValueBrowserClass.new
- Stage =
StageClass.new
- CustomDialogs =
CustomDialogsClass.new
- Directory =
DirectoryClass.new
- Syslog =
SyslogClass.new
- Call =
CallClass.new
- Report =
ReportClass.new
- UIHelper =
UIHelperClass.new
- Misc =
MiscClass.new
- Crash =
CrashClass.new
- ConfigHistory =
ConfigHistoryClass.new
- Mode =
ModeClass.new
- Arch =
ArchClass.new
- Version =
VersionClass.new
- Event =
EventClass.new
- Encoding =
EncodingClass.new
- Label =
LabelClass.new
- Hooks =
HooksClass.new
- MailAliases =
MailAliasesClass.new
- XVersion =
XVersionClass.new
- FileUtils =
FileUtilsClass.new
- Distro =
DistroClass.new
- ContextMenu =
ContextMenuClass.new
- Summary =
SummaryClass.new
- DontShowAgain =
DontShowAgainClass.new
- OSRelease =
OSReleaseClass.new
- Assert =
AssertClass.new
- Icon =
IconClass.new
- Linuxrc =
LinuxrcClass.new
- Popup =
PopupClass.new
- PackagesProposal =
PackagesProposalClass.new
- Message =
MessageClass.new