change git checkout
This commit is contained in:
parent
4e21ee9c70
commit
c7437a4acf
4 changed files with 27 additions and 26 deletions
|
@ -72,7 +72,7 @@ if [[ $- = *i* ]] ; then
|
||||||
# which dnf >/dev/null 2>&1 [ -z "${P11M+x}" ] && P11M="$(dnf repoquery --installed -l p11-kit | grep \/p11-kit-proxy.so\$ | head -1)"
|
# which dnf >/dev/null 2>&1 [ -z "${P11M+x}" ] && P11M="$(dnf repoquery --installed -l p11-kit | grep \/p11-kit-proxy.so\$ | head -1)"
|
||||||
# which dpkg >/dev/null 2>&1 && [ -z "${P11M+x}" ] && P11M="$(dpkg -L p11-kit-modules|grep \/p11-kit-proxy.so\$ | head -1)"
|
# which dpkg >/dev/null 2>&1 && [ -z "${P11M+x}" ] && P11M="$(dpkg -L p11-kit-modules|grep \/p11-kit-proxy.so\$ | head -1)"
|
||||||
|
|
||||||
[ -z "${PKCS11_MODULE:+x}" ] && [ -n "$(whereis p11-kit-proxy.so|awk '{print $2}')" ] && export PKCS11_MODULE=$(whereis p11-kit-proxy.so|awk '{print $2}' || { echo "p11-kit-proxy not installed, unset KCS11_MODULE"; unset PKCS11_MODULE; })
|
[ -z "${PKCS11_MODULE:+x}" ] && [ -n "$(whereis p11-kit-proxy.so|awk '{print $2}')" ] && export PKCS11_MODULE=$(whereis p11-kit-proxy.so|awk '{print $2}' || { echo "p11-kit-proxy not installed, unset PKCS11_MODULE"; unset PKCS11_MODULE; })
|
||||||
[ -z "${P11M:+x}" ] && [ -n "$(whereis p11-kit-proxy.so|awk '{print $2}')" ] && export P11M=$(whereis p11-kit-proxy.so|awk '{print $2}' || { echo "p11-kit-proxy not forwarded by ssh or installed, unset P11M"; unset P11M; })
|
[ -z "${P11M:+x}" ] && [ -n "$(whereis p11-kit-proxy.so|awk '{print $2}')" ] && export P11M=$(whereis p11-kit-proxy.so|awk '{print $2}' || { echo "p11-kit-proxy not forwarded by ssh or installed, unset P11M"; unset P11M; })
|
||||||
|
|
||||||
# Basics
|
# Basics
|
||||||
|
@ -95,9 +95,6 @@ EOF
|
||||||
-lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") ]; then
|
-lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") ]; then
|
||||||
logwarning "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours) reached"
|
logwarning "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours) reached"
|
||||||
loginfo "check if remote »$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1)« is reachable"
|
loginfo "check if remote »$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1)« is reachable"
|
||||||
# git ls-remote
|
|
||||||
# if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $MSC_GIT ls-remote >/dev/null 2>&1) ;then
|
|
||||||
# git fetch --dry-run --verbose
|
|
||||||
if $MSC_GIT fetch --dry-run >/dev/null 2>&1 ;then
|
if $MSC_GIT fetch --dry-run >/dev/null 2>&1 ;then
|
||||||
loginfo "reachable"
|
loginfo "reachable"
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -14,11 +14,9 @@
|
||||||
[ -z "${MSC_GIT+x}" ] && MSC_GIT=git
|
[ -z "${MSC_GIT+x}" ] && MSC_GIT=git
|
||||||
[ -z "${MSC_LOGDIR+x}" ] && export MSC_LOGDIR="${HOME}/logs"
|
[ -z "${MSC_LOGDIR+x}" ] && export MSC_LOGDIR="${HOME}/logs"
|
||||||
[ -z "${MSC_LOGFILE+x}" ] && export MSC_LOGFILE="${MSC_LOGDIR}/myshellconfig.log"
|
[ -z "${MSC_LOGFILE+x}" ] && export MSC_LOGFILE="${MSC_LOGDIR}/myshellconfig.log"
|
||||||
#MSC_LOGDIR="./logs"
|
|
||||||
#MSC_LOGFILE="${MSC_LOGDIR}/git.log"
|
|
||||||
[ -d "${MSC_LOGDIR}" ] || mkdir -p "${MSC_LOGDIR}"
|
[ -d "${MSC_LOGDIR}" ] || mkdir -p "${MSC_LOGDIR}"
|
||||||
[ -z "${MSC_GIT_REMOTE_NAME+x}" ] && export MSC_GIT_REMOTE_NAME=$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1)
|
[ -z "${MSC_GIT_REMOTE_NAME+x}" ] && export MSC_GIT_REMOTE_NAME=$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1)
|
||||||
[ -z "${MSC_GIT_BRANCH:+x}" ] && export MSC_GIT_BRANCH=master
|
[ -z "${MSC_GIT_BRANCH:+x}" ] && export MSC_GIT_BRANCH=$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +79,6 @@ if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \
|
||||||
-a ${MSC_GIT_REPO_UPDATE-${MSC_GIT_REPO_UPDATE_DEFAULT-true}} ]; then
|
-a ${MSC_GIT_REPO_UPDATE-${MSC_GIT_REPO_UPDATE_DEFAULT-true}} ]; then
|
||||||
[ -z "${dorepoupdate+x}" ] && dorepoupdate="true"
|
[ -z "${dorepoupdate+x}" ] && dorepoupdate="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $(stat --printf %Y ${MSC_GIT_UPD_SUBMOD_STATFILE} 2>/dev/null || echo 0 ) \
|
if [ $(stat --printf %Y ${MSC_GIT_UPD_SUBMOD_STATFILE} 2>/dev/null || echo 0 ) \
|
||||||
-lt $(date --date="${MSC_GIT_SUBMODULES_UPDATE_INTERVALL-${MSC_GIT_SUBMODULES_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") \
|
-lt $(date --date="${MSC_GIT_SUBMODULES_UPDATE_INTERVALL-${MSC_GIT_SUBMODULES_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") \
|
||||||
-a ${MSC_GIT_SUBMODULES_UPDATE-${MSC_GIT_SUBMODULES_UPDATE_DEFAULT-true}} ]; then
|
-a ${MSC_GIT_SUBMODULES_UPDATE-${MSC_GIT_SUBMODULES_UPDATE_DEFAULT-true}} ]; then
|
||||||
|
@ -93,7 +90,8 @@ if $dorepoupdate; then
|
||||||
loginfo "$MSC_GIT submodule sync"
|
loginfo "$MSC_GIT submodule sync"
|
||||||
logdebug "$($MSC_GIT submodule sync 2>&1)"
|
logdebug "$($MSC_GIT submodule sync 2>&1)"
|
||||||
loginfo "fetch repo${dosubmodupdate:+ and submodules}"
|
loginfo "fetch repo${dosubmodupdate:+ and submodules}"
|
||||||
$MSC_GIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; }
|
# $MSC_GIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; }
|
||||||
|
$MSC_GIT fetch -p || { logwarning fetch failed; gitupdateend; exit 1; }
|
||||||
if ${dosubmodupdate:-false}; then
|
if ${dosubmodupdate:-false}; then
|
||||||
lastupdatesubmodules
|
lastupdatesubmodules
|
||||||
fi
|
fi
|
||||||
|
@ -138,8 +136,9 @@ EOF
|
||||||
|
|
||||||
if ${dosubmodupdate:-false}; then
|
if ${dosubmodupdate:-false}; then
|
||||||
loginfo "update and commit submodules"
|
loginfo "update and commit submodules"
|
||||||
logdebug "$($MSC_GIT submodule update --remote)"
|
logdebug "$($MSC_GIT submodule sync --recursive)"
|
||||||
logdebug "$($MSC_GIT commit -a -m 'update submodules')"
|
logdebug "$($MSC_GIT submodule update --init --recursive)"
|
||||||
|
#logdebug "$($MSC_GIT commit -a -m 'update submodules')"
|
||||||
touch $MSC_GIT_UPD_SUBMOD_STATFILE
|
touch $MSC_GIT_UPD_SUBMOD_STATFILE
|
||||||
logwarning "submodules synced"
|
logwarning "submodules synced"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
### GIT ####
|
### GIT ####
|
||||||
export MSC_GIT_REPO_UPDATE_DEFAULT=true
|
export MSC_GIT_REPO_UPDATE_DEFAULT=true
|
||||||
export MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT=48 #intervall in hours
|
export MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT=48 #intervall in hours
|
||||||
|
export MSC_GIT_REMOTE_NAME_DEFAULT=gitea
|
||||||
|
export MSC_GIT_BRANCH_DEFAULT=master
|
||||||
export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true
|
export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true
|
||||||
export MSC_GIT_SUBMODULES_UPDATE_INTERVALL_DEFAULT=196 #intervall in hours
|
export MSC_GIT_SUBMODULES_UPDATE_INTERVALL_DEFAULT=196 #intervall in hours
|
||||||
export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://github.com/"
|
export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://github.com/"
|
||||||
|
@ -24,3 +26,4 @@ export TRASHMAIL_TARGET_MAIL_DEFAULT=wertstoffe@xundeenergie.at
|
||||||
export TRASHMAIL_HASHED_DEFAULT=true
|
export TRASHMAIL_HASHED_DEFAULT=true
|
||||||
|
|
||||||
export SSH_CERT_VALIDITY_WARN_SEC="14 days"
|
export SSH_CERT_VALIDITY_WARN_SEC="14 days"
|
||||||
|
|
||||||
|
|
|
@ -14,16 +14,14 @@ if ! $SSHS; then
|
||||||
MSC_GIT_PROTOCOL_FILE=""
|
MSC_GIT_PROTOCOL_FILE=""
|
||||||
[ -z "${MSC_GIT_SERVER+x}" ] && MSC_GIT_SERVER="gitea.schuerz.at"
|
[ -z "${MSC_GIT_SERVER+x}" ] && MSC_GIT_SERVER="gitea.schuerz.at"
|
||||||
[ -z "${MSC_GIT_REPO_NAME+x}" ] && MSC_GIT_REPO_NAME="$(basename $MSC_BASE).git"
|
[ -z "${MSC_GIT_REPO_NAME+x}" ] && MSC_GIT_REPO_NAME="$(basename $MSC_BASE).git"
|
||||||
[ -z "${MSC_GIT_REPO_PATH_HTTP+x}" ] && MSC_GIT_REPO_PATH_HTTP="/jakob/"
|
[ -z "${MSC_GIT_REPO_PATH+x}" ] && MSC_GIT_REPO_PATH="jakob"
|
||||||
[ -z "${MSC_GIT_REPO_PATH_SSH+x}" ] && MSC_GIT_REPO_PATH_SSH=":jakob/"
|
|
||||||
[ -z "${MSC_GIT_REPO_PATH_GIT+x}" ] && MSC_GIT_REPO_PATH_GIT="/jakob/"
|
|
||||||
# [ -z "${MSC_GIT_REPO_PATH_FILE+x}" ] && MSC_GIT_REPO_PATH_FILE="/media/$USER/gitstick/"
|
# [ -z "${MSC_GIT_REPO_PATH_FILE+x}" ] && MSC_GIT_REPO_PATH_FILE="/media/$USER/gitstick/"
|
||||||
[ -z "${MSC_GIT_REPO_PATH_FILE+x}" ] && MSC_GIT_REPO_PATH_FILE="/srv/git/"
|
[ -z "${MSC_GIT_REPO_PATH_FILE+x}" ] && MSC_GIT_REPO_PATH_FILE="/srv/git/"
|
||||||
|
|
||||||
|
|
||||||
MSC_GIT_REMOTE_PUBLIC_GIT="${MSC_GIT_PROTOCOL_GIT}${MSC_GIT_SERVER}${MSC_GIT_REPO_PATH_GIT}"
|
MSC_GIT_REMOTE_PUBLIC_GIT="${MSC_GIT_PROTOCOL_GIT}${MSC_GIT_SERVER}/${MSC_GIT_REPO_PATH}/"
|
||||||
MSC_GIT_REMOTE_PUBLIC_SSH="${MSC_GIT_PROTOCOL_SSH}${MSC_GIT_SERVER}${MSC_GIT_REPO_PATH_SSH}"
|
MSC_GIT_REMOTE_PUBLIC_SSH="${MSC_GIT_PROTOCOL_SSH}${MSC_GIT_SERVER}:${MSC_GIT_REPO_PATH}/"
|
||||||
MSC_GIT_REMOTE_PUBLIC_HTTP="${MSC_GIT_PROTOCOL_HTTP}${MSC_GIT_SERVER}${MSC_GIT_REPO_PATH_HTTP}"
|
MSC_GIT_REMOTE_PUBLIC_HTTP="${MSC_GIT_PROTOCOL_HTTP}${MSC_GIT_SERVER}/${MSC_GIT_REPO_PATH}/"
|
||||||
MSC_GIT_REMOTE_PUBLIC_FILE="${MSC_GIT_PROTOCOL_FILE}${MSC_GIT_REPO_PATH_FILE}"
|
MSC_GIT_REMOTE_PUBLIC_FILE="${MSC_GIT_PROTOCOL_FILE}${MSC_GIT_REPO_PATH_FILE}"
|
||||||
MSC_GIT_REMOTE_PUBLIC_DEFAULT="${MSC_GIT_REMOTE_PUBLIC_GIT}"
|
MSC_GIT_REMOTE_PUBLIC_DEFAULT="${MSC_GIT_REMOTE_PUBLIC_GIT}"
|
||||||
|
|
||||||
|
@ -76,8 +74,10 @@ if ! $SSHS; then
|
||||||
MSC_GIT_REMOTE_PUSH=${MSC_GIT_REMOTE_PUSH_PUBLIC}${MSC_GIT_REPO_NAME}
|
MSC_GIT_REMOTE_PUSH=${MSC_GIT_REMOTE_PUSH_PUBLIC}${MSC_GIT_REPO_NAME}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "${MSC_GIT_REMOTE_NAME+x}" ] && export MSC_GIT_REMOTE_NAME=gitea
|
# [ -z "${MSC_GIT_REMOTE_NAME+x}" ] && export MSC_GIT_REMOTE_NAME=$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1)
|
||||||
[ -z "${MSC_GIT_BRANCH+x}" ] && export MSC_GIT_BRANCH=master
|
# [ -z "${MSC_GIT_BRANCH+x}" ] && export MSC_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
[ -z "${MSC_GIT_REMOTE_NAME+x}" ] && export MSC_GIT_REMOTE_NAME=${MSC_GIT_REMOTE_NAME_DEFAULT}
|
||||||
|
[ -z "${MSC_GIT_BRANCH+x}" ] && export MSC_GIT_BRANCH=${MSC_GIT_BRANCH_DEFAULT}
|
||||||
# If TAG is set, checkout is always headless.
|
# If TAG is set, checkout is always headless.
|
||||||
[ -z "${MSC_GIT_TAG:+x}" ] || { export MSC_GIT_BRANCH=${MSC_GIT_TAG}; export MSC_GIT_CHECKOUTSCRIPT_OPTIONS="-h"; }
|
[ -z "${MSC_GIT_TAG:+x}" ] || { export MSC_GIT_BRANCH=${MSC_GIT_TAG}; export MSC_GIT_CHECKOUTSCRIPT_OPTIONS="-h"; }
|
||||||
|
|
||||||
|
@ -89,8 +89,10 @@ if ! $SSHS; then
|
||||||
*term*)
|
*term*)
|
||||||
|
|
||||||
if [ -d "${MSC_BASE}" -a $($MSC_GIT status 1>/dev/null 2>&1; echo $?) -eq 0 ]; then
|
if [ -d "${MSC_BASE}" -a $($MSC_GIT status 1>/dev/null 2>&1; echo $?) -eq 0 ]; then
|
||||||
|
# MSC_BASE exists and is a git repo
|
||||||
[ -d "${MSC_LOGDIR}" ] || mkdir -p "${MSC_LOGDIR}"
|
[ -d "${MSC_LOGDIR}" ] || mkdir -p "${MSC_LOGDIR}"
|
||||||
if ! $MSC_GIT rev-parse --git-dir > /dev/null 2>&1 ; then
|
if ! $MSC_GIT rev-parse --git-dir > /dev/null 2>&1 ; then
|
||||||
|
# MSC_BASE is not a git-repo initialize it
|
||||||
loginfo "Init ${MSC_BASE} as git-repo" >&2
|
loginfo "Init ${MSC_BASE} as git-repo" >&2
|
||||||
$MSC_GIT init
|
$MSC_GIT init
|
||||||
fi
|
fi
|
||||||
|
@ -100,7 +102,7 @@ if ! $SSHS; then
|
||||||
$MSC_GIT config user.name "${FULLNAME}"
|
$MSC_GIT config user.name "${FULLNAME}"
|
||||||
|
|
||||||
# set upstream only if not detached
|
# set upstream only if not detached
|
||||||
[ $($MSC_GIT rev-parse --abbrev-ref HEAD) != "HEAD" ] && $MSC_GIT branch --set-upstream-to=${MSC_GIT_REMOTE_NAME}/$($MSC_GIT rev-parse --abbrev-ref HEAD)
|
# [ $($MSC_GIT rev-parse --abbrev-ref HEAD) != "HEAD" ] && $MSC_GIT branch --set-upstream-to=${MSC_GIT_REMOTE_NAME}/${MSC_GIT_BRANCH}
|
||||||
|
|
||||||
# sync repo with origin if git is reachable
|
# sync repo with origin if git is reachable
|
||||||
if ckrepo ; then
|
if ckrepo ; then
|
||||||
|
@ -148,7 +150,7 @@ if ! $SSHS; then
|
||||||
# not necessary any more. Vim plugins are updated through git submodules
|
# not necessary any more. Vim plugins are updated through git submodules
|
||||||
#vim -c "PluginInstall" -c ":qa!"
|
#vim -c "PluginInstall" -c ":qa!"
|
||||||
fi
|
fi
|
||||||
[ -z ${MSC_GIT_REMOTE_PUSH+x} ] || $MSC_GIT remote set-url --push ${MSC_GIT_REMOTE_NAME} "${MSC_GIT_REMOTE_PUSH}"
|
#[ -z ${MSC_GIT_REMOTE_PUSH+x} ] || $MSC_GIT remote set-url --push ${MSC_GIT_REMOTE_NAME} "${MSC_GIT_REMOTE_PUSH}"
|
||||||
;;
|
;;
|
||||||
*screen*)
|
*screen*)
|
||||||
loginfo "I'm in sceen/tmux now - no profily syncing" >&2
|
loginfo "I'm in sceen/tmux now - no profily syncing" >&2
|
||||||
|
|
Loading…
Reference in a new issue