Skip to content

Commit

Permalink
initial commit for advanced hooks (fate#314132)
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak authored and Ladislav Slezak committed Feb 1, 2013
1 parent 1a7e7db commit 6e665c4
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/modules/Wagon.ycp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@

string check_repos_module = "wagon_check_repositories";

const string hook_dir = "/var/lib/YaST2/wagon/hooks/";

global void SetUpdateWorkflow (string new_update_workflow_type) {
// FIXME: check

Expand Down Expand Up @@ -842,6 +844,50 @@ It it also safe to abort the migration now.</b></li>")
return true;
}

// <seq>_<prefix>_<name>_<stage>_<step>
// sequence number 00 -> 99 (it's important to keep the beginning zeros for correct sorting!)
// prefix - should be unique to avoid conflicts, use package name (if it is part of a package)
// or your vendor name, internet domain name, etc... basicaly anything which can be considered
// enough unique
// name - any name (just to differ the scripts), some descriptive name is recommended
// stage - can be 'before', 'after'
// step is the YCP client name, or 'abort' which is called when aborting migration
// (it can be used for cleaning up after previously called scripts)
//
// the script should return exit value 0, if it fails (non-zero exit value) it displays an error
// 000_my_script_test_after_selfupdate

global boolean RunHooks(string step, string stage) {
y2milestone("Running '%1' hooks for step: %2", stage, step);

// get all hooks
list<string> all_scripts = (list<string>)SCR::Read(.target.dir, hook_dir);

if (scripts == nil || scripts == [])
{
y2milestone("No hook scripts found");
return true;
}

// get the list of scripts for this step/stage
list<string> scripts = filter(string script, all_scripts, {
return regexpmatch(script, "$");
});

// run the scripts
foreach(string script, scripts, {
y2milestone("Starting hook script: %1", script);

integer ret = (integer)SCR::Execute(.target.bash, script);

if (ret != 0)
{
}
});

return true;
}

/**
* Check whether NCC or SMT is used for registration
*/
Expand Down

0 comments on commit 6e665c4

Please sign in to comment.