Skip to content
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

Checking for systemd scripts in more directories (bnc#795929) #37

Merged
merged 5 commits into from Jan 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 14 additions & 15 deletions library/runlevel/src/Service.ycp
Expand Up @@ -72,14 +72,9 @@ import "FileUtils";
string invoker = "/bin/systemctl";

/**
* Script location
* Unit locations for systemd
*/
string init_d = "/etc/init.d";

/**
* Unit location for systemd
*/
string systemd_d = "/lib/systemd/system";
list <string> systemd_dirs = ["/usr/lib/systemd/system", "/run/systemd/system", "/etc/systemd/system"];

/**
* After a function returns an error, this holds an error message,
Expand All @@ -101,20 +96,27 @@ string error_msg = "";
define boolean checkExists (string name) {
if(name == nil || name == "") {
// Error message.
// %1 is a name of an init script in /lib/systemd/system,
// %1 is a name of an init script in /usr/lib/systemd/system,
// eg. nfsserver
error_msg = sformat (_("Empty service name: %1."), name);
y2error(1, error_msg);
return false;
}

if (FileUtils::Exists(sformat("%1/%2.service", systemd_d,name))) {
boolean service_exists = false;


string target_dir = find(string directory, systemd_dirs,
``(FileUtils::Exists(sformat("%1/%2.service", directory, name)))
);

if (target_dir != nil) {
return true;
} else {
// Error message.
// %1 is a name of an init script in /lib/systemd/system,
// %1 is a name of an init script in /usr/lib/systemd/system,
// eg. nfsserver
error_msg = sformat (_("Service %1 does not exist in %2."), name, systemd_d);
error_msg = sformat (_("Service %1 does not exist in %2."), name, mergestring(systemd_dirs, ", "));
y2milestone (1, error_msg);
return false;
}
Expand Down Expand Up @@ -361,9 +363,6 @@ global define integer RunInitScriptWithTimeOut (string name, string param) {

string lang = nil;

/**
* Run init script and return output
*/
/**
* Run init script and also return its output (stdout and stderr merged).
* @param name init service name
Expand Down Expand Up @@ -396,7 +395,7 @@ global define map RunInitScriptOutput (string name, string param) {
// locale_debug = "; ls /nono 2>&1; /usr/bin/locale; /usr/bin/env";

return (map)SCR::Execute (.target.bash_output,
sformat ("%2/%1 %3 2>&1", name, init_d, param)
sformat ("%1 %2 %3.service 2>&1", invoker, param, name)
+ locale_debug,
env);
}
Expand Down
28 changes: 15 additions & 13 deletions library/runlevel/testsuite/tests/ServiceAdjust.out
@@ -1,37 +1,39 @@
Read .target.tmpdir "/tmp"
Read .target.stat "/lib/systemd/system/aaa.service" $[]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $[]
Read .target.stat "/run/systemd/system/aaa.service" $[]
Read .target.stat "/etc/systemd/system/aaa.service" $[]
Log Service aaa does not exist.
Return false
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":["0", "1", "3"], "stop":["4", "5", "6"]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["0", "1", "3"], "defstop":["4", "5", "6"]]]
Execute .target.bash_output "/bin/systemctl disable aaa.service" $["exit":0, "stderr":"", "stdout":""]
Return true
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":[], "stop":[]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["0", "1", "3"], "defstop":["4", "5", "6"]]]
Return true
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":[], "stop":[]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["0", "1", "3"], "defstop":["4", "5", "6"]]]
Execute .target.bash_output "/bin/systemctl enable aaa.service" $["exit":0, "stderr":"", "stdout":""]
Return true
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":["1"], "stop":[]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["0", "1", "3"], "defstop":["4", "5", "6"]]]
Return true
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":["1"], "stop":[]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["0", "1", "3"], "defstop":["4", "5", "6"]]]
Execute .target.bash_output "/bin/systemctl enable aaa.service" $["exit":0, "stderr":"", "stdout":""]
Return true
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":["0", "1", "3"], "stop":[]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["0", "1", "3"], "defstop":["4", "5", "6"]]]
Execute .target.bash_output "/bin/systemctl enable aaa.service" $["exit":0, "stderr":"", "stdout":""]
Expand Down
8 changes: 4 additions & 4 deletions library/runlevel/testsuite/tests/ServiceFinetune.out
@@ -1,12 +1,12 @@
Read .target.tmpdir "/tmp"
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Log Cannot enable service aaa (just) in selected runlevels, enabling in all default ones
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":[], "stop":[]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["3", "5"], "defstop":["0", "1", "2", "6"], "description":"description", "provides":["aaa"], "reqstart":["$local_fs", "$remote_fs", "$network"], "reqstop":["$local_fs", "$remote_fs", "$network"], "shortdescription":"description", "shouldstart":["$time"], "shouldstop":["$time"]]]
Execute .target.bash_output "/bin/systemctl enable aaa.service" $["exit":0, "stderr":"", "stdout":""]
Return true
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Execute .target.bash_output "/bin/systemctl --force disable aaa.service" $["exit":0, "stderr":"", "stdout":""]
Return true
6 changes: 3 additions & 3 deletions library/runlevel/testsuite/tests/ServiceFullInfo.out
@@ -1,8 +1,8 @@
Read .target.tmpdir "/tmp"
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":["0", "1", "3"], "stop":["4", "5", "6"]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["0", "1", "3"], "defstop":["4", "5", "6"]]]
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Execute .target.bash "/bin/systemctl status aaa.service" $["TERM":"raw"] 3
Return $["defstart":["0", "1", "3"], "defstop":["4", "5", "6"], "start":["0", "1", "3"], "started":3, "stop":["4", "5", "6"]]
2 changes: 1 addition & 1 deletion library/runlevel/testsuite/tests/ServiceInfo.out
@@ -1,5 +1,5 @@
Read .target.tmpdir "/tmp"
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Read .init.scripts.runlevel "aaa" $["aaa":$["start":["0", "1", "3"], "stop":["4", "5", "6"]]]
Read .init.scripts.comment "aaa" $["aaa":$["defstart":["0", "1", "3"], "defstop":["4", "5", "6"]]]
Return $["defstart":["0", "1", "3"], "defstop":["4", "5", "6"], "start":["0", "1", "3"], "stop":["4", "5", "6"]]
2 changes: 1 addition & 1 deletion library/runlevel/testsuite/tests/ServiceStatus.out
@@ -1,4 +1,4 @@
Read .target.tmpdir "/tmp"
Read .target.stat "/lib/systemd/system/aaa.service" $["isreg":true]
Read .target.stat "/usr/lib/systemd/system/aaa.service" $["isreg":true]
Execute .target.bash "/bin/systemctl status aaa.service" $["TERM":"raw"] 3
Return 3
1 change: 1 addition & 0 deletions package/yast2.changes
Expand Up @@ -3,6 +3,7 @@ Mon Jan 14 10:17:53 UTC 2013 - locilka@suse.com

- Runlevel definitions (targets) are now in /usr/lib/systemd/system
(bnc#795929)
- Checking for systemd scripts in more directories (bnc#795929)
- 2.23.18

-------------------------------------------------------------------
Expand Down