Update ... update.sh

This commit is contained in:
Dalf 2019-07-11 17:13:31 +02:00
parent 518650fc80
commit d1d553bb65
1 changed files with 14 additions and 19 deletions

View File

@ -2,6 +2,8 @@
. ./util.sh . ./util.sh
SERVICE_NAME="searx-docker.service"
if [ ! -x "${which systemctl}" ]; then if [ ! -x "${which systemctl}" ]; then
echo "systemctl not found" 1>&2 echo "systemctl not found" 1>&2
exit 1 exit 1
@ -15,26 +17,19 @@ fi
# stop the systemd service # stop the systemd service
systemctl stop searx-docker.service systemctl stop searx-docker.service
# save local modification # update, change to 'git pull --rebase --autostash origin master' at your own risk
git stash push git pull --ff-only --autostash origin master
# update only if fast forward can be used, saver than "git pull --rebase"
git pull --ff-only || {
git stash pop
echo "The local and remote branches have diverged. Please update manually."
echo "Use\n systemctl start searx-docker.service\nto restart searx"
exit 1
}
# re-apply local modification
git stash pop
if [ $(git ls-files -u | wc -l) -gt 0 ]; then
echo "There are git conflicts"
else
# update docker images # update docker images
docker-compose pull docker-compose pull
# update searx configuration # update searx configuration
source ./.env source ./.env
docker-compose run searx ${SEARX_COMMAND} -d docker-compose run searx ${SEARX_COMMAND} -d
fi
# let the user see # let the user see
echo "Use\nsystemctl start searx-docker.service\nto restart searx" echo "Use\nsystemctl start searx-docker.service\nto restart searx"