2019-11-26 21:47:40 +01:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# checks if the branch and repository exists
|
|
|
|
check_branch() {
|
2020-06-15 00:30:25 +02:00
|
|
|
repo=${1:-}
|
|
|
|
branch=${2:-}
|
|
|
|
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
|
|
|
|
[ "$?" -eq "0" ]
|
2019-11-26 21:47:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# clones the whole develop branch (Friendica and Addons)
|
|
|
|
clone_develop() {
|
2020-06-15 00:30:25 +02:00
|
|
|
friendica_git="${FRIENDICA_VERSION}"
|
|
|
|
addons_git="${FRIENDICA_ADDONS}"
|
|
|
|
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
|
|
|
|
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/friendica-addons}"
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
if echo "{$friendica_git,,}" | grep -Eq '^.*\-dev'; then
|
|
|
|
friendica_git="develop"
|
|
|
|
fi
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
if echo "{$addons_git,,}" | grep -Eq '^.*\-dev'; then
|
|
|
|
addons_git="develop"
|
|
|
|
fi
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
# Check if the branches exist before wiping the
|
|
|
|
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
|
|
|
|
echo "Cloning '${friendica_git}' from GitHub repository '${friendica_repo}' ..."
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
# Removing the whole directory first
|
|
|
|
rm -fr /usr/src/friendica
|
|
|
|
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
mkdir /usr/src/friendica/addon
|
|
|
|
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
echo "Download finished"
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
if [ ! -f /usr/src/friendica/VERSION ]; then
|
|
|
|
echo "Couldn't clone repository"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
|
|
|
|
return 0
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
else
|
|
|
|
if check_branch "$friendica_repo" "$friendica_git"; then
|
|
|
|
echo "$friendica_repo/$friendica_git is not valid."
|
|
|
|
else
|
|
|
|
echo "$friendica_addons_repo/$addons_git is not valid."
|
|
|
|
fi
|
|
|
|
echo "Using old version."
|
|
|
|
return 1
|
2019-11-26 21:47:40 +01:00
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
fi
|
2019-11-26 21:47:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# just check if we execute apache or php-fpm
|
|
|
|
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
|
2020-06-15 00:30:25 +02:00
|
|
|
# cloning from git is just possible for develop or Release Candidate
|
|
|
|
if echo "${FRIENDICA_VERSION}" | grep -Eq '^.*(\-dev|-rc|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
|
|
|
|
# just clone & check if it's a new install or upgrade
|
|
|
|
clone_develop
|
|
|
|
fi
|
2019-11-26 21:47:40 +01:00
|
|
|
fi
|
|
|
|
|
2020-01-03 19:20:20 +01:00
|
|
|
exec /entrypoint.sh "$@"
|