From a71e62722aeae69c1e9120999c3fc71e337f534e Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 25 Oct 2024 15:33:10 -0700 Subject: [PATCH] Config - Initial support for EmComm Tools user configuration. This is a WiP and will likely change --- overlay/etc/skel/.bash_profile | 4 +- .../etc/skel/.config/emcomm-tools/user.json | 4 ++ overlay/opt/emcomm-tools/bin/et-user | 48 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 overlay/etc/skel/.config/emcomm-tools/user.json create mode 100755 overlay/opt/emcomm-tools/bin/et-user diff --git a/overlay/etc/skel/.bash_profile b/overlay/etc/skel/.bash_profile index 836ca2c..85352f9 100644 --- a/overlay/etc/skel/.bash_profile +++ b/overlay/etc/skel/.bash_profile @@ -1,6 +1,6 @@ # Author : Gaston Gonzalez # Date : 23 April 2024 -# Updated : 20 October 2024 +# Updated : 25 October 2024 # Description : bash profile # 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}" cat /etc/motd echo -e "${NC}" + +export ET_USER_CONFIG=${HOME}/.config/emcomm-tools/user.json diff --git a/overlay/etc/skel/.config/emcomm-tools/user.json b/overlay/etc/skel/.config/emcomm-tools/user.json new file mode 100644 index 0000000..2d66dd5 --- /dev/null +++ b/overlay/etc/skel/.config/emcomm-tools/user.json @@ -0,0 +1,4 @@ +{ + "callsign": "N0CALL", + "grid": "DM33" +} diff --git a/overlay/opt/emcomm-tools/bin/et-user b/overlay/opt/emcomm-tools/bin/et-user new file mode 100755 index 0000000..9cbc92a --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-user @@ -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 < "${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 +