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