diff --git a/README.md b/README.md index 49522d6848..bd1cc124c8 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ cron [list|add|delete|deleteall] adds, deletes a custom cron job or del usb [on|off] turns usb ports on or off remote [check|status|upgrade|services] helps with treehouses remote android app [version|commands|allservices] -log <0|1|2|3|4|show|max> gets/sets log level and shows log +log [0|1|2|3|4|show|max|ram [on|off]] gets/sets log level and shows log blocker <0|1|2|3|4||max> website blocking levels using /etc/hosts sdbench displays read and write speed of micro SD card inspire [joke|qotd|random] displays quote based on user input diff --git a/_treehouses b/_treehouses index 69c0532252..7b7220f7bd 100644 --- a/_treehouses +++ b/_treehouses @@ -198,6 +198,9 @@ treehouses log 4 treehouses log max treehouses log show treehouses log show 5 +treehouses log ram +treehouses log ram on +treehouses log ram off treehouses memory treehouses memory -g treehouses memory -m diff --git a/modules/help.sh b/modules/help.sh index 4a5ba7100e..500ccab910 100644 --- a/modules/help.sh +++ b/modules/help.sh @@ -95,7 +95,7 @@ Usage: treehouses usb [on|off] turns usb ports on or off remote [check|status|upgrade|services] helps with treehouses remote android app [version|commands|allservices] - log <0|1|2|3|4|show|max> gets/sets log level and shows log + log [0|1|2|3|4|show|max|ram [on|off]] gets/sets log level and shows log blocker <0|1|2|3|4||max> website blocking levels using /etc/hosts sdbench displays read and write speed of micro SD card inspire [joke|qotd|random] displays quote based on user input diff --git a/modules/log.sh b/modules/log.sh index bf09e7c09e..6237c3b50e 100644 --- a/modules/log.sh +++ b/modules/log.sh @@ -1,3 +1,25 @@ +function log2ram { + checkrpi + checkargn $# 1 + if [ "$1" = "" ]; then + if [[ $(df -h) != *"log2ram"* ]]; then + echo "log2ram is off" + else + echo "log2ram is on" + fi + elif [ "$1" = "on" ]; then + if [[ $(log2ram) = *off* ]]; then + command log2ram start + fi + echo "Successfully started log2ram" + elif [ "$1" = "off" ]; then + command log2ram stop + echo "Sucessfully stopped log2ram" + else + log_and_exit1 "Error: only '', 'on', and 'off' options supported" + fi +} + # uses logger command to log to /var/log/syslog # logit "text" "whether or not to write to screen" "logging level" # e.g. logit "i logged some text" @@ -105,6 +127,9 @@ function log { LOG=max logit "log X: level set to max" "" "DEBUG" ;; + "ram") + log2ram "$2" + ;; *) log_and_exit1 "Error: only '0' '1' '2' '3' '4' 'show' 'max' options are supported" ;; @@ -114,7 +139,7 @@ function log { function log_help { echo - echo "Usage: $BASENAME log <0|1|2|3|4|show|max>" + echo "Usage: $BASENAME log [0|1|2|3|4|show|max|ram [on|off]]" echo echo "Example:" echo " $BASENAME log" @@ -146,4 +171,16 @@ function log_help { echo " $BASENAME log max" echo " log X: level set to max" echo + echo " $BASENAME log ram" + echo " log2ram is off" + echo " force logs to be stored in ram and only writes to disk on shutdown" + echo " https://github.com/azlux/log2ram" + echo " Stores logs in 40M (Megabytes) in mount point in memory" + echo + echo " $BASENAME log ram on" + echo " Successfully started log2ram" + echo + echo " $BASENAME log ram off" + echo " Successfully stopped log2ram" + echo }