From 0d6b2415cb0c3ff9038a43034750ff52fd0f6274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 24 Nov 2020 00:10:22 +0100 Subject: [PATCH 01/25] update submodules --- vim/pack/plugins/start/vim-airline | 2 +- vim/pack/plugins/start/vim-fugitive | 2 +- vim/pack/plugins/start/vim-gitgutter | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vim/pack/plugins/start/vim-airline b/vim/pack/plugins/start/vim-airline index 5366671..a48f676 160000 --- a/vim/pack/plugins/start/vim-airline +++ b/vim/pack/plugins/start/vim-airline @@ -1 +1 @@ -Subproject commit 536667191d5bdc0afa3a18d7df229731e778815e +Subproject commit a48f67657ff261422845d367772de38618ccc049 diff --git a/vim/pack/plugins/start/vim-fugitive b/vim/pack/plugins/start/vim-fugitive index 1a77f1c..660d2ba 160000 --- a/vim/pack/plugins/start/vim-fugitive +++ b/vim/pack/plugins/start/vim-fugitive @@ -1 +1 @@ -Subproject commit 1a77f1c00e12e8460f39098ec3289c5433d32512 +Subproject commit 660d2ba2b60026a9069ee005562ddad6a67f9fb0 diff --git a/vim/pack/plugins/start/vim-gitgutter b/vim/pack/plugins/start/vim-gitgutter index 987a333..f614693 160000 --- a/vim/pack/plugins/start/vim-gitgutter +++ b/vim/pack/plugins/start/vim-gitgutter @@ -1 +1 @@ -Subproject commit 987a33355ef424161fdbc4e5d625b5b5aed9704c +Subproject commit f614693b2a743d1b28245b2d1534f1180e2be2bf From 5181abc542b58c59b17275b8d317d2e1d2fe6a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 17 Dec 2020 03:58:40 +0100 Subject: [PATCH 02/25] update submodules --- vim/pack/plugins/start/fzf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/pack/plugins/start/fzf b/vim/pack/plugins/start/fzf index 00f4551..ab3937e 160000 --- a/vim/pack/plugins/start/fzf +++ b/vim/pack/plugins/start/fzf @@ -1 +1 @@ -Subproject commit 00f4551a7b9edda202f15f43e694f949f04927de +Subproject commit ab3937ee5a62d63bac9307bfe72601eeb4fc9cd2 From da5f41c6a05bb96f28038a1368e7cee23a5da6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 18 Dec 2020 18:00:29 +0100 Subject: [PATCH 03/25] update submodules --- vim/pack/plugins/start/nerdtree | 2 +- vim/pack/plugins/start/vim-airline-themes | 2 +- vim/pack/plugins/start/vim-fugitive | 2 +- vim/pack/plugins/start/vim-gnupg | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) create mode 160000 vim/pack/plugins/start/vim-gnupg diff --git a/vim/pack/plugins/start/nerdtree b/vim/pack/plugins/start/nerdtree index 14af897..474d735 160000 --- a/vim/pack/plugins/start/nerdtree +++ b/vim/pack/plugins/start/nerdtree @@ -1 +1 @@ -Subproject commit 14af89743ac1c31ff9bb43682025eda50333a7d5 +Subproject commit 474d735b7d68a315e1f426920f9aa7391369b606 diff --git a/vim/pack/plugins/start/vim-airline-themes b/vim/pack/plugins/start/vim-airline-themes index 5cf03c3..8f1aa2c 160000 --- a/vim/pack/plugins/start/vim-airline-themes +++ b/vim/pack/plugins/start/vim-airline-themes @@ -1 +1 @@ -Subproject commit 5cf03c355b64836ebcb681136539f48ada34f363 +Subproject commit 8f1aa2c7fa44bf33b1fd4678f9c7b40c126b0e2b diff --git a/vim/pack/plugins/start/vim-fugitive b/vim/pack/plugins/start/vim-fugitive index 7afa1cf..bebe504 160000 --- a/vim/pack/plugins/start/vim-fugitive +++ b/vim/pack/plugins/start/vim-fugitive @@ -1 +1 @@ -Subproject commit 7afa1cfaa62e7fc6f891d0d59f4b10d046b5fd8e +Subproject commit bebe504e38d0a20c30d6dd666c4c793b3cc66104 diff --git a/vim/pack/plugins/start/vim-gnupg b/vim/pack/plugins/start/vim-gnupg new file mode 160000 index 0000000..96be0be --- /dev/null +++ b/vim/pack/plugins/start/vim-gnupg @@ -0,0 +1 @@ +Subproject commit 96be0be1240a848da56d665b38e1b0fe7ee3f1af From ace9e7685603fa5b677e517b7a9a129ef14e266a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 19 Dec 2020 13:02:34 +0100 Subject: [PATCH 04/25] update submodules --- vim/pack/plugins/start/nerdtree | 2 +- vim/pack/plugins/start/vim-airline-themes | 2 +- vim/pack/plugins/start/vim-fugitive | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vim/pack/plugins/start/nerdtree b/vim/pack/plugins/start/nerdtree index 14af897..2406c45 160000 --- a/vim/pack/plugins/start/nerdtree +++ b/vim/pack/plugins/start/nerdtree @@ -1 +1 @@ -Subproject commit 14af89743ac1c31ff9bb43682025eda50333a7d5 +Subproject commit 2406c456ee73d32289c2c304ecd8dd1735bc2f2c diff --git a/vim/pack/plugins/start/vim-airline-themes b/vim/pack/plugins/start/vim-airline-themes index 5cf03c3..8f1aa2c 160000 --- a/vim/pack/plugins/start/vim-airline-themes +++ b/vim/pack/plugins/start/vim-airline-themes @@ -1 +1 @@ -Subproject commit 5cf03c355b64836ebcb681136539f48ada34f363 +Subproject commit 8f1aa2c7fa44bf33b1fd4678f9c7b40c126b0e2b diff --git a/vim/pack/plugins/start/vim-fugitive b/vim/pack/plugins/start/vim-fugitive index 7afa1cf..bebe504 160000 --- a/vim/pack/plugins/start/vim-fugitive +++ b/vim/pack/plugins/start/vim-fugitive @@ -1 +1 @@ -Subproject commit 7afa1cfaa62e7fc6f891d0d59f4b10d046b5fd8e +Subproject commit bebe504e38d0a20c30d6dd666c4c793b3cc66104 From 25bb02adf93e77a224ad69d53ebedfda186d7567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 19 Dec 2020 21:01:15 +0100 Subject: [PATCH 05/25] add function to test btrfs --- functions.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions.sh b/functions.sh index ef86ae2..2c9f55c 100755 --- a/functions.sh +++ b/functions.sh @@ -946,4 +946,9 @@ get_crtime() { # return 0 #} + +is_btrfs_subvolume() { + btrfs subvolume show "$1" >/dev/null 2>&1 +} + #EOF From a575ab0e14a28e79884372aebf8f11c8f79a40bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 19 Dec 2020 21:04:03 +0100 Subject: [PATCH 06/25] add vim plugin --- vim/pack/plugins/start/vim-gnupg | 1 + 1 file changed, 1 insertion(+) create mode 160000 vim/pack/plugins/start/vim-gnupg diff --git a/vim/pack/plugins/start/vim-gnupg b/vim/pack/plugins/start/vim-gnupg new file mode 160000 index 0000000..96be0be --- /dev/null +++ b/vim/pack/plugins/start/vim-gnupg @@ -0,0 +1 @@ +Subproject commit 96be0be1240a848da56d665b38e1b0fe7ee3f1af From 3f4b655d1c93a0760d6b11a781f8accc58518077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 19 Dec 2020 22:39:31 +0100 Subject: [PATCH 07/25] add btrfs-functions --- functions.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index 2c9f55c..f2eecd9 100755 --- a/functions.sh +++ b/functions.sh @@ -948,7 +948,30 @@ get_crtime() { is_btrfs_subvolume() { - btrfs subvolume show "$1" >/dev/null 2>&1 + sudo btrfs subvolume show "$1" >/dev/null } +convert_to_subvolume () { + local XSUDO + local DIR + case $1 in + --sudo|-s) + XSUDO=sudo + shift + ;; + esac + DIR="${1}" + [ -d "${DIR}" ] || return 1 + is_btrfs_subvolume "${DIR}" && return 0 + set -x + #btrfs subvolume create "${DIR}".new && \ + ${XSUDO:+sudo} btrfs subvolume create "${DIR}.new" && \ + /bin/cp -Tr --reflink=always "${DIR}" "${DIR}".new && \ + mv "${DIR}" "${DIR}".orig && \ + mv "${DIR}".new "${DIR}" || return 2 + + set +x + return 0 + +} #EOF From a010d54b21040ec047de709795d2d3e2bfd1507f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sat, 19 Dec 2020 22:46:56 +0100 Subject: [PATCH 08/25] add option archive to cp --- functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index f2eecd9..585f338 100755 --- a/functions.sh +++ b/functions.sh @@ -966,7 +966,7 @@ convert_to_subvolume () { set -x #btrfs subvolume create "${DIR}".new && \ ${XSUDO:+sudo} btrfs subvolume create "${DIR}.new" && \ - /bin/cp -Tr --reflink=always "${DIR}" "${DIR}".new && \ + /bin/cp -aTr --reflink=always "${DIR}" "${DIR}".new && \ mv "${DIR}" "${DIR}".orig && \ mv "${DIR}".new "${DIR}" || return 2 From fa6f4819c9d35fb94f2c7245984b9591a32361e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Mon, 21 Dec 2020 01:45:17 +0100 Subject: [PATCH 09/25] update submodules --- vim/pack/plugins/start/nerdtree | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/pack/plugins/start/nerdtree b/vim/pack/plugins/start/nerdtree index 2406c45..aaa946f 160000 --- a/vim/pack/plugins/start/nerdtree +++ b/vim/pack/plugins/start/nerdtree @@ -1 +1 @@ -Subproject commit 2406c456ee73d32289c2c304ecd8dd1735bc2f2c +Subproject commit aaa946fb6bd79b9af86fbaf4b6b63fd81d839bd9 From d9d6b6dcdbcfaa35a303fe2e871d29d7e081c9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Mon, 21 Dec 2020 21:39:59 +0100 Subject: [PATCH 10/25] increase update intervall for submodules --- bashrc_add | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc_add b/bashrc_add index 24f8671..182f0a5 100755 --- a/bashrc_add +++ b/bashrc_add @@ -47,7 +47,7 @@ if [[ $- = *i* ]] ; then [ -z "${MSC_GIT_CHECKOUT_TIMEOUT+x}" ] && export MSC_GIT_CHECKOUT_TIMEOUT=20s [ -z "${MSC_GIT_SYNC+x}" ] && export MSC_GIT_SYNC=true [ -z "${MSC_GIT_SUBMODULES_UPDATE_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true - [ -z "${MSC_GIT_SUBMODULES_UPDATE_INTERVALL+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_INTERVALL=48 #intervall in hours + [ -z "${MSC_GIT_SUBMODULES_UPDATE_INTERVALL+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_INTERVALL=96 #intervall in hours [ -z "${MSC_GIT_SUBMODULES_SERVER_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://git.schuerz.at/github.com/" [ -z "${MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT+x}" ] && export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h" # hardcoded git From 007ba8bc13452c993f6e0bfdf3f757bc7564dcea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 08:19:20 +0100 Subject: [PATCH 11/25] update submodules --- vim/pack/plugins/start/fzf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/pack/plugins/start/fzf b/vim/pack/plugins/start/fzf index ab3937e..e9bc733 160000 --- a/vim/pack/plugins/start/fzf +++ b/vim/pack/plugins/start/fzf @@ -1 +1 @@ -Subproject commit ab3937ee5a62d63bac9307bfe72601eeb4fc9cd2 +Subproject commit e9bc7331bde238e84f24b76ebb1f5e18799b15c4 From 615df5a0359d132e57fec3a7695e9703b25d742f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 12:51:04 +0100 Subject: [PATCH 12/25] update submods and repo only after intervall --- bashrc_add | 56 +++++++++++++++++++--------------- bin/git-myshellconfig-checkout | 32 +++++++++---------- 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/bashrc_add b/bashrc_add index 182f0a5..b62dfab 100755 --- a/bashrc_add +++ b/bashrc_add @@ -27,29 +27,32 @@ if [[ $- = *i* ]] ; then # hardcoded paths export MSC_BASE_PARENT="$(dirname $MSC_BASE)" export MSC_BASH_COMPLETION="${HOME}/${MSC_SUBPATH}/bash_completion.d" + export MSC_GIT_UPD_SUBMOD_STATFILE="${MSC_BASE%/}${MSC_BASE:+/}.last_update_submodules" + export MSC_GIT_UPD_REPO_STATFILE="${MSC_BASE%/}${MSC_BASE:+/}.last_update_repo" # Load DEFAULTS [ -e ${MSC_BASE}/defaults.conf ] && . ${MSC_BASE}/defaults.conf # Userdata - [ -z "${USERNAME+x}" ] && export USERNAME="$USER" - [ -z "${USEREMAIL+x}" ] && export USEREMAIL="$USER@$(domainname -d)" - [ -z "${FULLNAME+x}" ] && export FULLNAME="$(getent passwd $USER | cut -d ":" -f 5 | cut -d ',' -f 1)" + [ -z "${USERNAME+x}" ] && export USERNAME="$USER" + [ -z "${USEREMAIL+x}" ] && export USEREMAIL="$USER@$(domainname -d)" + [ -z "${FULLNAME+x}" ] && export FULLNAME="$(getent passwd $USER | cut -d ":" -f 5 | cut -d ',' -f 1)" # GIT - [ -z "${GIT_AUTHOR_NAME+x}" ] && export GIT_AUTHOR_NAME=$FULLNAME - [ -z "${GIT_AUTHOR_EMAIL+x}" ] && export GIT_AUTHOR_EMAIL=$USEREMAIL - [ -z "${GIT_COMMITTER_NAME+x}" ] && export GIT_COMMITTER_NAME=$FULLNAME - [ -z "${GIT_COMMITTER_EMAIL+x}" ] && export GIT_COMMITTER_EMAIL=$USEREMAIL + [ -z "${GIT_AUTHOR_NAME+x}" ] && export GIT_AUTHOR_NAME=$FULLNAME + [ -z "${GIT_AUTHOR_EMAIL+x}" ] && export GIT_AUTHOR_EMAIL=$USEREMAIL + [ -z "${GIT_COMMITTER_NAME+x}" ] && export GIT_COMMITTER_NAME=$FULLNAME + [ -z "${GIT_COMMITTER_EMAIL+x}" ] && export GIT_COMMITTER_EMAIL=$USEREMAIL - [ -z "${MSC_GIT_TIMEOUT+x}" ] && export MSC_GIT_TIMEOUT=5s - [ -z "${MSC_GIT_CHECKOUT_TIMEOUT+x}" ] && export MSC_GIT_CHECKOUT_TIMEOUT=20s - [ -z "${MSC_GIT_SYNC+x}" ] && export MSC_GIT_SYNC=true - [ -z "${MSC_GIT_SUBMODULES_UPDATE_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true - [ -z "${MSC_GIT_SUBMODULES_UPDATE_INTERVALL+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_INTERVALL=96 #intervall in hours - [ -z "${MSC_GIT_SUBMODULES_SERVER_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://git.schuerz.at/github.com/" - [ -z "${MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT+x}" ] && export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h" + [ -z "${MSC_GIT_TIMEOUT+x}" ] && export MSC_GIT_TIMEOUT=5s + [ -z "${MSC_GIT_CHECKOUT_TIMEOUT+x}" ] && export MSC_GIT_CHECKOUT_TIMEOUT=20s + [ -z "${MSC_GIT_SYNC+x}" ] && export MSC_GIT_SYNC=true + [ -z "${MSC_GIT_SUBMODULES_UPDATE_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true + [ -z "${MSC_GIT_SUBMODULES_UPDATE_INTERVALL+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_INTERVALL=96 #intervall in hours + [ -z "${MSC_GIT_SUBMODULES_SERVER_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://git.schuerz.at/github.com/" + [ -z "${MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT+x}" ] && export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h" + # hardcoded git export SGIT="git -C ${MSC_BASE}" @@ -61,15 +64,15 @@ if [[ $- = *i* ]] ; then # Logging - [ -z "${MSC_LOGDIR+x}" ] && export MSC_LOGDIR="${HOME}/logs" - [ -z "${MSC_LOGFILE+x}" ] && export MSC_LOGFILE="${MSC_LOGDIR}/myshellconfig.log" - [ -z "${MSC_LOGLEVEL_DEFAULT+x}" ] && export MSC_LOGLEVEL_DEFAULT="INFO" - [ -z "${MSC_FILELOGLEVEL_DEFAULT+x}" ] && export MSC_FILELOGLEVEL_DEFAULT="DEBUG" - [ -z "${SCRIPT_LOG+x}" ] && export SCRIPT_LOG="${MSC_LOGFILE}" - [ -z "${LOGLEVEL_DEFAULT+x}" ] && export LOGLEVEL_DEFAULT="${MSC_LOGLEVEL_DEFAULT-INFO}" - [ -z "${FILELOGLEVEL_DEFAULT+x}" ] && export FILELOGLEVEL_DEFAULT="${MSC_FILELOGLEVEL_DEFAULT-INFO}" + [ -z "${MSC_LOGDIR+x}" ] && export MSC_LOGDIR="${HOME}/logs" + [ -z "${MSC_LOGFILE+x}" ] && export MSC_LOGFILE="${MSC_LOGDIR}/myshellconfig.log" + [ -z "${MSC_LOGLEVEL_DEFAULT+x}" ] && export MSC_LOGLEVEL_DEFAULT="INFO" + [ -z "${MSC_FILELOGLEVEL_DEFAULT+x}" ] && export MSC_FILELOGLEVEL_DEFAULT="DEBUG" + [ -z "${SCRIPT_LOG+x}" ] && export SCRIPT_LOG="${MSC_LOGFILE}" + [ -z "${LOGLEVEL_DEFAULT+x}" ] && export LOGLEVEL_DEFAULT="${MSC_LOGLEVEL_DEFAULT-INFO}" + [ -z "${FILELOGLEVEL_DEFAULT+x}" ] && export FILELOGLEVEL_DEFAULT="${MSC_FILELOGLEVEL_DEFAULT-INFO}" # Create necessary directories for logging - [ -n "${MSC_LOGDIR-x}" ] && mkdir -p "$MSC_LOGDIR" + [ -n "${MSC_LOGDIR-x}" ] && mkdir -p "$MSC_LOGDIR" # load logging functions . ${MSC_BASE}/logging @@ -90,7 +93,8 @@ EOF ckrepo () { # check if remote repo is reachable - if $MSC_GIT_SYNC; then + if [ $MSC_GIT_SYNC -a $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ + -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-0} hours ago" "+%s") ]; then if $( timeout --foreground "${MSC_GIT_TIMEOUT}" $SGIT ls-remote >/dev/null 2>&1) ;then return 0 else @@ -104,12 +108,14 @@ EOF } lastupdatesubmodules () { - date "+%s" > ${MSC_BASE%/}${MSC_BASE:+/}.last_update_submodules + #date "+%s" > ${MSC_GIT_UPD_SUBMOD_STATFILE} + touch ${MSC_GIT_UPD_REPO_STATFILE} } export -f lastupdatesubmodules lastupdaterepo () { - date "+%s" > ${MSC_BASE%/}${MSC_BASE:+/}.last_update_repo + #date "+%s" > ${MSC_GIT_UPD_REPO_STATFILE} + touch ${MSC_GIT_UPD_REPO_STATFILE} } export -f lastupdaterepo diff --git a/bin/git-myshellconfig-checkout b/bin/git-myshellconfig-checkout index 0313c70..3a599e0 100755 --- a/bin/git-myshellconfig-checkout +++ b/bin/git-myshellconfig-checkout @@ -61,15 +61,19 @@ done #echo -n " remote: ${MSC_GIT_REMOTE_NAME}, branch: ${MSC_GIT_BRANCH}: " # Check for updates in submodules only if last check was INTERVALL hours in the past -if [ $(cat ${MSC_BASE%/}${MSC_BASE:+/}.last_update_submodules 2>/dev/null || echo 0 ) \ +#if [ $(cat ${MSC_BASE%/}${MSC_BASE:+/}.last_update_submodules 2>/dev/null || echo 0 ) \ +[ -z "${MSC_GIT_UPD_SUBMOD_STATFILE+x}" ] && export MSC_GIT_UPD_SUBMOD_STATFILE="${MSC_BASE%/}${MSC_BASE:+/}.last_update_submodules" +[ -z "${MSC_GIT_UPD_REPO_STATFILE+x}" ] && export MSC_GIT_UPD_REPO_STATFILE="${MSC_BASE%/}${MSC_BASE:+/}.last_update_repo" + +if [ $(stat --printf %Y ${MSC_GIT_UPD_SUBMOD_STATFILE} 2>/dev/null || echo 0 ) \ -lt $(date --date="${MSC_GIT_SUBMODULES_UPDATE_INTERVALL} hours ago" "+%s") \ -a ${MSC_GIT_SUBMODULES_UPDATE-${MSC_GIT_SUBMODULES_UPDATE_DEFAULT-true}} ]; then [ -z "${dosrepoupdate+x}" ] && dorepoupdate="true" fi -if [ $(cat ${MSC_BASE%/}${MSC_BASE:+/}.last_update_submodules 2>/dev/null || echo 0 ) \ - -lt $(date --date="${MSC_GIT_SUBMODULES_UPDATE_INTERVALL} hours ago" "+%s") \ - -a ${MSC_GIT_SUBMODULES_UPDATE-${MSC_GIT_SUBMODULES_UPDATE_DEFAULT-true}} ]; then +if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ + -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL} hours ago" "+%s") \ + -a ${MSC_GIT_REPO_UPDATE-${MSC_GIT_REPO_UPDATE_DEFAULT-true}} ]; then [ -z "${dosubmodupdate+x}" ] && dosubmodupdate="true" fi @@ -88,6 +92,7 @@ if $SGIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MSC_LOGFILE}" 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; } + touch $MSC_GIT_UPD_REPO_STATFILE else logwarn -n " Lokale Änderungen festgestellt:" echo " Siehe Logfile ${MSC_LOGFILE}" >&2 @@ -114,18 +119,13 @@ fi loginfo "repo${dosubmodupdate:+ and submodules} synced" -#if ${MSC_GIT_SUBMODULES_UPDATE-${MSC_GIT_SUBMODULES_UPDATE_DEFAULT-true}}; then - if ${dosubmodupdate:-false}; then - loginfo "update and commit submodules" - logdebug "$($SGIT submodule update --remote)" - logdebug "$($SGIT commit -a -m 'update submodules')" - lastupdatesubmodules - logwarn "submodules synced" - fi -#else -# loginfo -n ", submodules not synced" -# logdebug "Do not update submodules. It's denied by environment MSC_GIT_UPDATE_SUBMODULES: ${MSC_GIT_SUBMODULES_UPDATE-${MSC_GIT_SUBMODULES_UPDATE_DEFAULT-true}}" -#fi +if ${dosubmodupdate:-false}; then + loginfo "update and commit submodules" + logdebug "$($SGIT submodule update --remote)" + logdebug "$($SGIT commit -a -m 'update submodules')" + touch $MSC_GIT_UPD_SUBMOD_STATFILE + logwarn "submodules synced" +fi EXIT exit $rc From 65c52d99012f2c47b38adb583cbf3c6c63824046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 12:57:15 +0100 Subject: [PATCH 13/25] add variables --- bashrc_add | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bashrc_add b/bashrc_add index b62dfab..115016e 100755 --- a/bashrc_add +++ b/bashrc_add @@ -48,8 +48,10 @@ if [[ $- = *i* ]] ; then [ -z "${MSC_GIT_TIMEOUT+x}" ] && export MSC_GIT_TIMEOUT=5s [ -z "${MSC_GIT_CHECKOUT_TIMEOUT+x}" ] && export MSC_GIT_CHECKOUT_TIMEOUT=20s [ -z "${MSC_GIT_SYNC+x}" ] && export MSC_GIT_SYNC=true + [ -z "${MSC_GIT_REPO_UPDATE_DEFAULT+x}" ] && export MSC_GIT_REPO_UPDATE_DEFAULT=true + [ -z "${MSC_GIT_REPO_UPDATE_INTERVALL+x}" ] && export MSC_GIT_REPO_UPDATE_INTERVALL=48 #intervall in hours [ -z "${MSC_GIT_SUBMODULES_UPDATE_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true - [ -z "${MSC_GIT_SUBMODULES_UPDATE_INTERVALL+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_INTERVALL=96 #intervall in hours + [ -z "${MSC_GIT_SUBMODULES_UPDATE_INTERVALL+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_INTERVALL=168 #intervall in hours 168=1week [ -z "${MSC_GIT_SUBMODULES_SERVER_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://git.schuerz.at/github.com/" [ -z "${MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT+x}" ] && export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h" From 479936321d42f05c255eadb3c95369a61fd6421f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:16:32 +0100 Subject: [PATCH 14/25] move defaults to own file, update variable usage --- bashrc_add | 16 +++------------- defaults.conf | 10 +++++++++- myshell_git_sync | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/bashrc_add b/bashrc_add index 115016e..033a86a 100755 --- a/bashrc_add +++ b/bashrc_add @@ -45,15 +45,9 @@ if [[ $- = *i* ]] ; then [ -z "${GIT_COMMITTER_NAME+x}" ] && export GIT_COMMITTER_NAME=$FULLNAME [ -z "${GIT_COMMITTER_EMAIL+x}" ] && export GIT_COMMITTER_EMAIL=$USEREMAIL - [ -z "${MSC_GIT_TIMEOUT+x}" ] && export MSC_GIT_TIMEOUT=5s +# [ -z "${MSC_GIT_TIMEOUT+x}" ] && export MSC_GIT_TIMEOUT=5s [ -z "${MSC_GIT_CHECKOUT_TIMEOUT+x}" ] && export MSC_GIT_CHECKOUT_TIMEOUT=20s [ -z "${MSC_GIT_SYNC+x}" ] && export MSC_GIT_SYNC=true - [ -z "${MSC_GIT_REPO_UPDATE_DEFAULT+x}" ] && export MSC_GIT_REPO_UPDATE_DEFAULT=true - [ -z "${MSC_GIT_REPO_UPDATE_INTERVALL+x}" ] && export MSC_GIT_REPO_UPDATE_INTERVALL=48 #intervall in hours - [ -z "${MSC_GIT_SUBMODULES_UPDATE_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true - [ -z "${MSC_GIT_SUBMODULES_UPDATE_INTERVALL+x}" ] && export MSC_GIT_SUBMODULES_UPDATE_INTERVALL=168 #intervall in hours 168=1week - [ -z "${MSC_GIT_SUBMODULES_SERVER_DEFAULT+x}" ] && export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://git.schuerz.at/github.com/" - [ -z "${MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT+x}" ] && export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h" # hardcoded git export SGIT="git -C ${MSC_BASE}" @@ -68,11 +62,7 @@ if [[ $- = *i* ]] ; then # Logging [ -z "${MSC_LOGDIR+x}" ] && export MSC_LOGDIR="${HOME}/logs" [ -z "${MSC_LOGFILE+x}" ] && export MSC_LOGFILE="${MSC_LOGDIR}/myshellconfig.log" - [ -z "${MSC_LOGLEVEL_DEFAULT+x}" ] && export MSC_LOGLEVEL_DEFAULT="INFO" - [ -z "${MSC_FILELOGLEVEL_DEFAULT+x}" ] && export MSC_FILELOGLEVEL_DEFAULT="DEBUG" [ -z "${SCRIPT_LOG+x}" ] && export SCRIPT_LOG="${MSC_LOGFILE}" - [ -z "${LOGLEVEL_DEFAULT+x}" ] && export LOGLEVEL_DEFAULT="${MSC_LOGLEVEL_DEFAULT-INFO}" - [ -z "${FILELOGLEVEL_DEFAULT+x}" ] && export FILELOGLEVEL_DEFAULT="${MSC_FILELOGLEVEL_DEFAULT-INFO}" # Create necessary directories for logging [ -n "${MSC_LOGDIR-x}" ] && mkdir -p "$MSC_LOGDIR" # load logging functions @@ -95,9 +85,9 @@ EOF ckrepo () { # check if remote repo is reachable - if [ $MSC_GIT_SYNC -a $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ + if [ ${MSC_GIT_SYNC-$MSC_GIT_REPO_UPDATE} -a $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-0} hours ago" "+%s") ]; then - if $( timeout --foreground "${MSC_GIT_TIMEOUT}" $SGIT ls-remote >/dev/null 2>&1) ;then + if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT ls-remote >/dev/null 2>&1) ;then return 0 else return 1 diff --git a/defaults.conf b/defaults.conf index 91d5cc7..3a4b258 100644 --- a/defaults.conf +++ b/defaults.conf @@ -1,8 +1,16 @@ +export MSC_GIT_REPO_UPDATE_DEFAULT=true +export MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT=48 #intervall in hours export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true -export MSC_GIT_SUBMODULES_UPDATE_INTERVALL=48 #intervall in hours +export MSC_GIT_SUBMODULES_UPDATE_INTERVALL_DEFAULT=196 #intervall in hours export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://git.schuerz.at/github.com/" export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h" +export MSC_GIT_TIMEOUT_DEFAULT=5s +export MSC_GIT_CHECKOUT_TIMEOUT_DEFAULT=20s export MSC_LOGLEVEL_DEFAULT="INFO" export MSC_FILELOGLEVEL_DEFAULT="DEBUG" export LOGLEVEL_DEFAULT="${MSC_LOGLEVEL_DEFAULT-INFO}" export FILELOGLEVEL_DEFAULT="${MSC_FILELOGLEVEL_DEFAULT-INFO}" +MSC_LOGLEVEL_DEFAULT="INFO" +MSC_FILELOGLEVEL_DEFAULT="DEBUG" +LOGLEVEL_DEFAULT="${MSC_LOGLEVEL_DEFAULT}" +FILELOGLEVEL_DEFAULT="${MSC_FILELOGLEVEL_DEFAULT}" diff --git a/myshell_git_sync b/myshell_git_sync index 00bdbd4..2694e95 100644 --- a/myshell_git_sync +++ b/myshell_git_sync @@ -116,13 +116,13 @@ if ! $SSHS; then else loginfo "Clone ${MSC_GIT_REMOTE} and configure git" >&2 - if $( timeout --foreground "${MSC_GIT_CHECKOUT_TIMEOUT}" \ + if $( timeout --foreground "${MSC_GIT_CHECKOUT_TIMEOUT-$MSC_GIT_CHECKOUT_TIMEOUT_DEFAULT}" \ git -C ${HOME} clone --recurse-submodules "${MSC_GIT_REMOTE}" "${MSC_BASE}" ); then : else MSC_GIT_REMOTE="${MSC_GIT_REMOTE_PUBLIC_HTTP}${MSC_GIT_REPO_NAME}" loginfo "Clone ${MSC_GIT_REMOTE} (http, because other protocol is not reachable) and configure git" >&2 - timeout --foreground "${MSC_GIT_CHECKOUT_TIMEOUT}" \ + timeout --foreground "${MSC_GIT_CHECKOUT_TIMEOUT-$MSC_GIT_CHECKOUT_TIMEOUT_DEFAULT}" \ git -C ${HOME} clone --recurse-submodules "${MSC_GIT_REMOTE}" "${MSC_BASE}" || return 1 2>/dev/null || exit 1 fi From e08bcfccfa91be97101884f5d038c933ea8addbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:18:39 +0100 Subject: [PATCH 15/25] remove duplicate lines --- defaults.conf | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/defaults.conf b/defaults.conf index 3a4b258..9f514cf 100644 --- a/defaults.conf +++ b/defaults.conf @@ -1,3 +1,4 @@ +### GIT #### export MSC_GIT_REPO_UPDATE_DEFAULT=true export MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT=48 #intervall in hours export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true @@ -6,11 +7,9 @@ export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://git.schuerz.at/github.com/" export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h" export MSC_GIT_TIMEOUT_DEFAULT=5s export MSC_GIT_CHECKOUT_TIMEOUT_DEFAULT=20s +### LOGGING ### +# Possible loglevel-values: ERROR, WARN, INFO, DEBUG, TRACE export MSC_LOGLEVEL_DEFAULT="INFO" export MSC_FILELOGLEVEL_DEFAULT="DEBUG" -export LOGLEVEL_DEFAULT="${MSC_LOGLEVEL_DEFAULT-INFO}" -export FILELOGLEVEL_DEFAULT="${MSC_FILELOGLEVEL_DEFAULT-INFO}" -MSC_LOGLEVEL_DEFAULT="INFO" -MSC_FILELOGLEVEL_DEFAULT="DEBUG" -LOGLEVEL_DEFAULT="${MSC_LOGLEVEL_DEFAULT}" -FILELOGLEVEL_DEFAULT="${MSC_FILELOGLEVEL_DEFAULT}" +export LOGLEVEL_DEFAULT="${MSC_LOGLEVEL_DEFAULT}" +export FILELOGLEVEL_DEFAULT="${MSC_FILELOGLEVEL_DEFAULT}" From 13478adf5c061e9097e877f35d4e9481dc3ce60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:19:00 +0100 Subject: [PATCH 16/25] add line to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ce0f4eb..9aa67e1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ bashrc_local .local_scripts .git-token .last_update_submodules +.last_update_repo From 2c2222557a5a8a6f6a6af44b9453f534ba13eef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:27:31 +0100 Subject: [PATCH 17/25] fix variables --- bashrc_add | 5 ++++- bin/git-myshellconfig-checkout | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bashrc_add b/bashrc_add index 033a86a..a53a366 100755 --- a/bashrc_add +++ b/bashrc_add @@ -86,10 +86,13 @@ EOF ckrepo () { # check if remote repo is reachable if [ ${MSC_GIT_SYNC-$MSC_GIT_REPO_UPDATE} -a $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ - -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-0} hours ago" "+%s") ]; then + -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") ]; then + logwarn "check if reachable" if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT ls-remote >/dev/null 2>&1) ;then + logwarn "reachable" return 0 else + logwarn "not reachable" return 1 fi else diff --git a/bin/git-myshellconfig-checkout b/bin/git-myshellconfig-checkout index 3a599e0..2191006 100755 --- a/bin/git-myshellconfig-checkout +++ b/bin/git-myshellconfig-checkout @@ -66,13 +66,13 @@ done [ -z "${MSC_GIT_UPD_REPO_STATFILE+x}" ] && export MSC_GIT_UPD_REPO_STATFILE="${MSC_BASE%/}${MSC_BASE:+/}.last_update_repo" if [ $(stat --printf %Y ${MSC_GIT_UPD_SUBMOD_STATFILE} 2>/dev/null || echo 0 ) \ - -lt $(date --date="${MSC_GIT_SUBMODULES_UPDATE_INTERVALL} 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 [ -z "${dosrepoupdate+x}" ] && dorepoupdate="true" fi if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ - -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL} hours ago" "+%s") \ + -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") \ -a ${MSC_GIT_REPO_UPDATE-${MSC_GIT_REPO_UPDATE_DEFAULT-true}} ]; then [ -z "${dosubmodupdate+x}" ] && dosubmodupdate="true" fi From cfe2f8bfaae5684dc51a07d2e3de672bd0928849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:31:05 +0100 Subject: [PATCH 18/25] fix ckrepo --- bashrc_add | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/bashrc_add b/bashrc_add index a53a366..5f403f3 100755 --- a/bashrc_add +++ b/bashrc_add @@ -85,19 +85,25 @@ EOF ckrepo () { # check if remote repo is reachable - if [ ${MSC_GIT_SYNC-$MSC_GIT_REPO_UPDATE} -a $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ + if ${MSC_GIT_SYNC-$MSC_GIT_REPO_UPDATE}; then + + 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 - logwarn "check if reachable" - if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT ls-remote >/dev/null 2>&1) ;then - logwarn "reachable" - return 0 - else - logwarn "not reachable" - return 1 + logwarn "check if reachable" + if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT ls-remote >/dev/null 2>&1) ;then + logwarn "reachable" + return 0 + else + logwarn "not reachable" + return 3 + fi + else + logwarn "sync-intervall not reached" + return 2 fi else logwarn "no sync allowed from config" >&2 - return 0 + return 1 fi } From e6de4c6796b5f5134007b7360ff8c8b6d2edd068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:32:50 +0100 Subject: [PATCH 19/25] improve output --- bashrc_add | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc_add b/bashrc_add index 5f403f3..8d6677a 100755 --- a/bashrc_add +++ b/bashrc_add @@ -98,7 +98,7 @@ EOF return 3 fi else - logwarn "sync-intervall not reached" + logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours) not reached" return 2 fi else From 580006d849d88b0fbed565ebf2e06de0c3ab36d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:55:22 +0100 Subject: [PATCH 20/25] calculate rest-time --- bashrc_add | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bashrc_add b/bashrc_add index 8d6677a..c560eb9 100755 --- a/bashrc_add +++ b/bashrc_add @@ -98,7 +98,9 @@ EOF return 3 fi else - logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours) not reached" + local seconds=$(( $(date "+%s") - $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") )) + logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours, \ + $((seconds/86400))" days" $(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds") left ) not reached" return 2 fi else From 360652a126a48531b2152e17e77232c2637eccb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:56:27 +0100 Subject: [PATCH 21/25] calculate rest-time --- bashrc_add | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bashrc_add b/bashrc_add index c560eb9..9727630 100755 --- a/bashrc_add +++ b/bashrc_add @@ -99,8 +99,7 @@ EOF fi else local seconds=$(( $(date "+%s") - $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") )) - logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours, \ - $((seconds/86400))" days" $(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds") left ) not reached" + logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours, $((seconds/86400))" days" $(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds") left ) not reached" return 2 fi else From b86946011a5e25d890d72d496fa0e1c96696f3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 13:57:52 +0100 Subject: [PATCH 22/25] calculate rest-time --- bashrc_add | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashrc_add b/bashrc_add index 9727630..b03bceb 100755 --- a/bashrc_add +++ b/bashrc_add @@ -99,7 +99,7 @@ EOF fi else local seconds=$(( $(date "+%s") - $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") )) - logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours, $((seconds/86400))" days" $(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds") left ) not reached" + logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours, $((seconds/86400)) days $(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds") left ) not reached" return 2 fi else From e95b3328dd608c966f97b00122dc3664372369f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 14:13:18 +0100 Subject: [PATCH 23/25] fix output --- bashrc_add | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bashrc_add b/bashrc_add index b03bceb..c041de1 100755 --- a/bashrc_add +++ b/bashrc_add @@ -98,8 +98,8 @@ EOF return 3 fi else - local seconds=$(( $(date "+%s") - $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") )) - logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours, $((seconds/86400)) days $(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds") left ) not reached" + local seconds=$(( $( date --date="@$(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 )" "+%s") - $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") )) + logwarn "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours) not reached yes. $((seconds/86400)) days $(date -d "1970-01-01 + $seconds seconds" "+%H hours %M minutes %S seconds") left." return 2 fi else From 46a8939e75de9f2d98846ee59d5af9a8b78c708e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 14:56:15 +0100 Subject: [PATCH 24/25] add option to force repoupdate --- bin/git-myshellconfig-checkout | 82 ++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/bin/git-myshellconfig-checkout b/bin/git-myshellconfig-checkout index 2191006..f95da3d 100755 --- a/bin/git-myshellconfig-checkout +++ b/bin/git-myshellconfig-checkout @@ -44,7 +44,11 @@ while [ $# -gt 0 ]; do PRE="${MSC_GIT_REMOTE_NAME}" shift ;; - -s|--submodules-update) + -r|--force-repo-update) + dosubmodupdate="true" + shift + ;; + -s|--force-submodules-update) dosubmodupdate="true" shift ;; @@ -68,7 +72,7 @@ done 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") \ -a ${MSC_GIT_SUBMODULES_UPDATE-${MSC_GIT_SUBMODULES_UPDATE_DEFAULT-true}} ]; then - [ -z "${dosrepoupdate+x}" ] && dorepoupdate="true" + [ -z "${dorepoupdate+x}" ] && dorepoupdate="true" fi if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ @@ -78,53 +82,55 @@ if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ fi #echo $SGIT fetch ${MSC_GIT_REMOTE_NAME} -p 1>&2 -loginfo "fetch repo${dosubmodupdate:+ and submodules}" -$SGIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarn fetch failed; gitupdateend; exit 1; } -if ${dosubmodupdate:-false}; then - lastupdatesubmodules -fi +if $dorepoupdate; then + loginfo "fetch repo${dosubmodupdate:+ and submodules}" + $SGIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarn 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 - cat << EOF >> "${MSC_LOGFILE}" - no changes in local repo - $SGIT checkout repo ${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; } - touch $MSC_GIT_UPD_REPO_STATFILE -else - logwarn -n " Lokale Änderungen festgestellt:" - echo " Siehe Logfile ${MSC_LOGFILE}" >&2 - cat << EOF >> "${MSC_LOGFILE}" - um die Änderung zurückzusetzen bitte + echo "Check for local changes:" >> "${MSC_LOGFILE}" + if $SGIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MSC_LOGFILE}" ; then + cat << EOF >> "${MSC_LOGFILE}" + no changes in local repo + $SGIT checkout repo ${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; } + touch $MSC_GIT_UPD_REPO_STATFILE + else + logwarn -n " Lokale Änderungen festgestellt:" + echo " Siehe Logfile ${MSC_LOGFILE}" >&2 + cat << EOF >> "${MSC_LOGFILE}" + um die Änderung zurückzusetzen bitte - $SGIT checkout \$FILENAME + $SGIT checkout \$FILENAME - oder um alle lokalen Änderungen auf einmal zurückzusetzen: + oder um alle lokalen Änderungen auf einmal zurückzusetzen: - $SGIT checkout . + $SGIT checkout . - ausführen + ausführen - Die Änderungen sind: - $($SGIT diff-index HEAD --|awk '{print $5, $6}') - $($SGIT diff-index -p HEAD --) + Die Änderungen sind: + $($SGIT diff-index HEAD --|awk '{print $5, $6}') + $($SGIT diff-index -p HEAD --) EOF - gitupdateend - exit 4 + gitupdateend + exit 4 -fi + fi -loginfo "repo${dosubmodupdate:+ and submodules} synced" + loginfo "repo${dosubmodupdate:+ and submodules} synced" -if ${dosubmodupdate:-false}; then - loginfo "update and commit submodules" - logdebug "$($SGIT submodule update --remote)" - logdebug "$($SGIT commit -a -m 'update submodules')" - touch $MSC_GIT_UPD_SUBMOD_STATFILE - logwarn "submodules synced" + if ${dosubmodupdate:-false}; then + loginfo "update and commit submodules" + logdebug "$($SGIT submodule update --remote)" + logdebug "$($SGIT commit -a -m 'update submodules')" + touch $MSC_GIT_UPD_SUBMOD_STATFILE + logwarn "submodules synced" + fi fi EXIT From fe333ba6eeb72ed801d5c10189810ce0205d13db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 23 Dec 2020 15:00:36 +0100 Subject: [PATCH 25/25] fix getopt --- bin/git-myshellconfig-checkout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-myshellconfig-checkout b/bin/git-myshellconfig-checkout index f95da3d..cb72aae 100755 --- a/bin/git-myshellconfig-checkout +++ b/bin/git-myshellconfig-checkout @@ -35,7 +35,7 @@ cat << EOF >> "${MSC_LOGFILE}" +-----BEGINN git update repo $(date) -------------------------------+ EOF -set -- $(getopt -u -o hs --long headless,submodules-update -- "$@" ) +set -- $(getopt -u -o hrs --long headless,force-repo-update,force-submodules-update -- "$@" ) while [ $# -gt 0 ]; do case $1 in