Add_server function pretty much done except for the bug squishin'.

This commit is contained in:
Storm Dragon 2023-12-13 22:23:31 -05:00
parent f99d620b21
commit ef098a76a2

24
tojam
View File

@ -67,7 +67,7 @@ add_server() {
errorMessage=""
fi
done
servers[${serverInfo[0]}]="${serverInfo[1]}:${serverInfo[2]}"
echo "[${serverInfo[0]}]=\"${serverInfo[1]}:${serverInfo[2]}\"" >> "${config}/servers.conf"
exit 0
}
@ -99,10 +99,10 @@ mkdir -p "${config}"
if ! [[ -r "${config}/config" ]]; then
# Write initial config file
echo 'anonymous="true"' >> "${config}/config"
echo 'saveSourceFiles="false"' >> "${config}/config"
echo 'soundDriver="jack"' >> "${config}/config"
echo "userName='Tojam$(date '+%S')'" >> "${config}/config"
{ echo 'anonymous="true"';
echo 'saveSourceFiles="false"';
echo 'soundDriver="jack"';
echo "userName='Tojam$(date '+%S')'"; } >> "${config}/config"
fi
source "${config}/config"
@ -125,6 +125,20 @@ declare -A servers=(
[Ninjamer 4]="ninjamer.com:2052"
$( [[ -r "${config}/servers.conf" ]] && source "${config}/servers.conf")
)
if [[ -r "${config}/servers.conf" ]]; then
while IFS="=" read -r key value; do
if [[ "$key" =~ ^\[.*\]$ && "$value" =~ ^\".*\"$ ]]; then
key="${key#[}"
key="${key%]}"
value="${value#\"}"
value="${value%\"}"
servers["$key"]="$value"
else
echo "Error: invalid format in ${config}/servers.conf" >&2
exit 1
fi
done < <(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' "${config}/servers.conf")
fi
# Server menu
declare -a menuList