From 23a1e2fbaba52bc57e110f46a01008d73328bc63 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 19 Feb 2015 22:56:15 +0000 Subject: [PATCH] Update other repo, function git create --- bin/nb-update | 26 ++++++++++++++++++++++++++ etc/bashrc.function | 35 ++++++++++++++++++++++++++++++++--- etc/cron/nb | 5 +++-- 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/bin/nb-update b/bin/nb-update index 0e6faedb..0a5aaa4c 100755 --- a/bin/nb-update +++ b/bin/nb-update @@ -1,14 +1,40 @@ #!/usr/bin/env bash +##################################################################### +# +# Call by cron/etc/nb +# +##################################################################### + . "${BASH_SOURCE%/*}/../etc/profile.sh" || exit declare -r NAME="$(basename "${0}")" ##################################################################### # Git pull # +echo ">git pull $NB_ROOT" cd $NB_ROOT || exit git pull ##################################################################### # Install # +echo ">nb-install" nb-install + +##################################################################### +# Others git repos from nbdom +# +for repo in \ + /etc/puppet/data \ +; do + [ -d "$repo/.git" ] || continue + cd "$repo" || continue + + echo ">git pull $repo" + git pull +done + +##################################################################### +# End +# +echo ">OK" diff --git a/etc/bashrc.function b/etc/bashrc.function index 20643597..778bee52 100644 --- a/etc/bashrc.function +++ b/etc/bashrc.function @@ -24,18 +24,44 @@ case "$OSTYPE" in darwin*) esac +# NB 19.02.15 root@pi:puppet# nb-git-create puppet/data +# NB 19.02.15 Initialized empty Git repository in /home/git/puppet/data.git/ +# NB 19.02.15 Cloning into 'data'... +# NB 19.02.15 warning: You appear to have cloned an empty repository. +# NB 19.02.15 Got to directory: data +# NB 19.02.15 Reinitialized existing Git repository in /etc/puppet/data/.git/ +# NB 19.02.15 [master (root-commit) 3ea2a65] Created by nb-git-create +# NB 19.02.15 1 file changed, 7 insertions(+) +# NB 19.02.15 create mode 100644 README.md +# NB 19.02.15 Counting objects: 3, done. +# NB 19.02.15 Compressing objects: 100% (2/2), done. +# NB 19.02.15 Writing objects: 100% (3/3), 272 bytes, done. +# NB 19.02.15 Total 3 (delta 0), reused 0 (delta 0) +# NB 19.02.15 To git@git.nbdom.net:puppet/data.git +# NB 19.02.15 * [new branch] master -> master +# NB 19.02.15 Branch master set up to track remote branch master from origin. +# NB 19.02.15 fatal: remote origin already exists. +# NB 19.02.15 Branch master set up to track remote branch master from origin. +# NB 19.02.15 Everything up-to-date function nb-git-create() { declare name="${1%.git}" declare dir=$(basename $name) declare repo='git@git.nbdom.net' - [ -e "$dir" ] && echo "$dir already exists!" 1>&2 && return 1 + + # + # Check, create repo on server + # + [ -e "$dir" ] && echo ">$dir already exists!" 1>&2 && return 1 ssh git@git.nbdom.net "git init --bare ${name}.git" || return git clone $repo:${name}.git || return - echo "Got to directory: $dir" + echo ">Got to directory: $dir" cd $dir || return + # + # Create files + # echo "$name ============= @@ -43,12 +69,15 @@ function nb-git-create() { DESCRIPTION " > README.md + + # + # Update repo + # git init git add * git commit -m "Created by $FUNCNAME" git push --set-upstream origin master git remote add origin $repo:${name}.git - git push -u origin master } function nb-git-clone() { diff --git a/etc/cron/nb b/etc/cron/nb index 57bee986..bdc742df 100644 --- a/etc/cron/nb +++ b/etc/cron/nb @@ -4,9 +4,10 @@ #LANG=C SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/nb/bin +NB_LOG=/var/log/nb.log ##################################################################### # m h dom mon dow user command # -*/15 9-00 * * * root nb-update &>/dev/null -*/60 00-08 * * * root nb-update &>/dev/null +*/15 9-00 * * * root nb-update &>$NB_LOG +*/60 00-08 * * * root nb-update &>$NB_LOG -- 2.47.3