cdist/cdist/conf/type/__zypper_repo/gencode-remote

95 lines
2.4 KiB
Plaintext
Raw Normal View History

2013-12-04 08:37:01 +00:00
#!/bin/sh
#
# 2013 Daniel Heule (hda at sfs.biz)
#
# 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/>.
#
#
# Manage repo services with Zypper (mostly suse)
#
# Debug
#exec >&2
#set -x
zypper_def_opts=" -q "
if [ -f "$__object/parameter/repo_desc" ]; then
desc="$(cat "$__object/parameter/repo_desc")"
else
desc="$__object_id"
fi
if [ -f "$__object/parameter/repo_uri" ]; then
uri="$(cat "$__object/parameter/repo_uri")"
else
uri="$__object_id"
fi
if [ -f "$__object/parameter/repo_id" ]; then
id="$(cat "$__object/parameter/repo_id")"
else
id="$__object_id"
fi
if [ -f "$__object/parameter/state" ]; then
state="$(cat "$__object/parameter/state")"
else
state="present"
fi
all_repo_ids="$(cat "$__object/explorer/all_repo_ids")"
enabled_repo_ids="$(cat "$__object/explorer/enabled_repo_ids")"
repo_id="$(cat "$__object/explorer/repo_id")"
act_id=""
2013-12-04 13:58:15 +00:00
if grep -q "$id" "$__object/explorer/all_repo_ids"; then
2013-12-04 08:37:01 +00:00
act_id="$id"
2013-12-04 13:58:15 +00:00
elif grep -q "$repo_id" "$__object/explorer/all_repo_ids"; then
2013-12-04 08:37:01 +00:00
act_id="$repo_id"
fi
case "$state" in
present)
if [ -z "$desc" ] || [ -z "$uri" ]; then
echo "parameter repo_desc and repo_uri for $state needed" >&2
exit 4
fi
2013-12-04 08:37:01 +00:00
if [ -z "$repo_id" ]; then
echo zypper $zypper_def_opts addrepo "'$uri'" "'$desc'"
fi
2013-12-04 08:37:01 +00:00
;;
absent)
if [ ! -z "$act_id" ]; then
2013-12-04 13:58:15 +00:00
echo zypper $zypper_def_opts removerepo "'$act_id'"
fi
2013-12-04 08:37:01 +00:00
;;
enabled)
if [ ! -z "$act_id" ]; then
2013-12-04 13:58:15 +00:00
echo zypper $zypper_def_opts modifyrepo -e "'$act_id'"
fi
2013-12-04 08:37:01 +00:00
;;
disabled)
if [ ! -z "$act_id" ]; then
2013-12-04 13:58:15 +00:00
echo zypper $zypper_def_opts modifyrepo -d "'$act_id'"
fi
2013-12-04 08:37:01 +00:00
;;
*)
echo "Unknown state: $state" >&2
exit 1
;;
esac