Move git functions to separate script

This commit is contained in:
Bob Mottram 2016-06-30 14:59:43 +01:00
parent 634773fcf6
commit 6f5f81d45c
No known key found for this signature in database
GPG Key ID: BA68F26108DC9F87
4 changed files with 240 additions and 384 deletions

View File

@ -37,6 +37,11 @@ export TEXTDOMAINDIR="/usr/share/locale"
DEFAULT_LANGUAGE=$(echo $LANG)
source /usr/local/bin/${PROJECT_NAME}-utils-git
if [ -f /usr/bin/${PROJECT_NAME}-utils-git ]; then
source /usr/bin/${PROJECT_NAME}-utils-git
fi
# username created by default within a debian image
GENERIC_IMAGE_USERNAME='fbone'
@ -618,61 +623,6 @@ function show_help {
exit 0
}
function git_clone {
repo_url="$1"
destination_dir="$2"
if [[ "$repo_url" == "ssh:"* ]]; then
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
echo "sshpass -p \"$FRIENDS_MIRRORS_PASSWORD\" git clone $repo_url $destination_dir"
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
return
fi
fi
fi
fi
fi
echo "git clone $repo_url $destination_dir"
git clone "$repo_url" "$destination_dir"
}
function git_pull {
if [ ! $1 ]; then
echo $'git_pull no repo specified'
fi
git stash
git remote set-url origin $1
git checkout master
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git pull
if [ $2 ]; then
git checkout $2 -b $2
fi
return
fi
fi
fi
fi
git pull
if [ $2 ]; then
# delete any existing branch
git branch -D $2
# check out the new branch
git checkout $2 -b $2
if [ ! "$?" = "0" ]; then
echo $"Unable to checkout $1 $2"
exit 72357
fi
fi
}
function remove_database {
app_name="$1"
if [ ! -d $INSTALL_DIR ]; then

View File

@ -36,6 +36,11 @@ export TEXTDOMAINDIR="/usr/share/locale"
CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
source /usr/local/bin/${PROJECT_NAME}-utils-git
if [ -f /usr/bin/${PROJECT_NAME}-utils-git ]; then
source /usr/bin/${PROJECT_NAME}-utils-git
fi
HOSTNAME=
LETSENCRYPT_HOSTNAME=
COUNTRY_CODE="US"
@ -94,52 +99,6 @@ function read_repo_servers {
done
}
function git_clone {
repo_url="$1"
destination_dir="$2"
if [[ "$repo_url" == "ssh:"* ]]; then
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
return
fi
fi
fi
fi
fi
git clone "$repo_url" "$destination_dir"
}
function git_pull {
if [ ! $1 ]; then
echo $'git_pull no repo specified'
fi
git stash
git remote set-url origin $1
git checkout master
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git pull
if [ $2 ]; then
git checkout $2 -b $2
fi
return
fi
fi
fi
fi
git pull
if [ $2 ]; then
git checkout $2 -b $2
fi
}
function show_help {
echo ''
echo $"${PROJECT_NAME}-addcert -h [hostname] -c [country code] -a [area] -l [location]"

View File

@ -77,6 +77,11 @@ INSTALL_DIR=$HOME/build
MESH_INSTALL_DIR=/var/lib
source /usr/local/bin/${PROJECT_NAME}-utils-git
if [ -f /usr/bin/${PROJECT_NAME}-utils-git ]; then
source /usr/bin/${PROJECT_NAME}-utils-git
fi
function show_help {
echo ''
echo $"${PROJECT_NAME}-mesh-install -f [function] -r [rootdir]"
@ -91,23 +96,6 @@ function show_help {
exit 0
}
function git_clone {
repo_url="$1"
destination_dir="$2"
if [[ "$repo_url" == "ssh:"* ]]; then
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
return
fi
fi
fi
fi
fi
git clone "$repo_url" "$destination_dir"
}
function mesh_babel {
$CHROOT_PREFIX apt-get -y install babeld

View File

@ -42,6 +42,11 @@ FRIENDS_MIRRORS_SSH_PORT=2222
FRIENDS_MIRRORS_PASSWORD=
MY_MIRRORS_PASSWORD=
source /usr/local/bin/${PROJECT_NAME}-utils-git
if [ -f /usr/bin/${PROJECT_NAME}-utils-git ]; then
source /usr/bin/${PROJECT_NAME}-utils-git
fi
function read_repo_servers {
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE; then
@ -81,52 +86,6 @@ function read_repo_servers {
done
}
function git_clone {
repo_url="$1"
destination_dir="$2"
if [[ "$repo_url" == "ssh:"* ]]; then
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
return
fi
fi
fi
fi
fi
git clone "$repo_url" "$destination_dir"
}
function git_pull {
if [ ! $1 ]; then
echo $'git_pull no repo specified'
fi
git stash
git remote set-url origin $1
git checkout master
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git pull
if [ $2 ]; then
git checkout $2 -b $2
fi
return
fi
fi
fi
fi
git pull
if [ $2 ]; then
git checkout $2 -b $2
fi
}
if [ -f $CONFIGURATION_FILE ]; then
# read the location of the main project repo
if grep -q "PROJECT_REPO" $CONFIGURATION_FILE; then