2.1 - logging fixes
This commit is contained in:
parent
a71813bd92
commit
cda848a99b
1 changed files with 18 additions and 10 deletions
|
@ -1,22 +1,30 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
scriptVersion="2.0"
|
scriptVersion="2.1"
|
||||||
|
scriptName="AutoConfig"
|
||||||
|
|
||||||
#### Import Settings
|
#### Import Settings
|
||||||
source /config/extended.conf
|
source /config/extended.conf
|
||||||
|
|
||||||
log () {
|
log () {
|
||||||
m_time=`date "+%F %T"`
|
m_time=`date "+%F %T"`
|
||||||
echo $m_time" :: AutoConfig :: $scriptVersion :: "$1
|
echo $m_time" :: $scriptName :: $scriptVersion :: "$1
|
||||||
}
|
}
|
||||||
|
|
||||||
# auto-clean up log file to reduce space usage
|
logfileSetup () {
|
||||||
if [ -f "/config/logs/AutoConfig.txt" ]; then
|
# auto-clean up log file to reduce space usage
|
||||||
find /config/logs -type f -name "AutoConfig.txt" -size +1024k -delete
|
if [ -f "/config/logs/$scriptName.txt" ]; then
|
||||||
sleep 0.01
|
find /config/logs -type f -name "$scriptName.txt" -size +1024k -delete
|
||||||
fi
|
fi
|
||||||
exec &> >(tee -a "/config/logs/AutoConfig.txt")
|
|
||||||
touch "/config/logs/AutoConfig.txt"
|
if [ ! -f "/config/logs/$scriptName.txt" ]; then
|
||||||
chmod 666 "/config/logs/AutoConfig.txt"
|
touch "/config/logs/$scriptName.txt"
|
||||||
|
chmod 666 "/config/logs/$scriptName.txt"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create Log, start writing...
|
||||||
|
logfileSetup
|
||||||
|
exec &> >(tee -a "/config/logs/$scriptName.txt")
|
||||||
|
|
||||||
if [ "$enableAutoConfig" != "true" ]; then
|
if [ "$enableAutoConfig" != "true" ]; then
|
||||||
log "Script is not enabled, enable by setting enableAutoConfig to \"true\" by modifying the \"/config/extended.conf\" config file..."
|
log "Script is not enabled, enable by setting enableAutoConfig to \"true\" by modifying the \"/config/extended.conf\" config file..."
|
||||||
|
|
Loading…
Reference in a new issue