export NB_DB=nb
nb_repos_commit_push() {
- shell_help "Commit each repos whith a comment" "$@" && return
- local status
- local pwd=`pwd`
- for i in $(nb_repos); do
- cd "$i" || continue
+ shell_help "Commit each repos whith a comment" "$@" && return
+ local status
+ local pwd=`pwd`
+ for i in $(nb_repos); do
+ cd "$i" || continue
- printf ">%s\n" "$i"
- (
- git commit --all --no-status --quiet --message "$*" && git push
- ) 2>&1 \
- | grep -vE '^(On branch master|Your branch is up-to-date|nothing to commit)' \
- | sed 's/^/ /'
+ printf ">%s\n" "$i"
+ (
+ git commit --all --no-status --quiet --message "$*" && git push
+ ) 2>&1 \
+ | grep -vE '^(On branch master|Your branch is up-to-date|nothing to commit)' \
+ | sed 's/^/ /'
- done
- cd "$pwd"
+ done
+ cd "$pwd"
}
nb_repos_status() {
- shell_help "List repos git status" "$@" && return
- local status
- local pwd=`pwd`
- local i
- local ret=0
- for i in $(nb_repos); do
- cd "$i" || continue
+ shell_help "List repos git status" "$@" && return
+ local status
+ local pwd=`pwd`
+ local i
+ local ret=0
+ for i in $(nb_repos); do
+ cd "$i" || continue
- status=$(git status --short "$i"|sed 's/^/ /')
- [ -n "$status" ] && status=$'\n'"$status" && ret=1
+ status=$(git status --short "$i"|sed 's/^/ /')
+ [ -n "$status" ] && status=$'\n'"$status" && ret=1
- printf "%s %s\n" "$i" "$status"
- done
- cd "$pwd"
- return $ret
+ printf "%s %s\n" "$i" "$status"
+ done
+ cd "$pwd"
+ return $ret
}
nb_mails() {
- printf '| 1-$ cat\nx\n' | mail | perl -MDate::Manip -MEncode -ne '
+ printf '| 1-$ cat\nx\n' | mail | perl -MDate::Manip -MEncode -ne '
BEGIN {
- $SIG{__WARN__} = sub{ };
- "'"$LANG $LC_ALL $LC_CTYPE"'" =~ /yes/ and binmode STDOUT, ":utf8";
+ $SIG{__WARN__} = sub{ };
+ "'"$LANG $LC_ALL $LC_CTYPE"'" =~ /yes/ and binmode STDOUT, ":utf8";
}
$. == 2 and print;
/^From / .. /^$/ or next;
chomp;
if ($_ eq "") {
- $h{From} =~ s/^.*?([^<\s]+@[^\s>]+).*?$/$1/;
- $h{Date} = &UnixDate($h{Date},"%Y-%m-%d %H:%M");
- $h{Subject} = decode("MIME-Header",$h{Subject});
- push(@m,[
- $h{Date},
- $h{From},
- $h{Subject},
- ]);
- %h = ();
- next;
+ $h{From} =~ s/^.*?([^<\s]+@[^\s>]+).*?$/$1/;
+ $h{Date} = &UnixDate($h{Date},"%Y-%m-%d %H:%M");
+ $h{Subject} = decode("MIME-Header",$h{Subject});
+ push(@m,[
+ $h{Date},
+ $h{From},
+ $h{Subject},
+ ]);
+ %h = ();
+ next;
}
/^(Date|Subject|From): (.*)$/ and $h{$1} = $2;
END { print map {sprintf "%s | %s | %s\n",@$_;} sort {$b->[1] cmp $a->[1]} @m }
'
#/var/spool/mail/$USER
- #printf 'f *\nx\n' | mail | perl -e '@_=<>; shift @_; print shift @_; print reverse @_'
+ #printf 'f *\nx\n' | mail | perl -e '@_=<>; shift @_; print shift @_; print reverse @_'
}
nb_rb() {
- ruby -r$NB_ROOT/lib/ruby/nb.rb -e "$@"
+ ruby -r$NB_ROOT/lib/ruby/nb.rb -e "$@"
}
nb_perl() {
- ruby -r$NB_ROOT/lib/perl/NB -e "$@"
+ ruby -r$NB_ROOT/lib/perl/NB -e "$@"
}
nb_api_post() {
- local usage="Usage: nb_api_post TABLE field1=val1 field2=val2 ..."
- local table="${1:?$usage}"; shift
+ local usage="Usage: nb_api_post TABLE field1=val1 field2=val2 ..."
+ local table="${1:?$usage}"; shift
- local host=$(hostname)
- [ -z "$host" ] && host=$(hostname -f)
+ local host=$(hostname)
+ [ -z "$host" ] && host=$(hostname -f)
- local curl="curl -su nb:0TXARcQUpjHZctoROA2X.weWSZKM5DGT -H 'Accept: application/x-sh' https://api.nbdom.net/data/$table/replace -d host=$host"
+ local curl="curl -su nb:0TXARcQUpjHZctoROA2X.weWSZKM5DGT -H 'Accept: application/x-sh' https://api.nbdom.net/data/$table/replace -d host=$host"
- while [ "$#" -gt "0" ]; do
- curl="$curl -d \"$1\""
- shift
- done
- (
- eval "$curl"
- ) > /dev/null
+ while [ "$#" -gt "0" ]; do
+ curl="$curl -d \"$1\""
+ shift
+ done
+ (
+ eval "$curl"
+ ) > /dev/null
}
nb_post_sys_infos() {
- (
- sys_infos | sed -e 's/"/\\"/g' -e 's/^/key="sys./' -e 's/\t/" val="/' -e 's/$/"/' | while read -r i; do
- eval nb_api_post host_info $i
- done
- )
+ sys_infos | sed -e 's/"/\\"/g' -e 's/^/key="sys./' -e 's/\t/" val="/' -e 's/$/"/' | while read -r i; do
+ eval nb_api_post host_info $i
+ done
}