1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-05 15:57:23 +01:00

Simplify alternate repo/branch installation

This commit is contained in:
downtownallday
2022-06-26 22:10:47 -04:00
parent 5de40fc9b1
commit f05fa8ba01
7 changed files with 200 additions and 158 deletions

View File

@@ -1,20 +1,20 @@
#
# source all lib scripts
#
# from your script, supply the path to this directory as the first argument
#
# eg source "tests/lib/all.sh" "tests/lib"
# eg source "tests/lib/all.sh"
#
# failure to load any script is fatal!
. "$1/color-output.sh" || exit 1
. "$1/locations.sh" || exit 2
. "$1/misc.sh" || exit 3
. "$1/rest.sh" || exit 4
. "$1/system.sh" || exit 5
. "$1/carddav.sh" || exit 6
D=$(dirname "$BASH_SOURCE")
. "$1/populate.sh" || exit 7
. "$1/installed-state.sh" || exit 8
. "$1/totp.sh" || exit 9
. "$D/color-output.sh" || exit 1
. "$D/locations.sh" || exit 2
. "$D/misc.sh" || exit 3
. "$D/rest.sh" || exit 4
. "$D/system.sh" || exit 5
. "$D/carddav.sh" || exit 6
. "$D/populate.sh" || exit 7
. "$D/installed-state.sh" || exit 8
. "$D/totp.sh" || exit 9

View File

@@ -1,3 +1,6 @@
#
# requires:
# scripts: [ misc.sh ]
wait_for_apt() {
# check to see if other package managers have a lock on new
@@ -140,3 +143,32 @@ exec_no_output() {
[ $code -ne 0 ] && return 1
return 0
}
git_clone() {
local REPO="$1"
local TREEISH="$2"
local TARGETPATH="$3"
local OPTIONS="$4"
if [ ! -x /usr/bin/git ]; then
exec_no_output apt-get install -y git || return 1
fi
if ! array_contains "keep-existing" $OPTIONS || \
[ ! -d "$TARGETPATH" ] || \
[ -z "$(ls -A "$TARGETPATH")" ]
then
rm -rf "$TARGETPATH"
git clone "$REPO" "$TARGETPATH"
if [ $? -ne 0 ]; then
rm -rf "$TARGETPATH"
return 1
fi
fi
if [ ! -z "$TREEISH" ]; then
pushd "$TARGETPATH" >/dev/null
git checkout "$TREEISH" || return 2
popd >/dev/null
fi
}