diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..152d75a --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/recordings +/upqueue + +.*.swp diff --git a/convert.sh b/convert.sh new file mode 100755 index 0000000..8f1dcf0 --- /dev/null +++ b/convert.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +. ./sumsel.conf + +#Alle WAV Files ausser das letzte File. +#Das letzte File wird gerade recorded und wird beim naechsten Durchlauf verarbeitet +FILES=$(ls -tr ${REC_DIR} |head -n -1) + +for F in ${FILES} +do + #echo ${F} + #Ermittle ctime des WAV Files + CTIME=$(date -r "${REC_DIR}/${F}" +"%Y%m%d%H%M%S") + ffmpeg -i "${REC_DIR}/${F}" -acodec mp3 "${UPL_DIR}/${CTIME}_${UP_SUFFIX}.mp3" + rm "${REC_DIR}/${F}" +done + +rsync -avzh --remove-source-files ${UPL_DIR} ${REMOTE_DIR} + diff --git a/locktest.sh b/locktest.sh new file mode 100755 index 0000000..75800f9 --- /dev/null +++ b/locktest.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +LOCK_DIR=/var/lock +LOCK_DIR=/tmp/sumsel + +#BASENAME=$(basename "$0") +#LOCK_FILE="${LOCK_DIR}/${BASENAME}" + +function set_lockfile { + BASENAME=$(basename "$0") + LOCK_FILE="${LOCK_DIR}/${BASENAME}" + RANDOM_FILE=$(mktemp --tmpdir=${LOCK_DIR}) + echo ${RANDOM_FILE} + echo $$ > ${RANDOM_FILE} + mv -n ${RANDOM_FILE} ${LOCK_FILE} + + if [ -e ${RANDOM_FILE} ] ; then + #rm ${RANDOM_FILE} + echo "Failed to acquired lock" + OTHER_PID=$(cat ${LOCK_FILE}) + + else + echo "Acquired lock" + fi +} + +function del_lockfile { + LOCK_FILE="${LOCK_DIR}/${BASENAME}" + rm ${LOCK_FILE} +} + +set_lockfile +del_lockfile + diff --git a/res/test.wav b/res/test.wav new file mode 100644 index 0000000..7b9da8c Binary files /dev/null and b/res/test.wav differ diff --git a/simulate.sh b/simulate.sh new file mode 100755 index 0000000..cce15ce --- /dev/null +++ b/simulate.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +. ./sumsel.conf + +COUNTER=0 +#SIM_EXAMPLE_FILE=./res/test.wav +#SIM_PREFIX=sums +#REC_DIR=./recordings + + +echo "Press [CTRL+C] to stop.." +while : +do + sleep 1 + COUNTER=$[$COUNTER +1] + dst_fn="${REC_DIR}/${SIM_PREFIX}_${COUNTER}.wav" + cp ${SIM_EXAMPLE_FILE} ${dst_fn} +done diff --git a/sumsel.conf b/sumsel.conf new file mode 100644 index 0000000..b862336 --- /dev/null +++ b/sumsel.conf @@ -0,0 +1,9 @@ +SIM_EXAMPLE_FILE=./res/test.wav +SIM_PREFIX=sums + +WAV_PREFIX=sums +REC_DIR=./recordings +UPL_DIR=./upqueue +UP_SUFFIX=sumsi +REMOTE_DIR=hs@192.168.42.118:/home/hs/sumsel +