]> git.nbdom.net Git - nb.git/commitdiff
nb-update, profile.d
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 7 Jul 2015 00:24:27 +0000 (01:24 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 7 Jul 2015 00:24:27 +0000 (01:24 +0100)
bin/nb-install
bin/nb-update
etc/bashrc.function
etc/profile
lib/php/cache.php
lib/php/test.php

index c8bf12f1adae5dc5c846c5fb7c84d80bfbe2d255..1efe8fe776ca02f6f4bd60955a54f8f8f50bf36b 100755 (executable)
@@ -46,9 +46,8 @@ else
   crontab -l > $TMP.crontab.orig.orig
   (
     # Delete user
-    perl -ane '/^(NB_LOG|SHELL|PATH)/ and print; /^[\*\d]/ or next; print join(" ",@F[0..4,6..$#F])."\n"' $NB_ROOT/etc/cron/nb
-    #perl -ane '/^\s*(#|$)/ and next; print ( scalar(@F>7) ? $_ : join(" ",@F[0..4,6..$#F])."\n" ); BEGIN{print "#>NB\n"} ;END {print "#<NB\n"}' $src
     crontab -l | grep -vE 'nb-update|^(PATH|NB_LOG|SHELL|#[<>]nb)'
+    perl -ane '/^(NB_LOG|SHELL|PATH)/ and print; /^[\*\d]/ or next; print join(" ",@F[0..4,6..$#F])."\n"' $NB_ROOT/etc/cron/nb
   ) > $TMP.crontab.orig.new
 
   if fdiff $TMP.crontab.orig.orig $TMP.crontab.orig.new; then
index 4a9dc3b8b7b4eeefb76083263c4147c06b3ed151..144f3edcedb70231f6e100443ed4c75b78a7c590 100755 (executable)
@@ -15,15 +15,21 @@ for repo in \
   $NB_ROOT \
   /opt/backup_servers \
   /{opt,home/www}/rent \
-  /etc/puppet \
+  root:/etc/puppet \
   /etc/puppet/data \
   /etc/puppet/modules \
   /home/www/izideal \
 ; do
+
+  case "$repo" in
+    *:*) user=${repo%%:*}; repo=${repo#*:} ;;
+    *) user="" ;;
+  esac
+
   [ -d "$repo/.git" ] || continue
   cd "$repo" || continue
 
-  user=`ls -dl "$repo" |awk '{print $3}'`
+  [ -z "$user" ] && user=`ls -dl "$repo" |awk '{print $3}'`
   echo ">git pull $repo (user=$user)"
 
   if [ "$USER" == "$user" ]; then
@@ -31,8 +37,11 @@ for repo in \
   else
     su $user -c "cd \"$repo\" && git pull"
   fi
+
   ret=$?
-  [ "$ret" != "0" ] && ex=$ret
+  [ "$ret" != "0" ] && ex=$ret && echo ">err $ret"
+
+  echo
 
 done
 
@@ -45,5 +54,5 @@ nb-install
 #####################################################################
 # End
 #
-[ "$ex" == "0" ] && echo ">OK"
+[ "$ex" == "0" ] && printf "\n>OK\n"
 exit $ex
index 3f26d4c0ad1a5653646222c79e0604b74ce6543b..7ac86ac3638dfb374300726d07052442169975d9 100644 (file)
@@ -364,11 +364,12 @@ Choose one > \
 # NB 06.07.15 }
 
 replace_tag_content() {
-  local tag="$1" content="$@"
+  declare tag="$1"; shift
+  declare content="$@"
   perl -ne 'BEGIN {
-$tag = shift @ARGV;
-$t1 = "# > $tag";
-$t2 = "# < $tag";
+$tag = shift(@ARGV)." - replace_tag_content";
+$t1 = "# >>> $tag";
+$t2 = "# <<< $tag";
 $content = shift @ARGV;
 $content = "$t1\n$content\n$t2\n"
 }
@@ -376,8 +377,7 @@ $content = "$t1\n$content\n$t2\n"
 if (/^$t1$/ .. /^$t2$/) {
   print "$content" and $content="" if /^$t1$/;
 } else {
-  #$_ = "OUT $_"; 
-  print "OUT $_"; 
+  print "$_"; 
 }
 
 END { print "$content" if $content; }
index 3883f93d2ebfe956d52bc5971271c62c80a79629..371345a0154457f30d0bbcc0bdddb413640906a1 100644 (file)
@@ -2,7 +2,7 @@
 [ -r "${BASH_SOURCE%/*}/bashrc" ] && . "${BASH_SOURCE%/*}/bashrc"
 [ -r "${BASH_SOURCE%/*}/aliases" ] && . "${BASH_SOURCE%/*}/aliases"
 
-for i in $NB_ROOT/etc/*.sh; do
+for i in ${BASH_SOURCE%/*}/profile.d/*.sh; do
   [ -r "$i" ] && . "$i"
 done
 unset i
index 64a727b4ef3ed74823894366007c817144879535..90f1bbaae786e61fd0bec8eafa87c3c9704203b0 100644 (file)
@@ -8,6 +8,7 @@ function cache_get_file($id,$expires) {
   if (!file_exists($file)) return null;
 
   $content = file_get_contents($file);
+
   if ( filectime($file) < (time()-$expires) ) @unlink($file);
 
   return $content;
index 68c0fb41be2aeb31bcbb651bfc4d7fab4a22092c..2fff54c07426d004fd97f40f4bd928c6d3eda36e 100644 (file)
@@ -18,21 +18,25 @@ exit;
 */
 
 function _f1() {
-  $var = ''; is_null($var);
+  $_REQUEST['zaza'] === null;
 } benchmark('_f1');
 
 function _f2() {
-  $var = ''; empty($var);
+  $_REQUEST['zaza'] == null;
 } benchmark('_f2');
 
 function _f3() {
-  $var = ''; isset($var);
+  @$_REQUEST['zaza'];
 } benchmark('_f3');
 
 function _f4() {
-  stripos('zaza', 'z') == ( strlen('zaza')-strlen('z') );
+  isset($_REQUEST['zaza']);
 } benchmark('_f4');
 
+function _f5() {
+  !empty($_REQUEST['zaza']);
+} benchmark('_f5');
+
 benchmark();
 exit;