forked from ungleich-public/cdist
create working version of __git
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
5a3dc38e60
commit
8b91e3116a
5 changed files with 116 additions and 25 deletions
30
cdist/conf/type/__git/explorer/state
Executable file
30
cdist/conf/type/__git/explorer/state
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Check whether repository exists
|
||||||
|
#
|
||||||
|
|
||||||
|
destination="/$__object_id/.git"
|
||||||
|
|
||||||
|
if [ -d "$destination" ]; then
|
||||||
|
echo present
|
||||||
|
else
|
||||||
|
echo absent
|
||||||
|
fi
|
|
@ -1 +1,47 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
state_should=present
|
||||||
|
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
branch=master
|
||||||
|
[ -f "$__object/parameter/branch" ] && branch="$(cat "$__object/parameter/branch")"
|
||||||
|
|
||||||
|
source="$(cat "$__object/parameter/source")"
|
||||||
|
|
||||||
|
destination="/$__object_id"
|
||||||
|
|
||||||
|
[ "$state_should" = "$state_is" ] && exit 0
|
||||||
|
|
||||||
|
case $state_should in
|
||||||
|
present)
|
||||||
|
echo git clone --quiet --branch "$branch" "$source" "$destination"
|
||||||
|
;;
|
||||||
|
# Handled in manifest
|
||||||
|
absent)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Unknown state: $state_should" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -10,8 +10,7 @@ cdist-type__git - Get and or keep git repositories up-to-date
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
This cdist type allows you to clone and keep git repositories
|
This cdist type allows you to clone git repositories
|
||||||
up-to-date.
|
|
||||||
|
|
||||||
|
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
|
@ -22,38 +21,21 @@ source::
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
name::
|
|
||||||
If supplied, use the name and not the object id as the package name.
|
|
||||||
|
|
||||||
state::
|
state::
|
||||||
Either "present" or "absent", defaults to "present"
|
Either "present" or "absent", defaults to "present"
|
||||||
|
|
||||||
branch::
|
branch::
|
||||||
The remote branch to check out
|
Create this branch by checking out the remote branch of this name
|
||||||
|
|
||||||
BOOLEAN PARAMETERS
|
|
||||||
------------------
|
|
||||||
up-to-date::
|
|
||||||
Whether to git merge on each run
|
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Create hard git of /etc/shadow
|
__git /home/services/dokuwiki --source git://github.com/splitbrain/dokuwiki.git
|
||||||
__git /home/services/dokuwiki --source /etc/shadow --type hard
|
|
||||||
|
|
||||||
# Relative symbolic git
|
# Checkout cdist, stay on branch 2.1
|
||||||
__git /etc/apache2/sites-enabled/www.test.ch \
|
__git /home/nico/cdist --source git://github.com/telmich/cdist.git --branch 2.1
|
||||||
--source ../sites-available/www.test.ch \
|
|
||||||
--type symbolic
|
|
||||||
|
|
||||||
# Absolute symbolic git
|
|
||||||
__git /opt/plone --source /home/services/plone --type symbolic
|
|
||||||
|
|
||||||
# Remove git
|
|
||||||
__git /opt/plone --state absent
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,5 +46,5 @@ SEE ALSO
|
||||||
|
|
||||||
COPYING
|
COPYING
|
||||||
-------
|
-------
|
||||||
Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is
|
Copyright \(C) 2012 Nico Schottelius. Free use of this software is
|
||||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||||
|
|
|
@ -1 +1,32 @@
|
||||||
__package git
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Ensure git is present
|
||||||
|
#
|
||||||
|
|
||||||
|
__package git --state present
|
||||||
|
|
||||||
|
state_should=present
|
||||||
|
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
# Let __directory handle removal of git repos
|
||||||
|
if [ "$state_should" = absent ]; then
|
||||||
|
__directory "$__object_id" --state absent
|
||||||
|
fi
|
||||||
|
|
2
cdist/conf/type/__git/parameter/optional
Normal file
2
cdist/conf/type/__git/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
state
|
||||||
|
branch
|
Loading…
Reference in a new issue