Config - Initial support for EmComm Tools user configuration. This is a WiP and will likely change

This commit is contained in:
Gaston Gonzalez
2024-10-25 15:33:10 -07:00
parent a26ab51809
commit a71e62722a
3 changed files with 55 additions and 1 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
# Author : Gaston Gonzalez # Author : Gaston Gonzalez
# Date : 23 April 2024 # Date : 23 April 2024
# Updated : 20 October 2024 # Updated : 25 October 2024
# Description : bash profile # Description : bash profile
# All user accounts should be in the 'et-data' group to allow data sharing with # All user accounts should be in the 'et-data' group to allow data sharing with
@@ -24,3 +24,5 @@ NC='\x1B[0m'
echo -e "${YELLOW}" echo -e "${YELLOW}"
cat /etc/motd cat /etc/motd
echo -e "${NC}" echo -e "${NC}"
export ET_USER_CONFIG=${HOME}/.config/emcomm-tools/user.json
@@ -0,0 +1,4 @@
{
"callsign": "N0CALL",
"grid": "DM33"
}
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
#
# Author : Gaston Gonzalez
# Date : 25 October 2024
# Purpose : Set user-specific settings for EmComm Tools.
ET_USER_CONFIG="${HOME}/.config/emcomm-tools/user.json"
if [ ! -e ${ET_USER_CONFIG} ]; then
cp /etc/skel/.config/emcomm-tools/user.json ${ET_USER_CONFIG}
fi
CUR_CALLSIGN=$(cat ${ET_USER_CONFIG} | jq -r .callsign)
CUR_GRID=$(cat ${ET_USER_CONFIG} | jq -r .grid)
while true; do
read -e -p "Enter your callsign (current: ${CUR_CALLSIGN}): " callsign
read -e -p "Enter your maidenhead grid square (current: ${CUR_GRID}): " grid
callsign=${callsign:-"$CUR_CALLSIGN"}
grid=${grid:-"$CUR_GRID"}
echo
echo "Is the following correct?:"
echo "Callsign: $callsign"
echo "Grid Square: $grid"
read -p "(y/n): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
cat <<EOF > "${ET_USER_CONFIG}"
{
"callsign": "${callsign}",
"grid": "${grid}"
}
EOF
echo "User settings updated..."
cat ${ET_USER_CONFIG} | jq .
break
elif [[ "$confirm" =~ ^[Nn]$ ]]; then
echo "Let's try again."
echo
else
echo "Please enter 'y' or 'n'."
fi
done