feat(install.sh): improve script logging & remove duplicate curl
This PR introduces the following changes:
- Remove the duplicate curl before Gaia cli installation
- Improve user console logging readability
- Add timestamp
I have tested the modified script.sh in a docker environment
Result:
Hello, I am a code review agent on flows.network. Here are my reviews of changed source code files in this PR.
install.sh
Potential issues
-
Incorrect
backup_to_filePath Handling:- The line
backup_to_file=$(cd "$backup_to_file" && pwd)is incorrect becausebackup_to_fileshould be a file path, not a directory. This command attempts to change into the backup file location as if it were a directory, which will fail.
- The line
-
Unnecessary Directory Permissions:
- The script creates directories with mode
777(mkdir -p -m777 $gaianet_base_dir), which is overly permissive and poses security risks. Directories should have more restrictive permissions, such as750.
- The script creates directories with mode
-
Redundant Architecture Check:
- The script checks for the architecture twice (once for Linux and once for macOS). This redundancy can be consolidated into a single check to improve readability and maintainability.
Summary of changes
-• Improved Logging: Introduced timestamped logging with color-coding for INFO, WARNING, ERROR, SUCCESS, and WAITING messages.
• Removed Duplicate curl Commands: Consolidated duplicate curl function calls into a single check_curl function.
• Reordered Variable Definitions: Moved ANSI escape code definitions below the argument parsing section for better organization.
I can also update the gaianet.sh script to match the style of this install.sh logging if needed :^)