WIP ...
This commit is contained in:
parent
e0af76527e
commit
2dc2ba05cd
@ -9,16 +9,28 @@
|
|||||||
{ #set enviroemnt
|
{ #set enviroemnt
|
||||||
readonly TRUE=1 #like <stdbool.h>
|
readonly TRUE=1 #like <stdbool.h>
|
||||||
readonly FALSE=0 #like <stdbool.h>
|
readonly FALSE=0 #like <stdbool.h>
|
||||||
readonly TTSYNC_EXIST=0
|
readonly TTSYNC_EXIST=0 #file exist local
|
||||||
readonly TTSYNC_BACKUP=1
|
readonly TTSYNC_BACKUP=1 #file exist local - backup exist
|
||||||
readonly TTSYNC_REMOTE=2
|
readonly TTSYNC_REMOTE=2 #file exists remote - not used jet
|
||||||
readonly TTSYNC_DEL=3
|
readonly TTSYNC_DEL=3 #local file deleted
|
||||||
readonly globalconf="/etc/tt/global"
|
readonly globalconf="/etc/tt/global"
|
||||||
}
|
}
|
||||||
|
|
||||||
{ #get options & args
|
{ #get options & args
|
||||||
readonly mode=$(echo $1 | tr -d '-')
|
readonly mode=$(echo $1 | tr -d '-')
|
||||||
moviedir="$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')
|
||||||
}
|
}
|
||||||
|
|
||||||
{ #db
|
{ #db
|
||||||
@ -46,6 +58,17 @@ function main() {
|
|||||||
#cd to moviedir
|
#cd to moviedir
|
||||||
cd "$moviedir"
|
cd "$moviedir"
|
||||||
|
|
||||||
|
#erselle zwei dateilisten
|
||||||
|
list_tmp=$(mktemp -d)
|
||||||
|
db_query "SELECT CONCAT('$moviedir/', Folder, '/', Name) FROM File WHERE TTSync=$TTSYNC_EXIST OR TTSync=$TTSYNC_BACKUP;" > "$list_tmp/indb"
|
||||||
|
find "$moviedir" -type f > "$list_tmp/exist"
|
||||||
|
|
||||||
|
#find new files
|
||||||
|
grep -vf "$list_tmp/indb" "$list_tmp/exist" > "$list_tmp/new"
|
||||||
|
|
||||||
|
#all IDs wich an old check date:
|
||||||
|
#db_query "SELECT ID FROM File Where TTCheck < '$DATE' OR TTCheck IS NULL;"
|
||||||
|
|
||||||
## dateiliste erstellen die mit DB abgeglichen wird
|
## dateiliste erstellen die mit DB abgeglichen wird
|
||||||
|
|
||||||
## alle die keien DB.PATH eintrag haben -> file_add
|
## alle die keien DB.PATH eintrag haben -> file_add
|
||||||
@ -110,7 +133,11 @@ function md5_out_del() {
|
|||||||
|
|
||||||
# file_size <path> -> (du -b)/1024 [Kb]
|
# file_size <path> -> (du -b)/1024 [Kb]
|
||||||
function file_size() {
|
function file_size() {
|
||||||
|
if [ -f "$1" ]; then
|
||||||
echo $(($(du -b "$1" | cut -f 1)/1024))
|
echo $(($(du -b "$1" | cut -f 1)/1024))
|
||||||
|
else
|
||||||
|
echo 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# db_query <query> -> result
|
# db_query <query> -> result
|
||||||
|
Loading…
Reference in New Issue
Block a user