Skip to content

Commit

Permalink
[tui] Implement #135 for update
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed Jan 20, 2025
1 parent 209df2f commit ae8d1b3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tui/features.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ if [[ "$RASPBERRYPI_MODEL" != *"Raspberry Pi 3"* ]] && [[ "$KERNEL" != *"microso
features+=("gui" "$GUI_DESCRIPTION" OFF)
fi

features_state_file="$RUN_AS_HOME/.local/state/ovos/features.json"
if [ -f "$features_state_file" ]; then
if jq -e '.features|any(. == "skills")' "$features_state_file"; then
if [ -f "$INSTALLER_STATE_FILE" ]; then
if jq -e '.features|any(. == "skills")' "$INSTALLER_STATE_FILE" &>>"$LOG_FILE"; then
features=("skills" "$SKILL_DESCRIPTION" ON)
else
features=("skills" "$SKILL_DESCRIPTION" OFF)
fi
if jq -e '.features|any(. == "extra-skills")' "$features_state_file"; then
if jq -e '.features|any(. == "extra-skills")' "$INSTALLER_STATE_FILE" &>>"$LOG_FILE"; then
features+=("extra-skills" "$EXTRA_SKILL_DESCRIPTION" ON)
else
features+=("extra-skills" "$EXTRA_SKILL_DESCRIPTION" OFF)
fi
if jq -e '.features|any(. == "gui")' "$features_state_file"; then
if jq -e '.features|any(. == "gui")' "$INSTALLER_STATE_FILE" &>>"$LOG_FILE"; then
features+=("gui" "$GUI_DESCRIPTION" ON)
else
features+=("gui" "$GUI_DESCRIPTION" OFF)
Expand Down Expand Up @@ -66,4 +65,6 @@ for FEATURE in $OVOS_FEATURES; do
esac
done

jq -n '.features += $ARGS.positional' --args "${FEATURES_STATE[@]}" > "$features_state_file"
if [ ! -f "$INSTALLER_STATE_FILE" ]; then
jq -en '.features += $ARGS.positional' --args "${FEATURES_STATE[@]}" >> "$INSTALLER_STATE_FILE"
fi
12 changes: 12 additions & 0 deletions tui/profiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ source "tui/locales/$LOCALE/profiles.sh"
active_profile="ovos"
available_profiles=(ovos satellite listener server)

if [ -f "$INSTALLER_STATE_FILE" ]; then
if jq -e 'has("profile")' "$INSTALLER_STATE_FILE" &>>"$LOG_FILE"; then
current_profile=$(jq -re '.profile' "$INSTALLER_STATE_FILE")
active_profile="$current_profile"
available_profiles=("$current_profile")
fi
fi

whiptail_args=(
--title "$TITLE"
--radiolist "$CONTENT"
Expand All @@ -31,3 +39,7 @@ if [ -z "$PROFILE" ]; then
source tui/channels.sh
source tui/profiles.sh
fi

if [ ! -f "$INSTALLER_STATE_FILE" ]; then
jq -en '.profile += "ovos"' > "$INSTALLER_STATE_FILE"
fi
1 change: 1 addition & 0 deletions utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,5 @@ function state_directory() {
mkdir -p "$OVOS_LOCAL_STATE_DIRECTORY" &>>"$LOG_FILE"
chown "$RUN_AS":"$(id -ng "$RUN_AS")" "$OVOS_LOCAL_STATE_DIRECTORY" &>>"$LOG_FILE"
fi
export INSTALLER_STATE_FILE="$OVOS_LOCAL_STATE_DIRECTORY/installer.json"
}

0 comments on commit ae8d1b3

Please sign in to comment.