source beautifying

This commit is contained in:
2021-02-01 17:12:39 +00:00
parent 753f6e1782
commit cc9de03d26

View File

@@ -25,14 +25,15 @@ UPL_SUFFIX=sumsi
usage() { usage() {
echo "Usage: $0 [-h] (-s|-r|-t) [-C <configfile>]" 1>&2; echo "Usage: $0 [-h] (-s|-r|-t) [-C <configfile>]" 1>&2;
echo -e '\t-h Usage' echo -e '\t-h Usage' 1>&2;
echo -e '\t-s Simulation' echo -e '\t-s Simulation' 1>&2;
echo -e '\t-r Aufnahme' echo -e '\t-r Aufnahme' 1>&2;
echo -e '\t-c Konvertierung' echo -e '\t-c Konvertierung' 1>&2;
echo -e '\t-C <configfile> ssss' echo -e '\t-C <configfile> Konfiguration laden' 1>&2;
exit 1; exit 1;
} }
mode=''
while getopts ":hsrcC:" options; while getopts ":hsrcC:" options;
do do
case "${options}" in case "${options}" in
@@ -47,7 +48,7 @@ do
if [ -f ${config} ]; then if [ -f ${config} ]; then
. ${config} . ${config}
else else
echo "file not found: ${config}" echo "config file not found: ${config}"
exit exit
fi fi
;; ;;
@@ -93,18 +94,18 @@ simulate() {
check_var_exists "REC_PREFIX" check_var_exists "REC_PREFIX"
check_var_exists "SIM_EXAMPLE_FILE" check_var_exists "SIM_EXAMPLE_FILE"
local COUNTER=0 local counter=0
local dst_fn=""
mkdir -p ${REC_DIR} mkdir -p ${REC_DIR}
echo "Press [CTRL+C] to stop.." echo "Press [CTRL+C] to stop.."
while : while :
do do
sleep 1 sleep 1
COUNTER=$[$COUNTER +1] counter=$[$counter +1]
dst_fn="${REC_DIR}/${REC_PREFIX}-${COUNTER}.wav" dst_fn="${REC_DIR}/${REC_PREFIX}-${counter}.wav"
cp ${SIM_EXAMPLE_FILE} ${dst_fn} cp ${SIM_EXAMPLE_FILE} ${dst_fn}
done done
exit 0
} }
record() { record() {
@@ -115,7 +116,6 @@ record() {
mkdir -p ${REC_DIR} mkdir -p ${REC_DIR}
arecord --format=cd --device=${REC_DEVICE} --max-file-time ${REC_FILE_TIME} ${REC_DIR}/${REC_PREFIX}.wav arecord --format=cd --device=${REC_DEVICE} --max-file-time ${REC_FILE_TIME} ${REC_DIR}/${REC_PREFIX}.wav
exit 0
} }
convert() { convert() {
@@ -124,9 +124,7 @@ convert() {
check_var_exists "UPL_SUFFIX" check_var_exists "UPL_SUFFIX"
check_var_exists "REMOTE_DIR" check_var_exists "REMOTE_DIR"
if set_lockfile; if set_lockfile; then
then
mkdir -p ${REC_DIR} mkdir -p ${REC_DIR}
mkdir -p ${UPL_DIR} mkdir -p ${UPL_DIR}
@@ -144,7 +142,6 @@ convert() {
rsync -avzh --remove-source-files ${UPL_DIR} ${REMOTE_DIR} rsync -avzh --remove-source-files ${UPL_DIR} ${REMOTE_DIR}
del_lockfile del_lockfile
exit 0
else else
echo "LOCK error" echo "LOCK error"
exit 1 exit 1
@@ -154,13 +151,15 @@ convert() {
case ${mode} in case ${mode} in
s) #Simulation s) #Simulation
simulate simulate
exit exit 0
;; ;;
r) #Aufnahme r) #Aufnahme
record record
exit 0
;; ;;
c) #Konvertierung c) #Konvertierung
convert convert
exit 0
;; ;;
*) *)
echo "mode not set" echo "mode not set"