2017-06-28 11:19:32 +00:00
|
|
|
#!/bin/sh -e
|
2013-06-19 16:49:43 +00:00
|
|
|
#
|
|
|
|
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
|
2020-09-21 08:18:39 +00:00
|
|
|
# 2020 Ander Punnar (ander@kvlt.ee)
|
2013-06-19 16:49:43 +00:00
|
|
|
#
|
|
|
|
# This file is part of cdist.
|
|
|
|
#
|
|
|
|
# cdist is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# cdist is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2020-09-21 08:18:39 +00:00
|
|
|
path_is="$( cat "$__object/explorer/path_is" )"
|
|
|
|
|
|
|
|
path_should="$( cat "$__object/parameter/path" )"
|
|
|
|
|
|
|
|
if [ "$path_is" = "$path_should" ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$( cat "$__object/explorer/path_should_state" )" = 'absent' ] && [ -z "$__cdist_dry_run" ]
|
|
|
|
then
|
|
|
|
echo "$path_should does not exist in target" >&2
|
|
|
|
exit 1
|
2020-02-19 10:58:22 +00:00
|
|
|
fi
|
|
|
|
|
2013-06-19 16:49:43 +00:00
|
|
|
name="$__object_id"
|
2020-09-21 08:18:39 +00:00
|
|
|
|
|
|
|
alternatives="$( cat "$__object/explorer/alternatives" )"
|
|
|
|
|
|
|
|
if ! echo "$alternatives" | grep -Fxq "$path_should"
|
|
|
|
then
|
|
|
|
if [ ! -f "$__object/parameter/install" ]
|
|
|
|
then
|
|
|
|
echo "$path_should is not in $name alternatives." >&2
|
|
|
|
echo 'Please install missing packages or use --install to add path to alternatives.' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
link="$( cat "$__object/explorer/link" )"
|
|
|
|
|
|
|
|
echo "update-alternatives --install '$link' '$name' '$path_should' 1000"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "update-alternatives --set '$name' '$path_should'"
|