implement functions allowing to easily mirror repository; actually only git supported
This commit is contained in:
parent
916260efa9
commit
9c4cce0f4e
|
@ -3,6 +3,40 @@
|
||||||
# Distributed under the terms of the GNU General Public License v3
|
# Distributed under the terms of the GNU General Public License v3
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Creates a local mirror of specified GIT repository
|
||||||
|
# Parameters: %dest_directory% %address% [%username%]
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
function mirrorGit() {
|
||||||
|
local DIRECTORY="${1}"
|
||||||
|
local ADDRESS="${2}"
|
||||||
|
local USER="${3:-root}"
|
||||||
|
if [ -d ${DIRECTORY} ]; then
|
||||||
|
cd ${DIRECTORY}
|
||||||
|
run "su ${USER} -s \"/bin/sh\" -c \"git fetch -all\"" || return 1
|
||||||
|
else
|
||||||
|
run "su ${USER} -s \"/bin/sh\" -c \"git clone --mirror --bare \
|
||||||
|
${ADDRESS} ${DIRECTORY}\"" || return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Creates a local mirror of specified repository regardless its protocol
|
||||||
|
# Parameters: %dest_directory% %protocol% %address% [%username%]
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
function mirrorRepository() {
|
||||||
|
case "${2}" in
|
||||||
|
[Gg][Ii][Tt])
|
||||||
|
mirrorGit "${1}" "${3}" "${4}" && return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printWarn "Tried to mirror data using unsupported protocol (${2})!"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Prepares SSH Wrappers for use with unknown hosts (requires key authentication)
|
# Prepares SSH Wrappers for use with unknown hosts (requires key authentication)
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue