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 e6661ba commit 209df2f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions ansible/roles/ovos_installer/tasks/ovos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- "{{ ovos_installer_user_home }}/.config/OpenVoiceOS/*"
- "{{ ovos_installer_user_home }}/.config/wireplumber/*"
- "{{ ovos_installer_user_home }}/.local/share/hivemind/*"
- "{{ ovos_installer_user_home }}/.local/state/ovos/*"
when: ovos_installer_cleaning | bool
tags:
- uninstall
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/ovos_installer/tasks/virtualenv/systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,6 @@
- "{{ ovos_installer_user_home }}/.local/share/precise-lite"
- "{{ ovos_installer_user_home }}/.local/state/mycroft"
- "{{ ovos_installer_user_home }}/.local/state/vosk"
- "{{ ovos_installer_user_home }}/.local/state/ovos"
- "{{ ovos_installer_user_home }}/nltk_data"
- "{{ ovos_installer_user_home }}/stdout"
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ install_ansible
download_yq
detect_scenario
i2c_scan
state_directory
trap "" ERR
set +eE

Expand Down
27 changes: 27 additions & 0 deletions tui/features.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,32 @@ export FEATURE_GUI="false"
export FEATURE_SKILLS="false"
export FEATURE_EXTRA_SKILLS="false"

declare -a features
features=("skills" "$SKILL_DESCRIPTION" ON)
features+=("extra-skills" "$EXTRA_SKILL_DESCRIPTION" OFF)
if [[ "$RASPBERRYPI_MODEL" != *"Raspberry Pi 3"* ]] && [[ "$KERNEL" != *"microsoft"* ]] && [ "$PROFILE" != "server" ]; then
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
features=("skills" "$SKILL_DESCRIPTION" ON)
else
features=("skills" "$SKILL_DESCRIPTION" OFF)
fi
if jq -e '.features|any(. == "extra-skills")' "$features_state_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
features+=("gui" "$GUI_DESCRIPTION" ON)
else
features+=("gui" "$GUI_DESCRIPTION" OFF)
fi
fi

OVOS_FEATURES=$(whiptail --separate-output --title "$TITLE" \
--checklist "$CONTENT" --cancel-button "$BACK_BUTTON" --ok-button "$OK_BUTTON" --yes-button "$OK_BUTTON" "$TUI_WINDOW_HEIGHT" "$TUI_WINDOW_WIDTH" "${#features[@]}" "${features[@]}" 3>&1 1>&2 2>&3)

Expand All @@ -27,16 +47,23 @@ if [ "$exit_status" -ne 0 ]; then
fi
fi

declare -a FEATURES_STATE

for FEATURE in $OVOS_FEATURES; do
case "$FEATURE" in
"gui")
export FEATURE_GUI="true"
FEATURES_STATE+=("gui")
;;
"skills")
export FEATURE_SKILLS="true"
FEATURES_STATE+=("skills")
;;
"extra-skills")
export FEATURE_EXTRA_SKILLS="true"
FEATURES_STATE+=("extra-skills")
;;
esac
done

jq -n '.features += $ARGS.positional' --args "${FEATURES_STATE[@]}" > "$features_state_file"
11 changes: 11 additions & 0 deletions utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,14 @@ function apt_ensure() {
echo "No missing packages"
fi
}

# This function ensures the existence of a specific local state directory and
# sets its ownership. This is useful for creating and managing state directories
# required by applications.
function state_directory() {
OVOS_LOCAL_STATE_DIRECTORY="$RUN_AS_HOME/.local/state/ovos"
if [ ! -d "$OVOS_LOCAL_STATE_DIRECTORY" ]; then
mkdir -p "$OVOS_LOCAL_STATE_DIRECTORY" &>>"$LOG_FILE"
chown "$RUN_AS":"$(id -ng "$RUN_AS")" "$OVOS_LOCAL_STATE_DIRECTORY" &>>"$LOG_FILE"
fi
}

0 comments on commit 209df2f

Please sign in to comment.