Skip to content

Commit

Permalink
ensure line spacing between config blocks
Browse files Browse the repository at this point in the history
- fixes #18
  • Loading branch information
OneCDOnly committed May 11, 2024
1 parent 0c59adb commit 2529c0d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
Binary file added build/SortMyQPKGs_240511.qpkg
Binary file not shown.
1 change: 1 addition & 0 deletions build/SortMyQPKGs_240511.qpkg.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5b63caccf389738288b95000aab06651 build/SortMyQPKGs_240511.qpkg
4 changes: 3 additions & 1 deletion docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
* Minor update: (unreleased)
* Minor update: (240511)
- add [QJDK21] to the ALPHA list.
- add [SortMyQPKGs] to the OMEGA list.
- ensure line spacing between config blocks.
- and a few code upgrades.

* Minor update: (240427)
Expand Down
2 changes: 1 addition & 1 deletion qpkg.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
QPKG_NAME="SortMyQPKGs"
QPKG_VER="240427"
QPKG_VER="240511"
QPKG_AUTHOR="OneCD"
QPKG_RC_NUM="500"
QPKG_SERVICE_PROGRAM="sortmyqpkgs.sh"
Expand Down
1 change: 1 addition & 0 deletions shared/OMEGA.default
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ SurveillanceStation # load late due to long startup time
OpenHab3 # load late due to long startup time
NotificationCenter # give netmgr more time to start
Traefik # load after all web services
SortMyQPKGs

# only run after everything else...
RunLast
21 changes: 12 additions & 9 deletions shared/sortmyqpkgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ Init()
PKGS_OMEGA_ORDERED+=("$package_ref")
done < "$actual_omega_pathfile"

PKGS_OMEGA_ORDERED+=("$QPKG_NAME")

}

BackupConfig()
Expand Down Expand Up @@ -252,6 +250,10 @@ SortPackages()
local b=''
local -i i=0

echo -e "\nsorting packages ..."

# time {

# read 'ALPHA' packages in reverse and prepend each to /etc/config/qpkg.conf
for ((i=${#PKGS_ALPHA_ORDERED[@]}-1; i>=0; i--)); do
for a in $(/bin/grep '^\[' /etc/config/qpkg.conf); do
Expand All @@ -270,6 +272,7 @@ SortPackages()
break
done
done
# }

}

Expand All @@ -278,7 +281,7 @@ SendToStart()

# sends $1 to the start of /etc/config/qpkg.conf

local a=$(ShowDataBlock "$1")
local a=$(GetDataBlock "$1")

if [[ $? -gt 0 ]]; then
echo "error - ${a}!"
Expand All @@ -297,19 +300,19 @@ SendToEnd()

# sends $1 to the end of /etc/config/qpkg.conf

local a=$(ShowDataBlock "$1")
local a=$(GetDataBlock "$1")

if [[ $? -gt 0 ]]; then
echo "error - ${a}!"
return 2
fi

/sbin/rmcfg "$1" -f /etc/config/qpkg.conf
echo -e "${a}\n" >> /etc/config/qpkg.conf
echo -e "\n${a}" >> /etc/config/qpkg.conf

}

ShowDataBlock()
GetDataBlock()
{

# returns the data block for the QPKG name specified as $1
Expand All @@ -333,7 +336,7 @@ ShowDataBlock()
bl=$(/usr/bin/tail -n$((ll-sl)) < /etc/config/qpkg.conf | /bin/grep -n '^\[' | /usr/bin/head -n1 | /usr/bin/cut -f1 -d':')
[[ $bl -ne 0 ]] && el=$((sl+bl-1)) || el=$ll

/bin/sed -n "$sl,${el}p" /etc/config/qpkg.conf
echo -e "$(/bin/sed -n "$sl,${el}p" /etc/config/qpkg.conf)" # Output this with 'echo' to strip trailing LFs from config block.

}

Expand Down Expand Up @@ -532,7 +535,7 @@ case $1 in
RecordOperationComplete "$1"
CommitLog
;;
backup)
b|backup)
RecordOperationRequest "$1"
BackupConfig
RecordOperationComplete "$1"
Expand Down Expand Up @@ -587,7 +590,7 @@ case $1 in
RecordOperationComplete "$1"
CommitLog
;;
status)
s|status)
if /bin/grep -q 'sortmyqpkgs.sh' $SHUTDOWN_PATHFILE; then
echo active
exit 0
Expand Down

0 comments on commit 2529c0d

Please sign in to comment.