Skip to content

Commit

Permalink
updated to new standard for /etc/mkinitcpio.conf arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
arcmags committed Nov 30, 2017
1 parent a6c99ba commit 454c1f2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.html
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,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.4</td>
<tr class="field"><th class="field-name">Version:</th><td class="field-body">1.1.5</td>
</tr>
<tr class="field"><th class="field-name">License:</th><td class="field-body">GPL 3.0</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ by several inquisitive `forum posts`_.
Chris Magyar

:Version:
1.1.4
1.1.5

:License:
GPL 3.0
Expand Down
2 changes: 1 addition & 1 deletion lib/man/ramroot.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH RAMROOT 8 "November 2017" "ramroot 1.1.4" "Ramroot Manual"
.TH RAMROOT 8 "November 2017" "ramroot 1.1.5" "Ramroot Manual"
.SH NAME
ramroot \- load root filesystem entirely to RAM during boot
.SH SYNOPSIS
Expand Down
22 changes: 11 additions & 11 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.4"
version="1.1.5"

print_help() {
cat <<'HELPDOC'
Expand Down Expand Up @@ -177,17 +177,17 @@ ramroot_enable() {

# add zram to initMODULES:
if [[ ! "$initMODULES" =~ zram ]]; then
if [ "$initMODULES" = 'MODULES=""' ]; then
initMODULES='MODULES="zram"'
if [ -z "$initMODULES" ]; then
initMODULES='zram'
else
initMODULES="${initMODULES%*\"} zram\""
initMODULES="${initMODULES} zram"
fi
printf ":: zram added to mkinitcpio.conf MODULES\n"
mkinitChange='true'
fi
# add ext4 to initMODULES:
if [[ ! "$initMODULES" =~ ext4 ]]; then
initMODULES="${initMODULES%*\"} ext4\""
initMODULES="${initMODULES} ext4"
printf ":: ext4 added to mkinitcpio.conf MODULES\n"
mkinitChange='true'
fi
Expand All @@ -201,8 +201,8 @@ ramroot_enable() {
# if changes need to be made:
if [ "$mkinitChange" = 'true' ] || [ "$dryRun" = 'true' ]; then
# build new mkinitcpio.conf:
sed "s@^MODULES=.*@$initMODULES@g; \
s@^HOOKS=.*@$initHOOKS@g;" \
sed "s@^MODULES=.*@MODULES=($initMODULES)@g; \
s@^HOOKS=.*@HOOKS=($initHOOKS)@g;" \
/etc/mkinitcpio.conf > mkinitcpio.conf
# FAIL: mkinitcpio.conf not built:
if [ ! -f mkinitcpio.conf ]; then
Expand Down Expand Up @@ -265,8 +265,8 @@ ramroot_disable() {
cp /etc/mkinitcpio.conf "$dirCache/mkinitcpio~.conf"
fi
# build new mkinitcpio.conf:
sed "s@^MODULES=.*@$initMODULES@g; \
s@^HOOKS=.*@$initHOOKS@g;" \
sed "s@^MODULES=.*@MODULES=($initMODULES)@g; \
s@^HOOKS=.*@HOOKS=($initHOOKS)@g;" \
/etc/mkinitcpio.conf > mkinitcpio.conf
# FAIL: mkinitcpio.conf not built:
if [ ! -f mkinitcpio.conf ]; then
Expand Down Expand Up @@ -405,8 +405,8 @@ cd "$dirBuild"
sudo -k

# get current MODULES and HOOKS from /etc/mkinitcpio.conf:
initMODULES=`grep -P '^ *MODULES=' /etc/mkinitcpio.conf`
initHOOKS=`grep -P '^ *HOOKS=' /etc/mkinitcpio.conf`
initMODULES="`grep -Po '^ *MODULES=\(\K.*?(?=\))' /etc/mkinitcpio.conf`"
initHOOKS="`grep -Po '^ *HOOKS=\(\K.*?(?=\))' /etc/mkinitcpio.conf`"

# execute action:
if [ "$ramrootAction" = 'enable' ]; then
Expand Down

0 comments on commit 454c1f2

Please sign in to comment.