From 40a93147bf637690585fef41d6c8801dd1b1dfb9 Mon Sep 17 00:00:00 2001 From: "c.magyar" Date: Fri, 8 Dec 2017 23:24:59 -0600 Subject: [PATCH] more detailed status action --- README.html | 8 +++++--- README.rst | 8 +++++--- lib/man/ramroot.8 | 8 +++++--- ramroot | 24 +++++++++++++++++++----- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/README.html b/README.html index 7cc94aa..11ddeb1 100644 --- a/README.html +++ b/README.html @@ -607,8 +607,10 @@

Actions

Disable ramroot. Remove build and runtime hooks from /usr/lib/initcpio.
status
-
Print ramroot status to screen. -Return exit status 2 if not enabled.
+
Print ramroot and root filesystem status to screen. +Return exit status 0 if enabled and currently loaded to RAM. +Return exit status 1 if enabled and not loaded RAM. +Return exit status 2 if disabled.
@@ -686,7 +688,7 @@

Credits

Author:Chris Magyar -Version:1.1.6 +Version:1.1.7 License:GPL 3.0 diff --git a/README.rst b/README.rst index ff92633..b8e2c7b 100644 --- a/README.rst +++ b/README.rst @@ -81,8 +81,10 @@ Action performed by ramroot; one must be specified. Remove build and runtime hooks from */usr/lib/initcpio*. ``status`` - Print ramroot status to screen. - Return exit status 2 if not enabled. + Print ramroot and root filesystem status to screen. + Return exit status 0 if enabled and currently loaded to RAM. + Return exit status 1 if enabled and not loaded RAM. + Return exit status 2 if disabled. Options @@ -181,7 +183,7 @@ by several inquisitive `forum posts`_. Chris Magyar :Version: - 1.1.6 + 1.1.7 :License: GPL 3.0 diff --git a/lib/man/ramroot.8 b/lib/man/ramroot.8 index 9e0e833..30e75fb 100644 --- a/lib/man/ramroot.8 +++ b/lib/man/ramroot.8 @@ -1,4 +1,4 @@ -.TH RAMROOT 8 "December 2017" "ramroot 1.1.6" "Ramroot Manual" +.TH RAMROOT 8 "December 2017" "ramroot 1.1.7" "Ramroot Manual" .SH NAME ramroot \- load root filesystem entirely to RAM during boot .SH SYNOPSIS @@ -49,8 +49,10 @@ Disable \fBramroot\fR. Remove build and runtime hooks from .TP \fBstatus\fR .br -Print \fBramroot\fR status to screen. -Return exit status 2 if not enabled. +Print \fBramroot\fR and root filesystem status to screen. +Return exit status 0 if enabled and currently loaded to RAM. +Return exit status 1 if enabled and not loaded RAM. +Return exit status 2 if disabled. .SH OPTIONS .TP \fB\-b\fR, \fB\-\-boot\fR <\fIUUID\fR> diff --git a/ramroot b/ramroot index 51e1076..f23087f 100755 --- a/ramroot +++ b/ramroot @@ -2,7 +2,7 @@ ##============================== ramroot ===============================## # Copyright (C) 2018 Chris Magyar GNU General Public License v3 # ##========================================================================## -version="1.1.6" +version="1.1.7" print_help() { cat <<'HELPDOC' @@ -29,8 +29,10 @@ ACTIONS Remove build and runtime hooks from /usr/lib/initcpio. status - Print ramroot status to screen. - Return exit status 2 if not enabled. + Print ramroot and root filesystem status to screen. + Return exit status 0 if enabled and currently loaded to RAM. + Return exit status 1 if enabled and not loaded RAM. + Return exit status 2 if disabled. OPTIONS -b, --boot UUID @@ -179,7 +181,7 @@ ramroot_enable() { # incognito mode: if [ "$incognitoMode" = 'true' ]; then sed -i '73i\ echo -e "\\e[0;30m"; clear' hooks/ramroot - sed -i '114i\ echo -e "\\E[H\\E[2J\\E[0;30m\\E[?1c" \\' \ + sed -i '114i\ echo -e "\\033[H\\033[2J\\033[0;30m\\033[?1c" \\' \ hooks/ramroot sed -i '115i\ > /zram_root/etc/issue' hooks/ramroot sed -i '116i\ chmod +x /zram_root/etc/issue' hooks/ramroot @@ -362,14 +364,26 @@ ramroot_remove() { ##======================== ramroot_status() ========================## # Print ramroot installation status to screen. ramroot_status() { + # print root filesystem status: + root_stat() { + if (lsblk | grep -P 'zram.*?/ ?$' >/dev/null); then + printf ":: root filesystem loaded to RAM\n" + else + printf ":: root filesystem not loaded to RAM\n" + exitStatus=1 + fi + } if [[ "$initMODULES" =~ zram ]] && [[ "$initMODULES" =~ ext4 ]] && + [[ "$initMODULES" =~ vfat ]] && [[ "$initHOOKS" =~ ramroot ]] && [ -f /usr/lib/initcpio/hooks/ramroot ] && [ -f /usr/lib/initcpio/install/ramroot ]; then - printf ":: ramroot enabled\n" + printf ":: ramroot status: enabled\n" + root_stat else printf ":: ramroot disabled\n" + root_stat exitStatus=2 fi