Skip to content

Commit 40a9314

Browse files
committed
more detailed status action
1 parent 36aecab commit 40a9314

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

README.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,10 @@ <h1>Actions</h1>
607607
<dd>Disable ramroot.
608608
Remove build and runtime hooks from <em>/usr/lib/initcpio</em>.</dd>
609609
<dt><tt class="docutils literal">status</tt></dt>
610-
<dd>Print ramroot status to screen.
611-
Return exit status 2 if not enabled.</dd>
610+
<dd>Print ramroot and root filesystem status to screen.
611+
Return exit status 0 if enabled and currently loaded to RAM.
612+
Return exit status 1 if enabled and not loaded RAM.
613+
Return exit status 2 if disabled.</dd>
612614
</dl>
613615
</div>
614616
<div class="section" id="options">
@@ -686,7 +688,7 @@ <h1>Credits</h1>
686688
<tbody valign="top">
687689
<tr class="field"><th class="field-name">Author:</th><td class="field-body">Chris Magyar</td>
688690
</tr>
689-
<tr class="field"><th class="field-name">Version:</th><td class="field-body">1.1.6</td>
691+
<tr class="field"><th class="field-name">Version:</th><td class="field-body">1.1.7</td>
690692
</tr>
691693
<tr class="field"><th class="field-name">License:</th><td class="field-body">GPL 3.0</td>
692694
</tr>

README.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ Action performed by ramroot; one must be specified.
8181
Remove build and runtime hooks from */usr/lib/initcpio*.
8282

8383
``status``
84-
Print ramroot status to screen.
85-
Return exit status 2 if not enabled.
84+
Print ramroot and root filesystem status to screen.
85+
Return exit status 0 if enabled and currently loaded to RAM.
86+
Return exit status 1 if enabled and not loaded RAM.
87+
Return exit status 2 if disabled.
8688

8789

8890
Options
@@ -181,7 +183,7 @@ by several inquisitive `forum posts`_.
181183
Chris Magyar
182184

183185
:Version:
184-
1.1.6
186+
1.1.7
185187

186188
:License:
187189
GPL 3.0

lib/man/ramroot.8

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH RAMROOT 8 "December 2017" "ramroot 1.1.6" "Ramroot Manual"
1+
.TH RAMROOT 8 "December 2017" "ramroot 1.1.7" "Ramroot Manual"
22
.SH NAME
33
ramroot \- load root filesystem entirely to RAM during boot
44
.SH SYNOPSIS
@@ -49,8 +49,10 @@ Disable \fBramroot\fR. Remove build and runtime hooks from
4949
.TP
5050
\fBstatus\fR
5151
.br
52-
Print \fBramroot\fR status to screen.
53-
Return exit status 2 if not enabled.
52+
Print \fBramroot\fR and root filesystem status to screen.
53+
Return exit status 0 if enabled and currently loaded to RAM.
54+
Return exit status 1 if enabled and not loaded RAM.
55+
Return exit status 2 if disabled.
5456
.SH OPTIONS
5557
.TP
5658
\fB\-b\fR, \fB\-\-boot\fR <\fIUUID\fR>

ramroot

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
##============================== ramroot ===============================##
33
# Copyright (C) 2018 Chris Magyar GNU General Public License v3 #
44
##========================================================================##
5-
version="1.1.6"
5+
version="1.1.7"
66

77
print_help() {
88
cat <<'HELPDOC'
@@ -29,8 +29,10 @@ ACTIONS
2929
Remove build and runtime hooks from /usr/lib/initcpio.
3030
3131
status
32-
Print ramroot status to screen.
33-
Return exit status 2 if not enabled.
32+
Print ramroot and root filesystem status to screen.
33+
Return exit status 0 if enabled and currently loaded to RAM.
34+
Return exit status 1 if enabled and not loaded RAM.
35+
Return exit status 2 if disabled.
3436
3537
OPTIONS
3638
-b, --boot UUID
@@ -179,7 +181,7 @@ ramroot_enable() {
179181
# incognito mode:
180182
if [ "$incognitoMode" = 'true' ]; then
181183
sed -i '73i\ echo -e "\\e[0;30m"; clear' hooks/ramroot
182-
sed -i '114i\ echo -e "\\E[H\\E[2J\\E[0;30m\\E[?1c" \\' \
184+
sed -i '114i\ echo -e "\\033[H\\033[2J\\033[0;30m\\033[?1c" \\' \
183185
hooks/ramroot
184186
sed -i '115i\ > /zram_root/etc/issue' hooks/ramroot
185187
sed -i '116i\ chmod +x /zram_root/etc/issue' hooks/ramroot
@@ -362,14 +364,26 @@ ramroot_remove() {
362364
##======================== ramroot_status() ========================##
363365
# Print ramroot installation status to screen.
364366
ramroot_status() {
367+
# print root filesystem status:
368+
root_stat() {
369+
if (lsblk | grep -P 'zram.*?/ ?$' >/dev/null); then
370+
printf ":: root filesystem loaded to RAM\n"
371+
else
372+
printf ":: root filesystem not loaded to RAM\n"
373+
exitStatus=1
374+
fi
375+
}
365376
if [[ "$initMODULES" =~ zram ]] &&
366377
[[ "$initMODULES" =~ ext4 ]] &&
378+
[[ "$initMODULES" =~ vfat ]] &&
367379
[[ "$initHOOKS" =~ ramroot ]] &&
368380
[ -f /usr/lib/initcpio/hooks/ramroot ] &&
369381
[ -f /usr/lib/initcpio/install/ramroot ]; then
370-
printf ":: ramroot enabled\n"
382+
printf ":: ramroot status: enabled\n"
383+
root_stat
371384
else
372385
printf ":: ramroot disabled\n"
386+
root_stat
373387
exitStatus=2
374388
fi
375389

0 commit comments

Comments
 (0)