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
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
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() {
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
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 "<p>"
- currentDate
- addInfo "albentohandy.sh is started</p>"
- addInfo "<p>Foldende Alben wurden ausgewählt:</p>"
- addInfo "<p>$(cat "$albumlist" | sed 's/$/<br>/')</p>"
- # 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 "<p>"
- currentDate
- addInfo "flac -> mp3 start<br>"
- # 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</p>"
-
- # 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 "<p>"
- currentDate
- addInfo "create sha256sum is start<br>"
printf "Phase %02d of %02d: create sha256sum\n\n" $((curphase++)) $phase
-
MakeSha256CheckSum "$WORK"
-
- currentDate
- addInfo "sha256sum is created</p>"
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 "<p>"
- currentDate
- addInfo "create $zipname start<br>"
-
MakeZipFile "$WORK" "$zipname"
-
printf "\n"
- currentDate
- addInfo "$zipname is created</p>"
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 "<p>"
- currentDate
- addInfo "copy from $WORK to $dest start<br>"
-
+ 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</p>"
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 "<p>"
- currentDate
- addInfo "send email</p>"
- closeMail
- sendEmail
}
main $*
+++ /dev/null
-#!/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="<html>\n \
-<head>\n \
-<title>albentohandy.sh notify</title>\n \
-</head>\n \
-<body>\n"
-}
-
-# write message
-addInfo() {
- MESSAGE="${MESSAGE}$1\n"
-}
-
-# close body andy html
-closeMail() {
- MESSAGE="${MESSAGE}\n \
-</body>\n \
-</html>\n"
-}