Skip to content

Commit

Permalink
Merge pull request #177 from jsuchome/Code-11-SP3
Browse files Browse the repository at this point in the history
different check for Chef (bnc#803358)
  • Loading branch information
jsuchome committed Feb 5, 2014
2 parents 5317e38 + 6408c66 commit 40e10b1
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 40 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.17.133
2.17.134
38 changes: 0 additions & 38 deletions library/commandline/src/CommandLine.ycp
Expand Up @@ -1246,38 +1246,6 @@ boolean RunMapFunction( boolean(map<string,string>) funct,
return ret;
}

define boolean ChefIsRunning() {
return SCR::Execute(.target.bash, "pgrep -fl chef-client") == 0;
}

/**
* Chef is a different way to configure the system.
* It will periodically overwrite files under its control.
* If it is running, now is a good time to tell the user
* and ask if she wants to proceed with YaST anyway.
* We do not try to find out which files these are and ask
* before any interactive YaST module.
* bnc#803358
* @return true if we can go on: chef not running, or if the user
* wants to continue anyway
*/
define boolean IgnoreOtherConfigTools() {
if (ChefIsRunning())
{
// Translators: a warning message in a continue-cancel question
// Opscode Chef is a different way to configure the system.
string message = _("Chef Client is running. The changes that you make
may be overridden by Chef later.
Continue configuration with YaST?");
return Popup::ContinueCancel(message);
}

// if we want to check other tools (Puppet?) add them here

// no conflicting tool found
return true;
}

/**
* @short Parse the Command Line
* @descr Function to parse the command line, start a GUI or handle interactive and
Expand Down Expand Up @@ -1317,12 +1285,6 @@ global any Run( map commandline ) {
return false;
}

// A hacky bail-out hook before interactive modules
if (! IgnoreOtherConfigTools())
{
return false;
}

if ( is(commandline[ "guihandler" ]:nil, symbol() ) )
{
symbol() exec = (symbol())commandline[ "guihandler" ]: nil;
Expand Down
5 changes: 4 additions & 1 deletion library/commandline/src/Makefile.am
Expand Up @@ -5,7 +5,10 @@
module_DATA = \
CommandLine.ycp

EXTRA_DIST = $(module_DATA)
client_DATA = \
other_tools_warning.ycp

EXTRA_DIST = $(module_DATA) $(client_DATA)

YCPCFLAGS = -M ../../types/src -M ../../modules -M ../../wizard/src -M ../../xml/src

Expand Down
29 changes: 29 additions & 0 deletions library/commandline/src/other_tools_warning.ycp
@@ -0,0 +1,29 @@
/**
* File: clients/other_tools_warning.ycp
* Package: yast2
*
* There may be different ways to configure the system than YaST, e.g. Chef.
* It will periodically overwrite files under its control.
* If it is running, now is a good time to tell the user
* and ask if she wants to proceed with YaST anyway.
* We do not try to find out which files these are and ask
* before any interactive YaST module.
* See bnc#803358
*/
{
import "Popup";
textdomain "base";

list args = WFM::Args();
if (size(args) > 0 && contains (args, "chef")) {

// Translators: a warning message in a continue-cancel question
// Opscode Chef is a different way to configure the system.
string message = _("Chef Client is running. The changes that you make
may be overridden by Chef later.
Continue configuration with YaST?");
return Popup::ContinueCancel(message);
}
return true;
}

7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Feb 5 12:50:37 CET 2014 - jsuchome@suse.cz

- Check for Chef outside in the yast2 shell script to catch modules
not using CommandLine (bnc#803358)
- 2.17.134

-------------------------------------------------------------------
Tue Jan 21 09:17:41 CET 2014 - gs@suse.de

Expand Down
37 changes: 37 additions & 0 deletions scripts/yast2
Expand Up @@ -209,6 +209,41 @@ snapshot_post()
fi
}

chef_is_running ()
{
pgrep -fl chef-client >/dev/null
}

# ask user if he want to continue despite there is chef-client running
# return 0 if user decided to continue
chef_warning_continue ()
{
$ybindir/y2base other_tools_warning -S "(chef)" "$SELECTED_GUI" $Y2_GEOMETRY $Y2UI_ARGS
}

# Check if chef-client is running and warn user about it (bnc#803358)
# Returns 0 if user confirmed the conflict and wants to exit before starting YaST.
# (check for other tools (like puppet) may be added here)
other_tools_are_conflicting ()
{
# - no need to check for installation/firstboot, they are started directly with y2base

if ! chef_is_running; then
return 1
fi

# existing arguments for yast module = CLI mode
# continue, but print a warning
if [ -n "$1" ]; then
echo "Warning: Chef Client is running. Your changes may be overridden by Chef later." >&2
return 1
fi

if chef_warning_continue; then
return 1
fi
return 0
}

TEMP=`/usr/bin/getopt -o hlg:s:Si --long help,list,kcontrol,geometry:,style:,strings,install,update,remove,fullscreen,noborder,qt,gtk,ncurses \
-n 'yast2' -- "$@"`
Expand Down Expand Up @@ -374,6 +409,8 @@ fi
if [ $module == "menu" -a -f "$y2ccbin" ] ; then
$y2ccbin $Y2UI_ARGS "$@"
exit_code=$?
elif test $module != "menu" && other_tools_are_conflicting "$@" ; then
exit_code=1
else
# In case YaST has to be restarted, create this file
# and exit. Script that creates the file should also
Expand Down

0 comments on commit 40e10b1

Please sign in to comment.