From: Nicolas Boisselier Date: Fri, 25 May 2018 22:51:59 +0000 (+0100) Subject: etc/cron.weekly/clean-dirs X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=315eff194c07b6a0ee4eb2d8e809cff8eb43b476;p=nb.git etc/cron.weekly/clean-dirs --- diff --git a/etc/cron.weekly/clean-dirs b/etc/cron.weekly/clean-dirs new file mode 100755 index 00000000..0b9e7a38 --- /dev/null +++ b/etc/cron.weekly/clean-dirs @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +################################################################################# +# +# NB 06.07.13 +# Delete unused files +# +# To test: touch -t '190001010000' /tmp/todel && ls -lh /tmp/todel +# +################################################################################# +DAYS="+120" +DIRS="\ +/tmp/ \ +/var/tmp/ \ +~root/tmp/ +/{home,Users}/*/tmp/ \ +/{home,Users}/*/{ownCloud,Dropbox,Google\ Drive}/tmp/ \ +/Users/*/.Trash/ \ +" + +LOCATE=" +/Thumbs.db +/ZbThumbnail.info +/.xvpics +/.DS_Store +/home/*/._ico_* +/home/share/Music/*desktop.ini +/kodi_crashlog-* +" + +################################################################################# +DEBUG=0 +LOG="/var/log/clean-dirs.log" +while [ $# -gt 0 ]; do + + case "$1" in + + -*help|-h) cat <&2 + exit 1 +fi + +[ -n "$LOG" -a "$DEBUG" = "0" ] && exec > "$LOG" + + ( + [ -n "$LOCATE" ] && which locate 1>/dev/null 2>&1 && locate $LOCATE & + if [ -n "$DIRS" -a -n "$DAYS" ]; then + eval find $DIRS -mindepth 1 -type f -mtime $DAYS + eval find $DIRS -mindepth 1 -type d -mtime $DAYS -empty -prune + fi + ) 2>/dev/null | while IFS= read -r path; do + + echo "Found: $path" + [ "$DEBUG" -gt 0 ] && continue + + rm -vr "$path" 2>/dev/null | sed 's/^/ /' + +done diff --git a/etc/cron/nb b/etc/cron/nb index d203d871..013fd8ba 100644 --- a/etc/cron/nb +++ b/etc/cron/nb @@ -3,7 +3,9 @@ # #LANG=C SHELL=/bin/bash -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/nb/bin +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +# NB 25.05.18 :/opt/nb/bin +#NB_INIT='[ -z "$NB_ROOT" ] || . /etc/profile' ##################################################################### # m h dom mon dow user command diff --git a/etc/profile.d/nb.sh b/etc/profile.d/nb.sh index dbc2ea28..519c7e92 100644 --- a/etc/profile.d/nb.sh +++ b/etc/profile.d/nb.sh @@ -101,6 +101,7 @@ nb_api_post() { curl="$curl -d \"$1\"" shift done + #echo "$curl"; return ( eval "$(eval "$curl")" #&& echo "$table: $rowCount: $args" ) @@ -108,6 +109,7 @@ nb_api_post() { nb_api_post_host_info() { local host=$(hostname) + [ -z "$*" ] && echo "Usage: nb_api_post_host_info key=? val=?" && return 1 [ -z "$host" ] && host=$(hostname -f) nb_api_post host_info "host=$host" "$@" } @@ -115,6 +117,6 @@ nb_api_post_host_info() { nb_post_sys_infos() { # To be compatible with other sed that does not support \t sys_infos | tr '\t' '!' | sed -e 's/"/\\"/g' -e 's/^/key="sys./' -e 's/!/" val="/' -e 's/$/"/' | while read -r i; do - eval nb_api_post_host_info $i + echo eval nb_api_post_host_info $i done } diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 8b5373fb..f0814e96 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -506,14 +506,19 @@ class DbQ extends nb { $row_parse_post($r,$this->table); } - public function table_rows($fct=null) { + private function table_rows($fct=null) { $this->db->limit = $this->limit(); + $ropt = [ + 'html_menu' => empty($this->_nopage), + ]; + #if (!empty($this->_nopage)) $this->db-> $this->row_parse_pre(); $this->row_parse_post(); $opt = ($this->page->is('html') and $this->table_rw() + and empty($this->_nopage) ) ? [ 'row_parse_pre' => function(&$r){ $this->row_parse_pre($r); @@ -550,7 +555,7 @@ class DbQ extends nb { ] : []; $this->db()->__construct($opt); - $this->table->rows(); + $this->table->rows($ropt); } private function ar_unshift( array & $array, $key, $val) {