Skip to content

Commit

Permalink
more detailed status action
Browse files Browse the repository at this point in the history
  • Loading branch information
arcmags committed Dec 9, 2017
1 parent 36aecab commit 40a9314
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
8 changes: 5 additions & 3 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,10 @@ <h1>Actions</h1>
<dd>Disable ramroot.
Remove build and runtime hooks from <em>/usr/lib/initcpio</em>.</dd>
<dt><tt class="docutils literal">status</tt></dt>
<dd>Print ramroot status to screen.
Return exit status 2 if not enabled.</dd>
<dd>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.</dd>
</dl>
</div>
<div class="section" id="options">
Expand Down Expand Up @@ -686,7 +688,7 @@ <h1>Credits</h1>
<tbody valign="top">
<tr class="field"><th class="field-name">Author:</th><td class="field-body">Chris Magyar</td>
</tr>
<tr class="field"><th class="field-name">Version:</th><td class="field-body">1.1.6</td>
<tr class="field"><th class="field-name">Version:</th><td class="field-body">1.1.7</td>
</tr>
<tr class="field"><th class="field-name">License:</th><td class="field-body">GPL 3.0</td>
</tr>
Expand Down
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -181,7 +183,7 @@ by several inquisitive `forum posts`_.
Chris Magyar

:Version:
1.1.6
1.1.7

:License:
GPL 3.0
Expand Down
8 changes: 5 additions & 3 deletions lib/man/ramroot.8
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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>
Expand Down
24 changes: 19 additions & 5 deletions ramroot
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 40a9314

Please sign in to comment.