debug mail
This commit is contained in:
parent
39dc99cbd6
commit
30f2649ae1
15
encode
15
encode
@ -19,17 +19,16 @@ Log(){ # 1:message 2:returncode(empty: no exit) I:file
|
|||||||
[[ $2 ]] && exit $2 || return 0
|
[[ $2 ]] && exit $2 || return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Mail(){ # 1:kind(0:done, 1:wrong type, 2:encoding error) 2:logline I:repopath,email,name,type,start,finish
|
Mail(){ # 1:kind(0:done, 1:wrong type, 2:encoding error) 2:logline I:repopath,email,username,name,type,start,finish
|
||||||
source "$repopath/vars" # I:user,password,smtp,port
|
source "$repopath/vars" # I:user,password,smtp,port
|
||||||
local sbj msg from="Stream Upload server"
|
local sbj msg to from="Stream Upload server"
|
||||||
declare -A mails
|
|
||||||
mapfile -t <"$repopath/mailhash"
|
mapfile -t <"$repopath/mailhash"
|
||||||
for line in "${MAPFILE[@]}"
|
for line in "${MAPFILE[@]}"
|
||||||
do [[ ${line:0:1} = '#' ]] && continue
|
do [[ ${line:0:1} = '#' ]] && continue
|
||||||
l=${line%$'\t'*} mails[${l%$'\t'*}]=${l#*$'\t'}
|
[[ $username = ${line%%$'\t'*} ]] && _=${line#*$'\t'} to=${_%$'\t'*} && break
|
||||||
done
|
done
|
||||||
# If proper email set, strip ':', otherwise it's the user: look up email
|
# If email given, strip ':'
|
||||||
[[ $email ]] && to=${email:1} || to=${mails[$email]}
|
[[ $email ]] && to=${email:1}
|
||||||
[[ $port ]] || port=587
|
[[ $port ]] || port=587
|
||||||
sbj[0]="Stream Upload encoding done for ${name##*@}"
|
sbj[0]="Stream Upload encoding done for ${name##*@}"
|
||||||
sbj[1]="Stream Upload file wrong type: $type"
|
sbj[1]="Stream Upload file wrong type: $type"
|
||||||
@ -41,7 +40,7 @@ Mail(){ # 1:kind(0:done, 1:wrong type, 2:encoding error) 2:logline I:repopath,em
|
|||||||
then # All ingredients for a mail present
|
then # All ingredients for a mail present
|
||||||
mailer -m "$(echo -e "${msg[$1]}")" -t "$to" -s "${sbj[$1]}" -u "$user" -p "$password" -S "$smtp" -P "$port" -f "$from" &&
|
mailer -m "$(echo -e "${msg[$1]}")" -t "$to" -s "${sbj[$1]}" -u "$user" -p "$password" -S "$smtp" -P "$port" -f "$from" &&
|
||||||
Log "== Mail with subject '${sbj[$1]}' sent to $to" ||
|
Log "== Mail with subject '${sbj[$1]}' sent to $to" ||
|
||||||
Log "== Mail with subject '${sbj[$1]}' failed to send"
|
Log "== Mail with subject '${sbj[$1]}' failed to send to: $to"
|
||||||
Log "Start encoding on $start, finished on $finish"
|
Log "Start encoding on $start, finished on $finish"
|
||||||
else # Can't send
|
else # Can't send
|
||||||
Log "== Mail with subject '${sbj[$1]}' could not be sent"
|
Log "== Mail with subject '${sbj[$1]}' could not be sent"
|
||||||
@ -52,7 +51,7 @@ Mail(){ # 1:kind(0:done, 1:wrong type, 2:encoding error) 2:logline I:repopath,em
|
|||||||
|
|
||||||
# Rename upload and check type
|
# Rename upload and check type
|
||||||
file=${upload%.upload} video=$file.mp4 name=${file##*/} key=${name%%.*}
|
file=${upload%.upload} video=$file.mp4 name=${file##*/} key=${name%%.*}
|
||||||
rest=${name#*.} date=${rest:0:15} _=${rest:16} username=${_%%:*} _=${_%@*} email=${_#${username}}
|
rest=${name#*.} date=${rest:0:15} _=${rest:16} _=${_%@*} username=${_%%:*} email=${_#$username}
|
||||||
mv "$upload" "$file"
|
mv "$upload" "$file"
|
||||||
|
|
||||||
type=$(file -bL --mime-type "$file")
|
type=$(file -bL --mime-type "$file")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user