3 ##############################
4 ## somenet.org ansible tool ##
5 ##############################
6 # Part of: https://git.somenet.org/root/pub/somesible.git
7 # 2017-2024 by someone <someone@somenet.org>
9 # update git repository
11 # This is always run inside the somesible repo only.
14 # .git may be a file, if checked out as submodule.
15 if [ ! -e ".git" ]; then
16 echo "*** ERROR (update_somesible.sh): this is not a git repo. abort."
20 SOMESIBLE_GIT_REV_START="$(git --git-dir ./.git --no-pager log --pretty=format:'%h' -n 1 HEAD --)"
23 echo "*** DEBUG (update.sh) start: [${SOMESIBLE_GIT_REV_START}] $(date -Isec)"
26 # (try to) read config in parent dir.
27 if [ -e "../somesible.conf" ]; then
30 if [ -z "$SOMESIBLE_VERSION" ]; then
31 SOMESIBLE_VERSION="tags/activeVersion"
33 echo "***********************************************************"
34 echo "*** WARNING (update_somesible.sh): using non-default version: ${SOMESIBLE_VERSION} ***"
35 echo "***********************************************************"
40 ################################
41 # update self (somesible repo) #
42 ################################
43 chmod -R u=rwX,go-rwx "./"
46 git config protocol.ext.allow always
47 git config remote.origin.url "ext::ssh -F ./.ssh/config git.somenet.org %S /root/pub/somesible"
48 git config remote.update.url 'git@git.somenet.org:/root/pub/somesible'
49 git config fetch.prune true
51 git ls-remote --exit-code -t origin > /dev/null 2>&1
53 if [ $USERCONFIG_OFFLINE -ne 0 ]; then
54 echo "****************************************************************************"
55 echo "*** INFO (update.sh): git repo unreachable. Offline? - Retry in 120 sec. ***"
56 echo "****************************************************************************"
59 git ls-remote --exit-code -t origin > /dev/null 2>&1
63 if [ $USERCONFIG_OFFLINE -ne 0 ]; then
64 echo "***************************************************************************"
65 echo "*** WARNING (update.sh): git repo unreachable. Offline? - Retry failed. ***"
66 echo "***************************************************************************"
69 git tag | xargs -n1 git tag -d
70 git fetch origin --tags
72 unset USERCONFIG_OFFLINE
74 git checkout -f "master"
75 git reset --hard "$SOMESIBLE_VERSION" --
77 echo "******************************************************************"
78 echo "*** WARNING (update_somesible.sh): invalid SOMESIBLE_VERSION? ***"
79 echo "******************************************************************"
81 git reset --hard "tags/activeVersion" --
84 # one --force is not enought!
88 # Do this twice to be sure.
89 chmod -R u=rwX,go-rwx "./"
94 echo "*** DONE (update_somesible.sh) [${SOMESIBLE_GIT_REV_START}] -> [$(git --git-dir ./.git --no-pager log --pretty=format:'%h' -n 1 HEAD --)] $(date -Isec)"
100 unset SOMESIBLE_VERSION
101 unset SOMESIBLE_GIT_REV_START