slimm preload down
MV moviedir var load to glob-lib
This commit is contained in:
parent
a3614030c8
commit
ad243b61fe
@ -13,6 +13,7 @@ LIBVER=1.1
|
|||||||
[ -z "$DEBUG" ] && readonly DEBUG=$FALSE
|
[ -z "$DEBUG" ] && readonly DEBUG=$FALSE
|
||||||
|
|
||||||
#ERROR Returns
|
#ERROR Returns
|
||||||
|
readonly ERROR_CONFIG=2
|
||||||
readonly ERROR_DBLINK=20
|
readonly ERROR_DBLINK=20
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,10 +50,38 @@ function db_query() {
|
|||||||
|
|
||||||
# config_load()
|
# config_load()
|
||||||
function config_load() {
|
function config_load() {
|
||||||
|
|
||||||
|
#load functions from LIB
|
||||||
|
if [ -f "$globalconf" ]; then
|
||||||
|
local config="$globalconf"
|
||||||
|
elif [ -f "$(readlink -f "$(dirname $0)/../../src/etc/tt/global")" ]; then
|
||||||
|
local config="$(readlink -f "$(dirname $0)/../../src/etc/tt/global")"
|
||||||
|
else
|
||||||
|
echo "ERROR: Global Config not found"
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
|
||||||
#load db settings
|
#load db settings
|
||||||
readonly dbname=$(grep -v '#' $globalconf | grep ^dbname= | sed "s|^dbname=||g" | tr -d '"')
|
readonly dbname=$(grep -v '#' $config | grep ^dbname= | sed "s|^dbname=||g" | tr -d '"')
|
||||||
readonly dbhost=$(grep -v '#' $globalconf | grep ^dbhost= | sed "s|^dbhost=||g" | tr -d '"')
|
readonly dbhost=$(grep -v '#' $config | grep ^dbhost= | sed "s|^dbhost=||g" | tr -d '"')
|
||||||
readonly dbuser=$(grep -v '#' $globalconf | grep ^dbuser= | sed "s|^dbuser=||g" | tr -d '"')
|
readonly dbuser=$(grep -v '#' $config | grep ^dbuser= | sed "s|^dbuser=||g" | tr -d '"')
|
||||||
readonly dbpwd=$(grep -v '#' $globalconf | grep ^dbpwd= | sed "s|^dbpwd=||g" | tr -d '"')
|
readonly dbpwd=$(grep -v '#' $config | grep ^dbpwd= | sed "s|^dbpwd=||g" | tr -d '"')
|
||||||
readonly dbport=$(grep -v '#' $globalconf | grep ^dbpwd= | sed "s|^dbport=||g" | tr -d '"')
|
readonly dbport=$(grep -v '#' $config | grep ^dbpwd= | sed "s|^dbport=||g" | tr -d '"')
|
||||||
|
|
||||||
|
#set moviedir
|
||||||
|
{
|
||||||
|
moviedir="$(echo $moviedir | sed 's|/$||g')" #remove last '/'
|
||||||
|
[ -z "$moviedir" ] && [ -d "$globalconf" ] && { # if (no argument) and (globalconf exist)
|
||||||
|
if [ -z "$(grep "moviedir=" "$globalconf" )" ]; then # and (moviedir is NOT in globalconf)
|
||||||
|
echo 'ERROR: NO Guilty moviedir SET'
|
||||||
|
exit $ERROR_CONFIG
|
||||||
|
else # and (moviedir is in globalconf)
|
||||||
|
readonly moviedir="$(grep "moviedir=" "$globalconf" | cut -d '=' -f 2 | tr -d '"' | sed 's|/$||g')"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
[ -d "$moviedir" ] || {
|
||||||
|
echo 'ERROR: NO Guilty moviedir SET'
|
||||||
|
exit $ERROR_CONFIG
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,37 +18,22 @@ else
|
|||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{ #get options & args
|
#get options & args
|
||||||
readonly mode=$(echo $1 | tr -d '-')
|
readonly mode=$(echo $1 | tr -d '-')
|
||||||
moviedir="$1"
|
[ -n "$1" ] && moviedir="$1"
|
||||||
[ -z "$moviedir" ] && [ -f "$globalconf" ] && { # if (no argument) and (globalconf exist)
|
|
||||||
if [ -z "$(grep "moviedir=" "$globalconf" )" ]; then # and (moviedir is NOT in globalconf)
|
|
||||||
echo 'neither "movie folder" is set in global config nor given as argument'
|
|
||||||
exit 2
|
|
||||||
else # and (moviedir is in globalconf)
|
|
||||||
moviedir="$(grep "moviedir=" "$globalconf" | cut -d '=' -f 2)"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
[ -d "$moviedir" ] || { echo "moviedir \"$moviedir\" do not exist"; exit 3; } # check moviedir
|
|
||||||
moviedir=""$(echo $moviedir | sed 's|/$||g')""
|
|
||||||
[ -z "$moviedir" ] && exit 255 #catch case moviedir="/"
|
|
||||||
readonly DATE=$(date '+%Y-%m-%d')
|
readonly DATE=$(date '+%Y-%m-%d')
|
||||||
|
|
||||||
#load config (DB,...)
|
#help function
|
||||||
config_load
|
[ "$mode" == "help" ] && {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function help() {
|
|
||||||
#help menue
|
#help menue
|
||||||
echo "$0 is part of the TerabyteTerminator Project"
|
echo "$0 is part of the TerabyteTerminator Project"
|
||||||
echo ""
|
echo ""
|
||||||
echo "update-file-state [moviedir]"
|
echo "update-file-state (moviedir)"
|
||||||
echo " moviedir: Is optional if it is already in the global config"
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
[ "$mode" == "help" ] && help
|
|
||||||
|
#load config (DB,...)
|
||||||
|
config_load
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
## Programm Haupt Ablauf ##
|
## Programm Haupt Ablauf ##
|
||||||
|
Loading…
Reference in New Issue
Block a user