From: Bastian Dehn Date: Sat, 25 Nov 2017 07:16:04 +0000 (+0100) Subject: remove: notify.sh X-Git-Tag: v1.0.0^2~91 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=3091de0f35f9a16015f07fee6eca9b57efe3e4eb;p=albentohandy.git remove: notify.sh --- diff --git a/Makefile b/Makefile index 8fe9b70..7a4eb78 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,6 @@ install: cp flactomp3v2 $(BINPATH)/flactomp3v2 chmod 755 $(BINPATH)/flactomp3v2 cp man/albentohandy.1 $(MANPATH)/albentohandy.1 - cp notify.sh $(BINPATH)/notify.sh - chmod 755 $(BINPATH)/notify.sh gzip $(MANPATH)/albentohandy.1 cp man/albentohandy.conf.1 $(MANPATH)/albentohandy.conf.1 gzip $(MANPATH)/albentohandy.conf.1 @@ -17,7 +15,6 @@ install: uninstall: rm $(BINPATH)/albentohandy rm $(BINPATH)/flactomp3v2 - rm $(BINPATH)/notify.sh rm $(MANPATH)/albentohandy.1.gz rm $(MANPATH)/albentohandy.conf.1.gz rm $(MANPATH)/flactomp3v2.conf.1.gz diff --git a/albentohandy b/albentohandy index 9adc402..eae9952 100755 --- a/albentohandy +++ b/albentohandy @@ -106,14 +106,6 @@ ExistsScripts() { printf "\nERROR\nflactomp3v2 do not found in %s\n" $scriptdir exit 1 fi - - # notify.sh: functions send email - if [ ! -f $scriptdir/notify.sh ]; then - printf "\nERROR\nnotify.sh do not found in %s\n" $scriptdir - exit 1 - else - source $scriptdir/notify.sh - fi } LoadConfig() { @@ -219,6 +211,23 @@ ReadArguments() { done } +ExistsAlbumlist() { + local albumlist="$1" + + if [ ! -f "$albumlist" ]; then + printf "\nalbumlist does not exists\n\n" + exit + fi +} + +CreateWorkDirectory() { + local WORK="$1" + + if [ ! -d $WORK ]; then + mkdir $WORK + fi +} + main() { WORK="$(pwd)/work.$$" # temporary working directory SCRIPTPATH="/usr/bin" # path to flactomp3v2 and notify.sh script @@ -226,101 +235,49 @@ main() { ExistsBasicProgramms LoadConfig - ExistsScripts "$SCRIPTPATH" - SetDefaultVariables ReadArguments $* - # check albumlist is set - if [ ! -f "$albumlist" ]; then - printf "\nalbumlist does not exists\n\n" - exit - fi - - # create working directory - if [ ! -d $WORK ]; then - mkdir $WORK - fi + ExistsAlbumlist "$albumlist" + CreateWorkDirectory "$WORK" - openMail - addInfo "

" - currentDate - addInfo "albentohandy.sh is started

" - addInfo "

Foldende Alben wurden ausgewählt:

" - addInfo "

$(cat "$albumlist" | sed 's/$/
/')

" - # make symlinks of original flac's in working directory - printf "\nPhase %02d of %02d: create symlinks of flac's to working directory %s\n" $((curphase++)) $phase "$WORK" + printf "\nPhase %02d of %02d:\n" $((curphase++)) $phase + printf "create symlinks of flac's in %s\n" "$WORK" MakeSymlinksToWork "$WORK" "$MUSICPATH" "$albumlist" - addInfo "

" - currentDate - addInfo "flac -> mp3 start
" - # convert flac to mp3 - # it is the longest phase printf "\nPhase %02d of %02d: flac -> mp3\n" $((curphase++)) $phase - ConvertFlacToMp3 "$WORK" "$BASEFILE" "$parallelopts" "$SCRIPTPATH" - currentDate - addInfo "flac -> mp3 finished

" - - # removing flac and cover.jpg printf "\nPhase %02d of %02d: remove flac's and cover's\n\n" $((curphase++)) $phase CleanupFlacAndCovers "$WORK" # create sha256sum in working directory if [ $checksum == true ]; then - addInfo "

" - currentDate - addInfo "create sha256sum is start
" printf "Phase %02d of %02d: create sha256sum\n\n" $((curphase++)) $phase - MakeSha256CheckSum "$WORK" - - currentDate - addInfo "sha256sum is created

" fi # make zipfile in the current path # content of zipfile is content of working directory if [ $mkzip == true ]; then printf "Phase %02d of %02d: create %s\n" $((curphase++)) $phase $zipname - addInfo "

" - currentDate - addInfo "create $zipname start
" - MakeZipFile "$WORK" "$zipname" - printf "\n" - currentDate - addInfo "$zipname is created

" fi # copy work directory to destination folder if [ $cptodest == true ]; then - printf "Phase %02d of %02d: copy %s/ to destination %s\n\n" $((curphase++)) $phase $WORK $dest - addInfo "

" - currentDate - addInfo "copy from $WORK to $dest start
" - + printf "Phase %02d of %02d:\n" $((curphase++)) $phase + printf "copy %s/ to destination %s\n\n" $WORK $dest CopyWorkDirToDestDir "$WORK" "$dest" - - currentDate - addInfo "copy from $WORK to $dest finished

" fi # delete the working directory - if ( [ $mkzip == true ] || [ $cptodest == true ] ) && [ $removework == true ]; then + if ( [ $mkzip == true ] || [ $cptodest == true ] ) && [ $removework == true ]; then CleanupWorkDir "$WORK" fi - - addInfo "

" - currentDate - addInfo "send email

" - closeMail - sendEmail } main $* diff --git a/notify.sh b/notify.sh deleted file mode 100755 index 2155243..0000000 --- a/notify.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -### Script is include in albentohandy to send notify. -### Here is the Basic functions to send mail. -### albentohandy.conf must have parameters for smtp - -# default no notify -# it will be set in .ablentohandy.conf -NOTIFY=false -MESSAGE="" - -# load all parameters to sendemail over smtp -# NOTIFY; FROMADDRESS; TOADDRESS; STMP; SMPTUSERNAME; SMTPPASSWORD(base64) -if [ ! -f $HOME/.albentohandy.conf ]; then - printf "\nERROR\n.albentohandy.conf does not exist\n" - exit 1 -else - source $HOME/.albentohandy.conf -fi - -# send email to notify user -sendEmail() { - if [ $NOTIFY == true ]; then - sendemail -f $FROMADDRESS -t $TOADDRESS \ --s $SMTP -xu $SMTPUSERNAME -xp $(echo $SMTPPASSWORD | base64 --decode) -o tls=yes \ --u "albentohandy" -o message-content-type=html -m "$MESSAGE" - fi -} - -# add current date in message -currentDate() { - MESSAGE="${MESSAGE}$(date +"%Y-%m-%d %H:%M:%S") " -} - -# open html, header and body -openMail() { - MESSAGE="\n \ -\n \ -albentohandy.sh notify\n \ -\n \ -\n" -} - -# write message -addInfo() { - MESSAGE="${MESSAGE}$1\n" -} - -# close body andy html -closeMail() { - MESSAGE="${MESSAGE}\n \ -\n \ -\n" -}