#
##############################################################################
main() {
-# NB 13.12.16 . "${BASH_SOURCE%/*}/../etc/profile" || exit
-. $(dirname "$0")/../etc/profile || exit 1; [ -z "$NB_ROOT" ] && exit
-NAME="$(basename "${0}")"
-TMP=/tmp/$NAME.$$
-INSTALL="rsync --archive --checksum --force"
-BY="Generated by $0"
-
-if [ "$UID" != "0" ] ; then
- echo "$NAME: please login as root." 1>&2
- exit 1
-fi
+ # NB 13.12.16 . "${BASH_SOURCE%/*}/../etc/profile" || exit
+ . $(dirname "$0")/../etc/profile || exit 1; [ -z "$NB_ROOT" ] && exit
+ NAME="$(basename "${0}")"
+ TMP=/tmp/$NAME.$$
+ INSTALL="rsync --archive --checksum --force"
+ BY="Generated by $0"
+
+ if [ "$UID" != "0" ] ; then
+ echo "$NAME: please login as root." 1>&2
+ exit 1
+ fi
-##############################################################################
-#
-# Args
-#
-##############################################################################
-case "$@" in *-h*|*-help*) exec echo "Usage: $NAME [-v] [-n]";; esac
-case "$@" in *-v*) INSTALL="$INSTALL -v";; esac
-case "$@" in *-n*) INSTALL="$INSTALL -n";; esac
-if ! which rsync >/dev/null; then
- INSTALL="cp -a"
+ ##############################################################################
+ #
+ # Args
+ #
+ ##############################################################################
+ case "$@" in *-h*|*-help*) exec echo "Usage: $NAME [-v] [-n]";; esac
case "$@" in *-v*) INSTALL="$INSTALL -v";; esac
- case "$@" in *-n*) INSTALL="echo DRY:";; esac
-fi
+ case "$@" in *-n*) INSTALL="$INSTALL -n";; esac
+ if ! which rsync >/dev/null; then
+ INSTALL="cp -a"
+ case "$@" in *-v*) INSTALL="$INSTALL -v";; esac
+ case "$@" in *-n*) INSTALL="echo DRY:";; esac
+ fi
-##############################################################################
-#
-# Functions
-#
-##############################################################################
-verbose() {
- [ -z "$@" ] && return
- printf '> %s\n' "$@"
-}
+ ##############################################################################
+ #
+ # Functions
+ #
+ ##############################################################################
+ verbose() {
+ [ -z "$@" ] && return
+ printf '> %s\n' "$@"
+ }
+
+ fdiff() {
+ [ -e "$1" ] || return 0
+ [ -e "$2" ] || return 0
+ [ -n "$(diff -q $1 $2 2>/dev/null)" ] && return 0
+ return 1
+ }
+
+ ##############################################################################
+ #
+ # Cron
+ #
+ if [ -e /etc/nb/cron.no ]; then
+ rm -f /etc/cron.d/nb /var/log/nb.log
+ else
+ #shell_help_noarg "zaza" "$@" && exit 0
+ cron_d_install "$NB_ROOT/etc/cron/nb" "nb-update|$NB_ROOT|NB_LOG" && verbose "Cron: $NB_ROOT/etc/cron/nb"
+ #cron_d_install "test" "" "nico.*true" && verbose "Cron: nico"
+ fi
-fdiff() {
- [ -e "$1" ] || return 0
- [ -e "$2" ] || return 0
- [ -n "$(diff -q $1 $2 2>/dev/null)" ] && return 0
- return 1
-}
+ #
+ # Profile
+ #
+ echo "[ -r $NB_ROOT/etc/profile ] && . $NB_ROOT/etc/profile" > $TMP.profile
+ if [ -d /etc/profile.d ]; then
-##############################################################################
-#
-# Cron
-#
-if [ -e /etc/nb/cron.no ]; then
- rm -f /etc/cron.d/nb /var/log/nb.log
-else
- #shell_help_noarg "zaza" "$@" && exit 0
- cron_d_install "$NB_ROOT/etc/cron/nb" "nb-update|$NB_ROOT|NB_LOG" && verbose "Cron: $NB_ROOT/etc/cron/nb"
- #cron_d_install "test" "" "nico.*true" && verbose "Cron: nico"
-fi
+ if fdiff $TMP.profile /etc/profile.d/nb.sh 1>/dev/null 2>&1; then
+ verbose "Install /etc/profile.d/nb.sh"
+ $INSTALL $TMP.profile /etc/profile.d/nb.sh
+ chmod 755 /etc/profile.d/nb.sh
+ fi
-#
-# Profile
-#
-echo "[ -r $NB_ROOT/etc/profile ] && . $NB_ROOT/etc/profile" > $TMP.profile
-if [ -d /etc/profile.d ]; then
+ elif [ -w /etc/profile ]; then
- if fdiff $TMP.profile /etc/profile.d/nb.sh 1>/dev/null 2>&1; then
- verbose "Install /etc/profile.d/nb.sh"
- $INSTALL $TMP.profile /etc/profile.d/nb.sh
- chmod 755 /etc/profile.d/nb.sh
- fi
+ grep -vF "$NB_ROOT/etc/profile.sh" /etc/profile > $TMP.clean
+ if fdiff /etc/profile $TMP.clean; then
+ verbose "Clean /etc/profile"
+ cat $TMP.clean > /etc/profile
+ fi
-elif [ -w /etc/profile ]; then
+ if ! grep -qm1 -F "$(cat $TMP.profile)" /etc/profile; then
+ verbose "Install /etc/profile"
+ cat $TMP.profile >> /etc/profile
+ fi
- grep -vF "$NB_ROOT/etc/profile.sh" /etc/profile > $TMP.clean
- if fdiff /etc/profile $TMP.clean; then
- verbose "Clean /etc/profile"
- cat $TMP.clean > /etc/profile
- fi
+ else
+ echo "Can't install /etc/profile. Directory not exists or wrong permission" 1>&2
- if ! grep -qm1 -F "$(cat $TMP.profile)" /etc/profile; then
- verbose "Install /etc/profile"
- cat $TMP.profile >> /etc/profile
fi
-else
- echo "Can't install /etc/profile. Directory not exists or wrong permission" 1>&2
+ #
+ # Specifics
+ #
+ chmod 755 $NB_ROOT/etc/vim/vim* $NB_ROOT/etc/vim/*.sh $NB_ROOT/etc/vim/*.pl $NB_ROOT/etc/vim/vimplate-dump
-fi
+ #
+ # Log
+ #
+ NB_USER=`(ls -dl $NB_ROOT 2>/dev/null || printf '- 0 root') | awk '{print $3}'`
+ verbose $(chown "$NB_USER" /var/log/nb.log 2> /dev/null)
-#
-# Specifics
-#
-chmod 755 $NB_ROOT/etc/vim/vim* $NB_ROOT/etc/vim/*.sh $NB_ROOT/etc/vim/*.pl $NB_ROOT/etc/vim/vimplate-dump
+ #
+ # nb-commit
+ #
+ cd "$NB_ROOT" || exit
-#
-# Log
-#
-NB_USER=`(ls -dl $NB_ROOT 2>/dev/null || printf '- 0 root') | awk '{print $3}'`
-verbose $(chown "$NB_USER" /var/log/nb.log 2> /dev/null)
+ rm -f .git/hooks/pre-push
-#
-# nb-commit
-#
-cd "$NB_ROOT" || exit
-rm -v .git/hooks/pre-push
-if [ ! -e .git/hooks/pre-push -a -w .git/hooks ]; then
- echo "Create .git/hooks/pre-push"
- cat <<EOF > .git/hooks/pre-push
+ if [ -w .git/hooks ]; then
+
+ #echo "Create .git/hooks/pre-push"
+ cat <<EOF > .git/hooks/pre-commit
#!/bin/sh
-echo Git hooks pre-push $* 1>&2
+echo Git hooks pre-commit $* 1>&2
$([ -e www/dbq/update.sh ] && echo www/dbq/update.sh)
EOF
- chmod 755 .git/hooks/pre-push
- chown "$NB_USER" .git/hooks/pre-push
-fi
-#
-# Bye
-#
-rm -f $TMP*
-exit 0
+ chmod 755 .git/hooks/pre-commit
+ chown "$NB_USER" .git/hooks/pre-commit
+
+ fi
+
+ #
+ # Bye
+ #
+ rm -f $TMP*
+ exit 0
}
main
if ($password=='') $password = $this->params['table'];
if ($password=='' and !empty($_POST['password'])) $password = $_POST['password'];
if ($this->is_html) echo <<<EOF
-<form action="$this->uri" method="post">
+<form action="$this->uri" method="post" class="block" style="padding:1.5em">
<label>Password</label><input type="text" name="password" value="$password" />
<input type="submit" />
</form>
$r['command'] = $this->page->tag('a',$r['command'],'href="'
.$this->db->base.'/'.($r['command'] == self::PARAM_DB_DEFAULT
? ''
- : $r['command'].'.'.$this->ext
+# NB 25.05.17 : $r['command'].'.'.$this->ext
+ : $r['command']
)
.'"');
});
} elseif ($action == 'ls') {
#$this->params += [ 'db' => '', 'table' => '', 'action' => '' ];
#$this->params = array_merge($this->params,[ 'db' => '', 'table' => '', 'action' => '' ]);
+
$this->page($this->db,'ls',[],function(&$r){
- $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.'/'.$r['id'].'.'.$this->ext.'"');
+# NB 25.05.17 $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.'/'.$r['id'].'.'.$this->ext.'"');
+ $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.'/'.$r['id'].'"');
});
} elseif ($action == 'logout') {