Author: lslezak
Date: Tue Sep 6 10:20:41 2011
New Revision: 65569
URL: http://svn.opensuse.org/viewcvs/yast?rev=65569&view=rev
Log:
applied mvidner's patch (attached in bnc#664548)
Modified:
branches/tmp/lslezak/yast2/library/runlevel/src/Makefile.am
branches/tmp/lslezak/yast2/library/runlevel/src/Service.ycp
Modified: branches/tmp/lslezak/yast2/library/runlevel/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/yast2/library/runlevel/src/Makefile.am?rev=65569&r1=65568&r2=65569&view=diff
==============================================================================
--- branches/tmp/lslezak/yast2/library/runlevel/src/Makefile.am (original)
+++ branches/tmp/lslezak/yast2/library/runlevel/src/Makefile.am Tue Sep 6 10:20:41 2011
@@ -9,4 +9,5 @@
EXTRA_DIST = $(agent_SCRIPTS) \
$(scrconf_DATA) $(module_DATA)
+YCPCFLAGS = -M ../../types/src -M ../../modules
include $(top_srcdir)/Makefile.am.common
Modified: branches/tmp/lslezak/yast2/library/runlevel/src/Service.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/yast2/library/runlevel/src/Service.ycp?rev=65569&r1=65568&r2=65569&view=diff
==============================================================================
--- branches/tmp/lslezak/yast2/library/runlevel/src/Service.ycp (original)
+++ branches/tmp/lslezak/yast2/library/runlevel/src/Service.ycp Tue Sep 6 10:20:41 2011
@@ -18,6 +18,8 @@
module "Service";
textdomain "base";
+import "FileUtils";
+
/***
* Services Manipulation
*/
@@ -44,9 +46,17 @@
*/
/**
+ * Program to invoke the service init scripts, or the systemd actions
+ */
+string invoker = "/sbin/service";
+/**
* Script location
*/
string init_d = "/etc/init.d";
+/**
+ * Unit location for systemd
+ */
+string systemd_d = "/lib/systemd/system";
/**
* After a function returns an error, this holds an error message,
@@ -74,7 +84,13 @@
y2error(1, error_msg);
return false;
}
- if(! (boolean) SCR::Read(.init.scripts.exists, name)) {
+ if (FileUtils::Exists(sformat("%1/%2", init_d,name))) {
+ return true;
+ }
+ else if (FileUtils::Exists(sformat("%1/%2.service", systemd_d,name))) {
+ return true;
+ }
+ else {
// Error message.
// %1 is a name of an init script in /etc/init.d,
// eg. nfsserver
@@ -82,7 +98,6 @@
y2milestone (1, error_msg);
return false;
}
- return true;
}
/**
@@ -111,7 +126,7 @@
*/
global define integer Status (string name) {
if(!checkExists (name)) return -1;
- return (integer) SCR::Execute (.target.bash, sformat ("%2/%1 status", name, init_d), $["TERM":"raw"]);
+ return (integer) SCR::Execute (.target.bash, sformat ("%1 %2 status", invoker, name), $["TERM":"raw"]);
}
/**
@@ -133,8 +148,8 @@
*/
define boolean serviceDisable (string name, boolean force) {
map ret = (map)SCR::Execute (.target.bash_output,
- sformat ("/sbin/insserv -r%3 %2/%1",
- name, init_d, force? "f": ""));
+ sformat ("/sbin/chkconfig -d%2 %1",
+ name, force? "f": ""));
if (0 != ret["exit"]:-1)
{
// Error message.
@@ -166,9 +181,10 @@
return false;
}
map service = Info (name);
+ boolean is_enabled = size (service["start"]:[]) != 0;
if ("disable" == action)
{
- if (size (service["start"]:[]) != 0)
+ if (is_enabled)
{
return serviceDisable (name, false);
}
@@ -176,7 +192,7 @@
}
if (("default" == action) || ("enable" == action))
{
- if ("enable" == action && size (service["start"]:[]) != 0)
+ if ("enable" == action && is_enabled)
{
// nothing to do
return true;
@@ -184,8 +200,8 @@
else
{
map ret = (map)SCR::Execute (.target.bash_output,
- sformat ("/sbin/insserv -d %2/%1",
- name, init_d));
+ sformat ("/sbin/chkconfig -a %1",
+ name));
if (0 != ret["exit"]:-1)
{
// Error message.
@@ -262,19 +278,16 @@
}
/**
- * Check if service is enabled
+ * Check if service is enabled (in RL 3 or multi-user.target)
*
- * Returns true if any link in /etc/init.d/rc?.d/ exists for this
- * script. If service does not exist, logs an error.
+ * Forwards to chkconfig -c which decides between init and systemd
*
* @param name service name
- * @return true if service is set to run in any runlevel
+ * @return true if service is set to run
*/
global define boolean Enabled (string name) {
if(!checkExists (name)) return false;
- map