forked from ungleich-public/cdist
Merge branch 'openwrt-support' of https://github.com/muggenhor/cdist
This commit is contained in:
commit
d11fb4dd6d
12 changed files with 200 additions and 16 deletions
|
@ -20,7 +20,14 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
lsb_release=$(which lsb_release 2>/dev/null)
|
case "$($__explorer/os)" in
|
||||||
if [ -x "$lsb_release" ]; then
|
openwrt)
|
||||||
|
(. /etc/openwrt_release && echo "$DISTRIB_CODENAME")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
lsb_release=$(which lsb_release 2>/dev/null)
|
||||||
|
if [ -x "$lsb_release" ]; then
|
||||||
$lsb_release --short --codename
|
$lsb_release --short --codename
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -20,7 +20,14 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
lsb_release=$(which lsb_release 2>/dev/null)
|
case "$($__explorer/os)" in
|
||||||
if [ -x "$lsb_release" ]; then
|
openwrt)
|
||||||
|
(. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
lsb_release=$(which lsb_release 2>/dev/null)
|
||||||
|
if [ -x "$lsb_release" ]; then
|
||||||
$lsb_release --short --description
|
$lsb_release --short --description
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -20,7 +20,14 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
lsb_release=$(which lsb_release 2>/dev/null)
|
case "$($__explorer/os)" in
|
||||||
if [ -x "$lsb_release" ]; then
|
openwrt)
|
||||||
|
(. /etc/openwrt_release && echo "$DISTRIB_ID")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
lsb_release=$(which lsb_release 2>/dev/null)
|
||||||
|
if [ -x "$lsb_release" ]; then
|
||||||
$lsb_release --short --id
|
$lsb_release --short --id
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -20,7 +20,14 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
lsb_release=$(which lsb_release 2>/dev/null)
|
case "$($__explorer/os)" in
|
||||||
if [ -x "$lsb_release" ]; then
|
openwrt)
|
||||||
|
(. /etc/openwrt_release && echo "$DISTRIB_RELEASE")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
lsb_release=$(which lsb_release 2>/dev/null)
|
||||||
|
if [ -x "$lsb_release" ]; then
|
||||||
$lsb_release --short --release
|
$lsb_release --short --release
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -56,6 +56,11 @@ if [ -f /etc/gentoo-release ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f /etc/openwrt_version ]; then
|
||||||
|
echo openwrt
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f /etc/owl-release ]; then
|
if [ -f /etc/owl-release ]; then
|
||||||
echo owl
|
echo owl
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -45,6 +45,9 @@ case "$($__explorer/os)" in
|
||||||
*bsd|solaris)
|
*bsd|solaris)
|
||||||
uname -r
|
uname -r
|
||||||
;;
|
;;
|
||||||
|
openwrt)
|
||||||
|
cat /etc/openwrt_version
|
||||||
|
;;
|
||||||
owl)
|
owl)
|
||||||
cat /etc/owl-release
|
cat /etc/owl-release
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -34,6 +34,7 @@ else
|
||||||
debian|ubuntu) type="apt" ;;
|
debian|ubuntu) type="apt" ;;
|
||||||
gentoo) type="emerge" ;;
|
gentoo) type="emerge" ;;
|
||||||
amazon|centos|fedora|redhat) type="yum" ;;
|
amazon|centos|fedora|redhat) type="yum" ;;
|
||||||
|
openwrt) type="opkg" ;;
|
||||||
*)
|
*)
|
||||||
echo "Don't know how to manage packages on: $os" >&2
|
echo "Don't know how to manage packages on: $os" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
39
conf/type/__package_opkg/explorer/pkg_status
Executable file
39
conf/type/__package_opkg/explorer/pkg_status
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2012 Giel van Schijndel (giel plus cdist at mortis dot eu)
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Retrieve the status of a package - parsed opkg output
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
name="$(cat "$__object/parameter/name")"
|
||||||
|
else
|
||||||
|
name="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Except dpkg failing, if package is not known / installed
|
||||||
|
if opkg status "$name" 2>/dev/null | grep -q "^Status: install user installed$"; then
|
||||||
|
echo "present"
|
||||||
|
exit 0
|
||||||
|
elif [ "$(opkg info "$name" 2> /dev/null | wc -l)" -eq 0 ]; then
|
||||||
|
echo "absent notpresent"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "absent"
|
57
conf/type/__package_opkg/gencode-remote
Executable file
57
conf/type/__package_opkg/gencode-remote
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2012 Giel van Schijndel (giel plus cdist at mortis dot eu)
|
||||||
|
#
|
||||||
|
# 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 packages on OpenWRT and co.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
name="$(cat "$__object/parameter/name")"
|
||||||
|
else
|
||||||
|
name="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
state_is="$(cat "$__object/explorer/pkg_status")"
|
||||||
|
case "$state_is" in
|
||||||
|
absent*)
|
||||||
|
present="$(echo "$state_is" | cut -d ' ' -f 2)"
|
||||||
|
state_is="absent"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ "$state_is" != "$state_should" ]; then
|
||||||
|
case "$state_should" in
|
||||||
|
present)
|
||||||
|
if [ "$present" = "notpresent" ]; then
|
||||||
|
echo opkg --verbosity=0 update
|
||||||
|
fi
|
||||||
|
echo opkg --verbosity=0 install \"$name\"
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
echo opkg --verbosity=0 remove \"$name\"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown state: $state" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
49
conf/type/__package_opkg/man.text
Normal file
49
conf/type/__package_opkg/man.text
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
cdist-type__package_opkg(7)
|
||||||
|
==========================
|
||||||
|
Giel van Schijndel <giel+cdist--@--mortis.eu>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__package_opkg - Manage packages with opkg
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
opkg is usually used on OpenWRT to manage packages.
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
state::
|
||||||
|
The state the package should be in, either "present" or "absent"
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
name::
|
||||||
|
If supplied, use the name and not the object id as the package name.
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Ensure lsof is installed
|
||||||
|
__package_opkg lsof --state present
|
||||||
|
|
||||||
|
# Remove obsolete package
|
||||||
|
__package_opkg dnsmasq --state absent
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
- cdist-type__package(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2012 Giel van Schijndel. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
1
conf/type/__package_opkg/parameter/optional
Normal file
1
conf/type/__package_opkg/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
||||||
|
name
|
1
conf/type/__package_opkg/parameter/required
Normal file
1
conf/type/__package_opkg/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
state
|
Loading…
Reference in a new issue