--- /dev/null
+#!/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 <<EOF
+Usage: clean-dirs [OPTIONS]
+-h --help This help
+-d --debug Dont delete anything
+-l --log [FILE] Write to log file
+-c --conf [FILE] Load shell config file
+EOF
+ exit
+ ;;
+ --debug|-d) DEBUG=$(($DEBUG+1)) ;;
+ --log|-l) shift; LOG=$1 ;;
+ --conf|-c) shift; . "$1" || exit ;;
+
+ *) exec $0 -h ;;
+
+ esac
+ shift
+
+done
+
+if [ -z "$DIRS" -a -z "$LOCATE" ]; then
+ echo "Envs DIRS and LOCATE undefined. See $0 --help" 1>&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
#
#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
curl="$curl -d \"$1\""
shift
done
+ #echo "$curl"; return
(
eval "$(eval "$curl")" #&& echo "$table: $rowCount: $args"
)
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" "$@"
}
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
}
$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);
] : [];
$this->db()->__construct($opt);
- $this->table->rows();
+ $this->table->rows($ropt);
}
private function ar_unshift( array & $array, $key, $val) {