From 369f104443bce5ee27323b1d2994dbc436971656 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sat, 7 Jan 2017 20:03:17 +0000 Subject: [PATCH] nb-commit --- bin/nb-commit | 16 ++++++++++++++++ etc/profile | 4 ++++ share/db/update.sh | 14 ++++++++------ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100755 bin/nb-commit diff --git a/bin/nb-commit b/bin/nb-commit new file mode 100755 index 00000000..b1ced227 --- /dev/null +++ b/bin/nb-commit @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +##################################################################### +# +# Compile, update source code +# Called by cron/etc/nb +# +##################################################################### +set -e +. $(dirname "$0")/../etc/profile || exit 1; [ -z "$NB_ROOT" ] && exit + +cd $NB_ROOT || exit + +share/db/update.sh + +which docker 1> /dev/null && docker run --rm -v $NB_ROOT:$NB_ROOT alpine sh -c "(. $NB_ROOT/etc/profile && nb_repos) >/dev/null && echo Docker: OK" + diff --git a/etc/profile b/etc/profile index 7ef448bc..0fac7cb1 100755 --- a/etc/profile +++ b/etc/profile @@ -1,8 +1,12 @@ +#-------------------------------------------------------------------------------- # # etc/profile # +# To test: # docker run --rm -it -v $NB_ROOT:$NB_ROOT alpine sh -c " . $NB_ROOT/etc/profile --debug && nb_repos && echo OK" # +# +#-------------------------------------------------------------------------------- [ "$1" = "--debug" ] && export NB_DEBUG="echo DEBUG: " && shift # diff --git a/share/db/update.sh b/share/db/update.sh index 807cc977..6d96a769 100755 --- a/share/db/update.sh +++ b/share/db/update.sh @@ -1,21 +1,23 @@ #!/usr/bin/env bash --login set -e cd "$(dirname "$0")" - -echo "Update sys.shell_function" - ( cat << EOF PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; -EOF -shell_functions2sql shell_function +SELECT 'Update sys.shell_function'; +`shell_functions2sql shell_function` -cat << EOF COMMIT; EOF ) | sqlite3 sys.db +IFS=$'\n' +for f in $(grep -lrI SHELL_REPLACE $NB_ROOT); do + + echo "Update $f" + shell_replace -i "$f" +done -- 2.47.3