Compare commits
5 commits
a77753bc23
...
9f2be86152
Author | SHA1 | Date | |
---|---|---|---|
|
9f2be86152 | ||
|
df804c318b | ||
|
67b1c1bdaf | ||
|
ebe4f43c17 | ||
|
29e8ad1fc5 |
4 changed files with 36 additions and 34 deletions
14
bashrc_add
14
bashrc_add
|
@ -49,7 +49,7 @@ if [[ $- = *i* ]] ; then
|
|||
[ -z "${MSC_GIT_SYNC+x}" ] && export MSC_GIT_SYNC=true
|
||||
|
||||
# hardcoded git
|
||||
export SGIT="git -C ${MSC_BASE}"
|
||||
export MSC_GIT="git -C ${MSC_BASE}"
|
||||
|
||||
|
||||
|
||||
|
@ -94,13 +94,15 @@ EOF
|
|||
if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \
|
||||
-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 "check if reachable"
|
||||
git ls-remote
|
||||
if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT ls-remote >/dev/null 2>&1) ;then
|
||||
logwarning "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
|
||||
loginfo "reachable"
|
||||
return 0
|
||||
else
|
||||
logwarning "not reachable"
|
||||
logwarning "$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1) not reachable"
|
||||
return 3
|
||||
fi
|
||||
else
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# notes : #
|
||||
#################################################################################################
|
||||
|
||||
[ -z "${SGIT+x}" ] && SGIT=git
|
||||
[ -z "${MSC_GIT+x}" ] && MSC_GIT=git
|
||||
[ -z "${MSC_LOGDIR+x}" ] && export MSC_LOGDIR="${HOME}/logs"
|
||||
[ -z "${MSC_LOGFILE+x}" ] && export MSC_LOGFILE="${MSC_LOGDIR}/myshellconfig.log"
|
||||
#MSC_LOGDIR="./logs"
|
||||
|
@ -88,23 +88,23 @@ if [ $(stat --printf %Y ${MSC_GIT_UPD_SUBMOD_STATFILE} 2>/dev/null || echo 0 )
|
|||
[ -z "${dosubmodupdate+x}" ] && dosubmodupdate="true"
|
||||
fi
|
||||
|
||||
#echo $SGIT fetch ${MSC_GIT_REMOTE_NAME} -p 1>&2
|
||||
#echo $MSC_GIT fetch ${MSC_GIT_REMOTE_NAME} -p 1>&2
|
||||
if $dorepoupdate; then
|
||||
loginfo "fetch repo${dosubmodupdate:+ and submodules}"
|
||||
#$SGIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; }
|
||||
$SGIT 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 ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; }
|
||||
if ${dosubmodupdate:-false}; then
|
||||
lastupdatesubmodules
|
||||
fi
|
||||
|
||||
echo "Check for local changes:" >> "${MSC_LOGFILE}"
|
||||
if $SGIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MSC_LOGFILE}" ; then
|
||||
if $MSC_GIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MSC_LOGFILE}" ; then
|
||||
cat << EOF >> "${MSC_LOGFILE}"
|
||||
no changes in local repo
|
||||
$SGIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH}
|
||||
$MSC_GIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH}
|
||||
EOF
|
||||
$SGIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; }
|
||||
$SGIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; }
|
||||
$MSC_GIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; }
|
||||
$MSC_GIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; }
|
||||
touch $MSC_GIT_UPD_REPO_STATFILE
|
||||
else
|
||||
logwarning -n " Lokale Änderungen festgestellt:"
|
||||
|
@ -112,17 +112,17 @@ EOF
|
|||
cat << EOF >> "${MSC_LOGFILE}"
|
||||
um die Änderung zurückzusetzen bitte
|
||||
|
||||
$SGIT checkout \$FILENAME
|
||||
$MSC_GIT checkout \$FILENAME
|
||||
|
||||
oder um alle lokalen Änderungen auf einmal zurückzusetzen:
|
||||
|
||||
$SGIT checkout .
|
||||
$MSC_GIT checkout .
|
||||
|
||||
ausführen
|
||||
|
||||
Die Änderungen sind:
|
||||
$($SGIT diff-index HEAD --|awk '{print $5, $6}')
|
||||
$($SGIT diff-index -p HEAD --)
|
||||
$($MSC_GIT diff-index HEAD --|awk '{print $5, $6}')
|
||||
$($MSC_GIT diff-index -p HEAD --)
|
||||
EOF
|
||||
|
||||
gitupdateend
|
||||
|
@ -134,8 +134,8 @@ EOF
|
|||
|
||||
if ${dosubmodupdate:-false}; then
|
||||
loginfo "update and commit submodules"
|
||||
logdebug "$($SGIT submodule update --remote)"
|
||||
logdebug "$($SGIT commit -a -m 'update submodules')"
|
||||
logdebug "$($MSC_GIT submodule update --remote)"
|
||||
logdebug "$($MSC_GIT commit -a -m 'update submodules')"
|
||||
touch $MSC_GIT_UPD_SUBMOD_STATFILE
|
||||
logwarning "submodules synced"
|
||||
fi
|
||||
|
|
|
@ -84,7 +84,7 @@ create_symlinks() {
|
|||
ln -sf "${MSC_BASE}/tmux/tmux.conf" ~/.tmux.conf
|
||||
|
||||
# Configure to use githooks in .githooks, not in standardlocation .git/hooks
|
||||
$SGIT config core.hooksPath .githooks
|
||||
$MSC_GIT config core.hooksPath .githooks
|
||||
# remove all old symlinks in .githooks and relink files from .githooks to .git/hooks
|
||||
# don't know, why i do it here. TODO: Check it
|
||||
find .git/hooks -type l -exec rm {} \; && find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
|
||||
|
@ -669,7 +669,7 @@ function checkbkp() {
|
|||
ENTRY
|
||||
if ping -c 3 backup.vpn >/dev/null 2>&1 ; then
|
||||
local SSH="/usr/bin/ssh"
|
||||
local CMD="$SSH -T backup.vpn"
|
||||
local CMD="$SSH -T root@backup.vpn"
|
||||
$CMD /bin/bash << EOF
|
||||
sudo find /srv/nfs/backup -mindepth 1 -maxdepth 1|grep -v -e "git$\|git-backup-repos"|while read i;do printf "%-30s%s\\n" "\$i" \$(ls \$i|tail -n1);done|sort -k 2.1 -r
|
||||
EOF
|
||||
|
@ -684,7 +684,7 @@ function checkbkp-full() {
|
|||
ENTRY
|
||||
if ping -c 3 backup.vpn >/dev/null 2>&1 ; then
|
||||
local SSH="/usr/bin/ssh"
|
||||
local CMD="$SSH -T backup.vpn"
|
||||
local CMD="$SSH -T root@backup.vpn"
|
||||
$CMD /bin/bash << EOF
|
||||
sudo find /srv/nfs/backup -mindepth 1 -maxdepth 1|grep -v -e "git$\|git-backup-repos"|while read i;do printf "%-30s%s\\n" "\$i" \$(ls \$i|tail -n1);done|sort -k 2.1 -r
|
||||
EOF
|
||||
|
|
|
@ -88,19 +88,19 @@ if ! $SSHS; then
|
|||
#*term*|*linux*)
|
||||
*term*)
|
||||
|
||||
if [ -d "${MSC_BASE}" -a $($SGIT 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
|
||||
[ -d "${MSC_LOGDIR}" ] || mkdir -p "${MSC_LOGDIR}"
|
||||
if ! $SGIT rev-parse --git-dir > /dev/null 2>&1 ; then
|
||||
if ! $MSC_GIT rev-parse --git-dir > /dev/null 2>&1 ; then
|
||||
loginfo "Init ${MSC_BASE} as git-repo" >&2
|
||||
$SGIT init
|
||||
$MSC_GIT init
|
||||
fi
|
||||
|
||||
# Update Userinformations for git
|
||||
$SGIT config user.email "${USERNAME}"
|
||||
$SGIT config user.name "${FULLNAME}"
|
||||
$MSC_GIT config user.email "${USERNAME}"
|
||||
$MSC_GIT config user.name "${FULLNAME}"
|
||||
|
||||
# set upstream only if not detached
|
||||
[ $($SGIT rev-parse --abbrev-ref HEAD) != "HEAD" ] && $SGIT branch --set-upstream-to=${MSC_GIT_REMOTE_NAME}/$($SGIT 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 rev-parse --abbrev-ref HEAD)
|
||||
|
||||
# sync repo with origin if git is reachable
|
||||
if ckrepo ; then
|
||||
|
@ -130,12 +130,12 @@ if ! $SSHS; then
|
|||
|
||||
[ -d "${MSC_BASE}" ] && { loginfo create ${MSC_LOGDIR} >&2; mkdir -p "${MSC_LOGDIR}"; }
|
||||
|
||||
$SGIT config user.email "${USERNAME}"
|
||||
$SGIT config user.name "${FULLNAME}"
|
||||
$MSC_GIT config user.email "${USERNAME}"
|
||||
$MSC_GIT config user.name "${FULLNAME}"
|
||||
|
||||
# Initialize Vundle as preconfigured Submodule
|
||||
#$SGIT submodule update --init --recursive
|
||||
#$SGIT submodule foreach 'git checkout master'
|
||||
#$MSC_GIT submodule update --init --recursive
|
||||
#$MSC_GIT submodule foreach 'git checkout master'
|
||||
|
||||
loginfo "sync config" >&2
|
||||
sync_config
|
||||
|
@ -148,7 +148,7 @@ if ! $SSHS; then
|
|||
# not necessary any more. Vim plugins are updated through git submodules
|
||||
#vim -c "PluginInstall" -c ":qa!"
|
||||
fi
|
||||
[ -z ${MSC_GIT_REMOTE_PUSH+x} ] || $SGIT 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*)
|
||||
loginfo "I'm in sceen/tmux now - no profily syncing" >&2
|
||||
|
|
Loading…
Reference in a new issue