ACC SHELL

Path : /usr/share/YaST2/include/network/
File Upload :
Current File : //usr/share/YaST2/include/network/runtime.ycp

/**
 * File:	include/network/runtime.ycp
 * Package:	Network configuration
 * Summary:	Runtime routines
 * Authors:	Michal Svec <msvec@suse.cz>
 *
 * $Id: runtime.ycp 59466 2009-11-10 14:50:55Z mzugec $
 */

{

import "Arch";
import "Desktop";
import "ISDN";
import "Mode";
import "NetworkInterfaces";
import "Package";
import "Service";
import "PackageSystem";

textdomain "network";

/**
 * Run SuSEconfig
 * @return true if success
 */
define boolean RunSuSEconfig() {
    y2milestone("Running SuSEconfig ...");
    SCR::Execute(.target.bash, "/sbin/SuSEconfig --module apache 2>/dev/null");
    SCR::Execute(.target.bash, "/sbin/SuSEconfig --module sendmail 2>/dev/null");
    SCR::Execute(.target.bash, "/sbin/SuSEconfig --module postfix 2>/dev/null");
    return true;
}

/**
 * Run one SuSEconfig module
 * @param modul SuSEconfig module
 * @return true if success
 */
define boolean RunSuSEconfigModule(string modul) {
    if(modul == nil || modul == "") {
	y2error("Wrong SuSEconfig module: %1", modul);
	return false;
    }
    y2milestone("Running SuSEconfig module %1", modul);
    return (SCR::Execute(.target.bash, sformat("/sbin/SuSEconfig --module %1", modul)) == 0);
}


/**
 * Link detection
 * @return true if link found
 * @see ethtool(8)
 */
boolean HasLink() {
    string ifname = "eth0";

    string command = sformat("ethtool %1 | grep -q 'Link detected: no'", ifname);
    if((integer) SCR::Execute(.target.bash, command) == 1) return false;
    return true;
}

/**
 * Are there interfaces controlled by smpppd and qinternet?
 * They are the ones with USERCONTROL=yes (#44303)
 * @return true/false
 */
boolean HaveDialupLikeInterfaces () {
    list <string> devs = NetworkInterfaces::Locate ("USERCONTROL", "yes");
    y2milestone ("user controlled interfaces: %1", devs);
    if (devs != [])
    {
	return true;
    }

    devs = ISDN::Locate ("USERCONTROL", "yes");
    y2milestone ("user controlled ISDN interfaces: %1", devs);

    return devs != [];
}

/**
 * Setup smpppd(8)
 * @return true if success
 */
define boolean SetupSMPPPD(boolean install_force) {
    boolean ret = true;
    /* Stop and disable */
    if (!HaveDialupLikeInterfaces ()) {
	ret = Service::Disable("smpppd") && ret;
	ret = Service::Stop("smpppd") && ret;
    }
    /* Start and enable */
    else {

	// (#299033) - if not forced, user can continue also without packages
        ret=PackageSystem::CheckAndInstallPackagesInteractive(["smpppd"]);

	ret = Service::Enable("smpppd") && ret;

	/* Installation? */
	if(Mode::normal ()) {
	    if(Service::Status("smpppd") == 0)
		ret = Service::Reload("smpppd") && ret;
	    else
		ret = Service::Start("smpppd") && ret;
	 }
    }

    return ret;
}


/* EOF */
}

ACC SHELL 2018