-
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #441 from rosecitytransit/master
- Loading branch information
Showing
5 changed files
with
60 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
#!/bin/bash | ||
|
||
#README: unit-script.txt | ||
|
||
CAPTUREDIR="" | ||
|
||
printf -v TRDATE '%(%Y/%-m/%-d)T' | ||
printf -v NOWTIME '%(%s)T' | ||
SHORTNAME=$1 | ||
RADIOID=$2 | ||
ACTION=$3 | ||
TALKGROUP=$4 | ||
if $3 != "ackresp" | ||
sed <capture_dir>/$1/radiolist.csv 's/^$RADIOID,(.*)/$RADIOID,$NOWTIME,$ACTION,$TALKGROUP,/' | ||
elif | ||
sed <capture_dir>/$1/radiolist.csv 's/$RADIOID,(\d+),([on|join|off|call]),(\d+),(\d+)/$RADIOID,$1,$2,$3,$NOWTIME' | ||
done | ||
echo "$2,$3,$4" >> <capture_dir>/$1/$TRDATE/radiolog.csv | ||
if [ ! "$3" == "ackresp" ]; then | ||
sed -i -e '/^'${2}',.*/{s//'${2}','${NOWTIME}','${3}','${4}',/;:a;n;ba;q}' -e '$a'${2}','${NOWTIME}','${3}','${4}',' $CAPTUREDIR/$1/radiolist.csv | ||
else | ||
sed -i -e '/^'${2}',\([0-9]*\),ackresp,,/{s//'${2}','${NOWTIME}',ackresp,,/;:a;n;ba;q}' -e '/^'${2}',\([0-9]*\),\([a-z]*\),\([0-9]*\),\([0-9]*\)/{s//'${2}',\1,\2,\3,'${NOWTIME}'/;:a;n;ba;q}' -e '$a'${2}','${NOWTIME}',ackresp,,' $CAPTUREDIR/$1/radiolist.csv | ||
fi | ||
echo "$2,$NOWTIME,$3,$4" >> $CAPTUREDIR/$1/$TRDATE/radiolog.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
unit-script.sh README: | ||
|
||
Creates a list of radio IDs in a file named "radiolist.csv" located in the | ||
shortName directory along side the recordings, and logs radio activity to | ||
"radiolog.csv" files located in each day's recordings directory | ||
|
||
Make sure to fill in the CAPTUREDIR="" line with the path used in config.json, no ending / | ||
|
||
file format: radioID,timestamp,action,talkgroup, | ||
for radiolist.csv, acknowledgment response timestamps are added at the end | ||
when they are seen after a different action | ||
|
||
Feel free to customize the script; to use for multiple systems, include in | ||
each system's config.json section | ||
|
||
NOTE: You need to run "echo > radiolist.csv" where the file(s) is going to be | ||
beforehand as sed doesn't work on empty files, and to capture actions before | ||
trunk-recorder makes the daily directory upon recording the first call, set | ||
up a cron task of: 0 0 * * * mkdir -p <capturedir>/$(date +\%Y/\%-m/\%-d/) | ||
|
||
sed usage based on https://stackoverflow.com/a/49852337 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters