2015-11-28 11:33:21 +00:00
|
|
|
#!/bin/bash
|
2015-11-24 14:03:58 +00:00
|
|
|
|
|
|
|
|
2015-11-28 11:33:21 +00:00
|
|
|
sudo_file=/etc/sudoers
|
2015-11-24 14:03:58 +00:00
|
|
|
|
|
|
|
|
2015-11-28 11:33:21 +00:00
|
|
|
# Add Command Aliases
|
|
|
|
add_cmd_alias() {
|
|
|
|
{% for sudo in sudo_chosen_obj %}
|
|
|
|
if $(grep '^Cmnd_Alias {{ sudo.name }}' ${sudo_file} &> /dev/null); then
|
|
|
|
sed -i 's@^Cmnd_Alias.*{{ sudo.name }}.*@Cmnd_Alias {{ sudo.name }} = {{ sudo.commands }}@g' ${sudo_file}
|
|
|
|
else
|
|
|
|
echo "Cmnd_Alias {{ sudo.name }} = {{ sudo.commands }}" >> ${sudo_file}
|
|
|
|
fi
|
|
|
|
{% endfor %}
|
|
|
|
}
|
2015-11-24 14:03:58 +00:00
|
|
|
|
|
|
|
|
2015-11-28 11:33:21 +00:00
|
|
|
add_role_chosen() {
|
|
|
|
{% for role, alias in sudo_chosen_aliase.items %}
|
|
|
|
if $(grep '^{{ role }}' ${sudo_file} &> /dev/null); then
|
|
|
|
sed -i 's@^{{ role }}.*@{{ role }} ALL = {{ alias }}@g' ${sudo_file}
|
|
|
|
else
|
|
|
|
echo "{{ role }} ALL = {{ alias }}" >> ${sudo_file}
|
|
|
|
fi
|
|
|
|
{% endfor %}
|
|
|
|
}
|
2015-11-24 14:03:58 +00:00
|
|
|
|
|
|
|
|
2015-11-28 11:33:21 +00:00
|
|
|
add_cmd_alias
|
|
|
|
add_role_chosen
|