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
|
||||
-----------
|
||||
This cdist type allows you to clone and keep git repositories
|
||||
up-to-date.
|
||||
This cdist type allows you to clone git repositories
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
|
@ -22,38 +21,21 @@ source::
|
|||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
state::
|
||||
Either "present" or "absent", defaults to "present"
|
||||
|
||||
branch::
|
||||
The remote branch to check out
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
up-to-date::
|
||||
Whether to git merge on each run
|
||||
Create this branch by checking out the remote branch of this name
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# Create hard git of /etc/shadow
|
||||
__git /home/services/dokuwiki --source /etc/shadow --type hard
|
||||
__git /home/services/dokuwiki --source git://github.com/splitbrain/dokuwiki.git
|
||||
|
||||
# Relative symbolic git
|
||||
__git /etc/apache2/sites-enabled/www.test.ch \
|
||||
--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
|
||||
# Checkout cdist, stay on branch 2.1
|
||||
__git /home/nico/cdist --source git://github.com/telmich/cdist.git --branch 2.1
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -64,5 +46,5 @@ SEE ALSO
|
|||
|
||||
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).
|
||||
|
|
|
@ -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