-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tui] Implement #135 for update #246
Changes from all commits
6373f58
e6661ba
209df2f
ae8d1b3
92fd641
d4d1d3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ install_ansible | |
download_yq | ||
detect_scenario | ||
i2c_scan | ||
state_directory | ||
trap "" ERR | ||
set +eE | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/env bash | ||
|
||
CONTENT=" | ||
An existing instance of Open Voice OS/HiveMind has been detected. | ||
Upgrading your existing instance of Open Voice OS or HiveMind to the latest version ensures that you stay ahead with the most advanced features, critical security updates, bug fixes, and performance optimizations. | ||
This not only enhances the overall functionality and user experience but also ensures compatibility with the latest integrations and tools, keeping your system reliable, secure, and future-proof. | ||
Do you want to update Open Voice OS to the latest version? | ||
" | ||
TITLE="Open Voice OS Installation - Update" | ||
|
||
export CONTENT TITLE |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,9 +3,19 @@ | |||||||||||||||||||||||||||||||||||||
# shellcheck source=locales/en-us/profiles.sh | ||||||||||||||||||||||||||||||||||||||
source "tui/locales/$LOCALE/profiles.sh" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
# Default active and available profiles | ||||||||||||||||||||||||||||||||||||||
active_profile="ovos" | ||||||||||||||||||||||||||||||||||||||
available_profiles=(ovos satellite listener server) | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
# Handle existing installation | ||||||||||||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+11
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for JSON operations. The script uses jq without proper error handling, which could lead to silent failures. Add error handling: 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")
+ if ! jq -e 'has("profile")' "$INSTALLER_STATE_FILE" &>>"$LOG_FILE"; then
+ echo "Error: Invalid state file format" >&2
+ exit 1
+ fi
+ current_profile=$(jq -re '.profile' "$INSTALLER_STATE_FILE") || {
+ echo "Error: Failed to read profile from state file" >&2
+ exit 1
+ } 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
whiptail_args=( | ||||||||||||||||||||||||||||||||||||||
--title "$TITLE" | ||||||||||||||||||||||||||||||||||||||
--radiolist "$CONTENT" | ||||||||||||||||||||||||||||||||||||||
|
@@ -31,3 +41,6 @@ if [ -z "$PROFILE" ]; then | |||||||||||||||||||||||||||||||||||||
source tui/channels.sh | ||||||||||||||||||||||||||||||||||||||
source tui/profiles.sh | ||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
jq -en --arg profile "$PROFILE" '.profile += $profile' > "$TEMP_PROFILE_FILE" | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle potential race conditions with temporary files. The script writes to a temporary file without proper locking mechanisms. Add file locking: -jq -en --arg profile "$PROFILE" '.profile += $profile' > "$TEMP_PROFILE_FILE"
+(
+ flock -w 10 200 || {
+ echo "Error: Failed to acquire lock" >&2
+ exit 1
+ }
+ jq -en --arg profile "$PROFILE" '.profile += $profile' > "$TEMP_PROFILE_FILE"
+) 200>"${TEMP_PROFILE_FILE}.lock" 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,4 +13,7 @@ whiptail --yesno --defaultno --no-button "$NO_BUTTON" --yes-button "$YES_BUTTON" | |||||||||||||||||||||
exit_status=$? | ||||||||||||||||||||||
if [ "$exit_status" -eq 1 ]; then | ||||||||||||||||||||||
export CONFIRM_UNINSTALL="false" | ||||||||||||||||||||||
|
||||||||||||||||||||||
# shellcheck source=update.sh | ||||||||||||||||||||||
source tui/update.sh | ||||||||||||||||||||||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling and improve user flow clarity. When uninstall is declined, the script directly sources update.sh without error handling or user notification. Add error handling and user notification: - # shellcheck source=update.sh
- source tui/update.sh
+ # shellcheck source=update.sh
+ if [ ! -f "tui/update.sh" ]; then
+ echo "Error: Update script not found" >&2
+ exit 1
+ fi
+ whiptail --msgbox --title "$TITLE" "Proceeding to update menu..." \
+ "$TUI_WINDOW_HEIGHT" "$TUI_WINDOW_WIDTH"
+ source tui/update.sh 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/env bash | ||
|
||
# shellcheck source=locales/en-us/misc.sh | ||
source "tui/locales/$LOCALE/misc.sh" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for locale file sourcing. The script assumes locale files exist but doesn't handle cases where they might be missing. Add error checking: -source "tui/locales/$LOCALE/misc.sh"
+if [ ! -f "tui/locales/$LOCALE/misc.sh" ]; then
+ echo "Error: Missing locale file tui/locales/$LOCALE/misc.sh" >&2
+ exit 1
+fi
+source "tui/locales/$LOCALE/misc.sh" Also applies to: 7-7 |
||
|
||
# shellcheck source=locales/en-us/update.sh | ||
source "tui/locales/$LOCALE/update.sh" | ||
|
||
whiptail --yesno --no-button "$NO_BUTTON" --yes-button "$YES_BUTTON" --title "$TITLE" "$CONTENT" "$TUI_WINDOW_HEIGHT" "$TUI_WINDOW_WIDTH" | ||
|
||
exit_status=$? | ||
if [ "$exit_status" -eq 1 ]; then | ||
exit 0 | ||
fi |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -54,6 +54,8 @@ declare -rA SUPPORTED_DEVICES=( | |||||||||||||
["tas5806"]="2f" #https://www.ti.com/product/TAS5806MD | ||||||||||||||
) | ||||||||||||||
export SUPPORTED_DEVICES | ||||||||||||||
export TEMP_FEATURES_FILE=/tmp/features.json | ||||||||||||||
export TEMP_PROFILE_FILE=/tmp/profile.json | ||||||||||||||
Comment on lines
+57
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use secure temporary file paths. Using hardcoded paths in /tmp could lead to security issues in multi-user environments. Use mktemp for secure temporary files: -export TEMP_FEATURES_FILE=/tmp/features.json
-export TEMP_PROFILE_FILE=/tmp/profile.json
+export TEMP_FEATURES_FILE
+export TEMP_PROFILE_FILE
+TEMP_FEATURES_FILE=$(mktemp -t ovos-features.XXXXXX.json)
+TEMP_PROFILE_FILE=$(mktemp -t ovos-profile.XXXXXX.json) 📝 Committable suggestion
Suggested change
|
||||||||||||||
export TUI_WINDOW_HEIGHT="35" | ||||||||||||||
export TUI_WINDOW_WIDTH="90" | ||||||||||||||
export USER_ID="$EUID" | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve temporary file handling and cleanup.
The script needs better error handling and cleanup for temporary files.
Add proper cleanup and error handling:
📝 Committable suggestion