#!/bin/bash

. /var/lib/autoyast-cc/libcc

SUDOERS="/etc/sudoers"
[ ! -f $SUDOERS ] && {
	cc_echo "sudo configuration file $SUDOERS does not exist - skipping configuration"
	cc_exit 0
}

trap "cc_exec_log rm -f $SUDOERS.$$" 0 1 2 3 15
perl -ne 'print unless /CC Configuration START/../CC configuration END/' < $SUDOERS >$SUDOERS.$$
cc_exec_log sed -i 's/^\(ALL.*\)/#\1/' $SUDOERS.$$ || {
	cc_echo "sudo configuration: sed command failed"
	cc_exit 1
}
echo "## CC Configuration START" >> $SUDOERS.$$
echo -e "%trusted\tALL=(ALL) ALL" >> $SUDOERS.$$
echo "## CC Configuration END" >> $SUDOERS.$$

cc_replace $SUDOERS.$$ $SUDOERS
cc_exit 0
