Skip to content

Commit 561ea08

Browse files
committed
update and add a bunch of additional commands
1 parent 9a04795 commit 561ea08

File tree

13 files changed

+209
-28
lines changed

13 files changed

+209
-28
lines changed

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "lib/krakenx"]
2+
path = lib/krakenx
3+
url = https://github.com/KsenijaS/krakenx.git
4+
[submodule "lib/bright"]
5+
path = lib/bright
6+
url = https://github.com/src-run/bash-bright-library.git
7+
[submodule "lib/bright-library"]
8+
path = lib/bright-library
9+
url = https://github.com/src-run/bash-bright-library.git

bin-available/bash.bash

Lines changed: 0 additions & 15 deletions
This file was deleted.

bin-available/color-convert.bash

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/bash
22

33
##
44
## This file is part of the `src-run/user-scripts-server` project.
@@ -9,24 +9,24 @@
99
## file that was distributed with this source code.
1010
##
1111

12-
isRgbFormat()
12+
function isRgbFormat()
1313
{
1414
[[ ${1} =~ ^((2[0-4][0-9]|25[0-5]|[01]?[0-9]?[0-9]),?\s?){3}$ ]]; return $?
1515
}
1616
17-
isHexFormat()
17+
function isHexFormat()
1818
{
1919
[[ ${1} =~ ^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$ ]]; return $?
2020
}
2121
22-
writeRgbAsHex()
22+
function writeRgbAsHex()
2323
{
2424
local rgb=($(echo ${1} | tr "," "\n"))
2525

2626
printf "%02X%02X%02X\n" ${rgb[@]}
2727
}
2828

29-
writeHexAsRgb()
29+
function writeHexAsRgb()
3030
{
3131
local h=${1}
3232

@@ -37,7 +37,7 @@ writeHexAsRgb()
3737
printf "%d,%d,%d\n" 0x${h:0:2} 0x${h:2:2} 0x${h:4:2}
3838
}
3939

40-
sanitizeFormat()
40+
function sanitizeFormat()
4141
{
4242
local f="${1}"
4343
local v=(${@})
@@ -53,7 +53,7 @@ sanitizeFormat()
5353
fi
5454
}
5555

56-
main() {
56+
function main() {
5757
local f=$(sanitizeFormat ${@})
5858

5959
if isHexFormat ${f}; then

bin-available/deb-install.bash

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
function out_line {
4+
local
5+
}
6+
7+
function main {
8+
local deb_file="${1}"
9+
local deb_opts="${@:2}"
10+
11+
if [[ -z "${deb_file}" ]]; then
12+
}
13+
14+
if [[ ${#} -eq 0 ]]; then
15+
printf 'Usage: ./$0 [DEB-PKG-FILE-NAME]\n'
16+
exit 255
17+
fi
18+
19+
if [[ ${#} -gt 1 ]]; then
20+
sudo gdebi --option="${@:2}" "${1}"
21+
22+
sudo gdebi --with-depends --tool apt ${@}
23+
24+
if [[ $? -eq 0 ]]; then
25+
printf 'Finished package install with options "%s"...\n' "${@}"
26+
else
27+
printf 'FAILED package install with options "%s"...\n' "${@}"
28+
exit 255
29+
fi

bin-available/monitor-sensors.bash

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ while true
8080
do
8181
clear
8282
echo -e "\n--- [coretemp-isa-0000 sensors: $(date +"%Y-%m-%d@%H:%M:%S.%N")]\n"; \
83-
sensors coretemp-isa-0000 | tail -n6 | head -n 5 | sed -rn 's/^([^:]+):\s+([^(]+)\s+\(([^)]+)\).*$/\1\t\2\t\3/p' | sed -e's/ */ /g' | awk -F"\t" '{ printf "%-19s=> %-10s(%s)\n", $1, $2, $3 }'; \
83+
sensors coretemp-isa-0000 | tail -n11 | head -n 10 | sed -rn 's/^([^:]+):\s+([^(]+)\s+\(([^)]+)\).*$/\1\t\2\t\3/p' | sed -e's/ */ /g' | awk -F"\t" '{ printf "%-19s=> %-10s(%s)\n", $1, $2, $3 }'; \
8484
echo -e "\n--- [nct6791-isa-0290 sensors: $(date +"%Y-%m-%d@%H:%M:%S.%N")]\n"; \
85-
sensors nct6791-isa-0290 | tail -n14 | head -n11 | sed -rn 's/^([^:]+):\s+([^(]+)\s+\(([^)]+)\).*$/\1\t\2\t\3/p' | sed -e's/ */ /g' | awk -F"\t" '{ printf "%-19s=> %-10s(%s)\n", $1, $2, $3 }';
86-
echo -e "\n--- [nzxt-kraken-pump: $(date +"%Y-%m-%d@%H:%M:%S.%N")]\n";
85+
sensors nct6791-isa-0290 | tail -n30 | head -n28 | sed -rn 's/^([^:]+):\s+([^(]+)\s+\(([^)]+)\).*$/\1\t\2\t\3/p' | sed -e's/ */ /g' | awk -F"\t" '{ printf "%-19s=> %-10s(%s)\n", $1, $2, $3 }';
86+
# echo -e "\n--- [nzxt-kraken-pump: $(date +"%Y-%m-%d@%H:%M:%S.%N")]\n";
8787
COLOR=$(colorSelect)
88-
sudo levctl -c "${COLOR}" | head -n4 | tail -n3 | sed -rn 's/^[ \t]*"([^"]+)": ([^,]+),?/\1\t\2/p' | sed -e's/_/ /g' | sed 's/[^ ]\+/\L\u&/g' | awk -F"\t" '{ printf "%-19s=> %-10s\n", $1, $2 }'
89-
printf "Hex Color => %s\n" "${COLOR}"
88+
# sudo levctl -c "${COLOR}" | head -n4 | tail -n3 | sed -rn 's/^[ \t]*"([^"]+)": ([^,]+),?/\1\t\2/p' | sed -e's/_/ /g' | sed 's/[^ ]\+/\L\u&/g' | awk -F"\t" '{ printf "%-19s=> %-10s\n", $1, $2 }'
89+
# printf "Hex Color => %s\n" "${COLOR}"
9090
sleep ${POLLING_TIME}
9191
done

bin-available/query-kraken.bash

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#!/bin/bash
2+
3+
##
4+
## This file is part of the `src-run/user-scripts-server` project.
5+
##
6+
## (c) Rob Frawley 2nd <rmf@src.run>
7+
##
8+
## For the full copyright and license information, please view the LICENSE.md
9+
## file that was distributed with this source code.
10+
##
11+
12+
#
13+
# output information message
14+
#
15+
function out_info {
16+
printf '[INFO] -- %s\n' "$(printf "${@}")"
17+
}
18+
19+
#
20+
# output warning message
21+
#
22+
function out_warn {
23+
>&2 printf '[WARN] ## %s\n' "$(printf "${@}")"
24+
}
25+
26+
#
27+
# output critical error
28+
#
29+
function out_crit {
30+
>&2 printf '[CRIT] !! %s\n' "$(printf "${@}")"
31+
}
32+
33+
#
34+
# resolve real path of input path
35+
#
36+
function resolve_real_path {
37+
local resolve_path="${1:-}"
38+
local readlink_bin='readlink'
39+
local readlink_opt='-m'
40+
local realpath_bin='realpath'
41+
local realpath_opt='-m'
42+
43+
if [[ -z ${resolve_path} ]]; then
44+
out_warn 'Failed to resolve real path on empty provided path!'
45+
return
46+
fi
47+
48+
if readlink_bin="$(which "${readlink_bin}" 2> /dev/null)"; then
49+
${readlink_bin} ${readlink_opt} "${resolve_path}"
50+
return $?
51+
fi
52+
53+
if realpath_bin="$(which "${realpath_bin}" 2> /dev/null)"; then
54+
${realpath_bin} ${realpath_opt} "${resolve_path}"
55+
return $?
56+
fi
57+
58+
out_warn 'Failed to resolve real path of "%s" (readlink and realpath must both be missing).' "${resolve_path}"
59+
printf '%s' "${resolve_path}"
60+
}
61+
62+
#
63+
# output usage information
64+
#
65+
function out_usage() {
66+
printf 'Usage: ./%s [OPTIONS]\n' "${_SELF_NAME}"
67+
printf '\t-%s | --%-11s %s\n' f fan-speed 'Output the speed of the radiator fan(s).'
68+
printf '\t-%s | --%-11s %s\n' p pump-speed 'Output the speed of the pump.'
69+
printf '\t-%s | --%-11s %s\n' l liquid-temp 'Output the liquid temperature of the loop.'
70+
printf '\t-%s | --%-11s %s\n' v fw-version 'Output the firmware version of the device controller.'
71+
printf '\t-%s | --%-11s %s\n' h help 'Output this usage information.'
72+
73+
exit 0
74+
}
75+
76+
#
77+
# get raw kraken stats data
78+
#
79+
function get_kraken_stats_data {
80+
echo -n "${_DATA_KBIN}"
81+
}
82+
83+
#
84+
# get one kraken stats line
85+
#
86+
function get_kraken_stats_line {
87+
local index="${1}"
88+
declare -A STATS
89+
90+
[[ -z ${index} ]] && return 255
91+
92+
while IFS= read -r data; do
93+
STATS[${data%%=*}]="${data#*=}"
94+
done <<< $(get_kraken_stats_data)
95+
96+
printf '%s\n' "${STATS[${index}]}"
97+
}
98+
99+
#
100+
# output requested data
101+
#
102+
function main {
103+
local opt="${1}"
104+
105+
if [[ ${#} -ne 1 ]]; then
106+
out_crit 'Detected invalid number of arguments! Expected 1 but got %d...' ${#}
107+
out_usage
108+
exit 255
109+
fi
110+
111+
case "${opt}" in
112+
-f|--fan-speed ) get_kraken_stats_line fan_speed ;;
113+
-p|--pump-speed ) get_kraken_stats_line pump_speed ;;
114+
-l|--liquid-temp ) get_kraken_stats_line liquid_temperature ;;
115+
-v|--fw-version ) get_kraken_stats_line firmware_version ;;
116+
-h|--help ) out_usage ;;
117+
* ) out_crit "Invalid argument: '%s'..." "${opt}"; out_usage ;;
118+
esac
119+
}
120+
121+
#
122+
# determine real path name of self
123+
#
124+
readonly _SELF_REAL="$(resolve_real_path "${0}")"
125+
126+
#
127+
# determine real file name of self
128+
#
129+
readonly _SELF_NAME="$(basename "${_SELF_REAL}")"
130+
131+
#
132+
# determine real directory path of self
133+
#
134+
readonly _SELF_PATH="$(dirname "${_SELF_REAL}")"
135+
136+
#
137+
# determine real file path to kraken library executable
138+
#
139+
readonly _LIBS_KBIN="$(resolve_real_path "${_SELF_PATH}/../lib/krakenx/bin/colctl")"
140+
141+
#
142+
# read and format kraken status data
143+
#
144+
readonly _DATA_KBIN="$(
145+
${_LIBS_KBIN} -s 2> /dev/null \
146+
| tail -n4 \
147+
| sed -E 's/^([a-z_]+) ([0-9\.]+)$/\1=\2/'
148+
)"
149+
150+
main "${@}"

bin-available/start-glances.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
sudo glances 2> /dev/null

bin-enabled/deb-install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../bin-available/deb-install.bash

bin-enabled/query-kraken

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../bin-available/query-kraken.bash

bin-enabled/start-glances

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../bin-available/start-glances.bash

lib/bright

Submodule bright added at ade02a2

lib/krakenx

Submodule krakenx added at 1d27fa9

0 commit comments

Comments
 (0)