mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 01:29:54 -06:00
26 lines
511 B
Bash
26 lines
511 B
Bash
#!/bin/bash
|
|
#
|
|
# script: rc.runlog
|
|
#
|
|
# General purpose run and log functions
|
|
#
|
|
# Bergware - created for Unraid OS, October 2023
|
|
|
|
BASENAME=$(basename "$0")
|
|
|
|
run(){
|
|
# log command to syslog
|
|
/usr/bin/logger -t $BASENAME -- "$@"
|
|
# run command - dismiss all output
|
|
"$@" &>/dev/null
|
|
}
|
|
|
|
log(){
|
|
# log message to syslog
|
|
while IFS=$'\n' read -r LINE; do
|
|
/usr/bin/logger -t $BASENAME -- "$LINE"
|
|
done <<< ${1:-$(</dev/stdin)}
|
|
# echo message to console
|
|
[[ -t 1 && -n $1 ]] && /bin/echo "$BASENAME: $1"
|
|
}
|