linutil icon indicating copy to clipboard operation
linutil copied to clipboard

Add automated Git configuration, Nerd Fonts installer, and bootloader management scripts to linutil

Open fam007e opened this issue 1 year ago • 8 comments

Type of Change

  • [x] New feature
  • [ ] Bug fix
  • [ ] Documentation Update
  • [ ] Refactoring
  • [ ] Hotfix
  • [ ] Security patch
  • [x] UI/UX improvement

Description

This pull request introduces several new features to linutil:

  1. Automated Git Configuration Script: This script helps users set up Git by configuring their GitHub email, SSH key (either Ed25519 or RSA), and copying the SSH key to the clipboard for easy GitHub integration. It checks for necessary tools like xclip and uses best practices for SSH key generation and GitHub authentication.

  2. Nerd Fonts Installer Script: This script automates the installation of Nerd Fonts by detecting the user’s Linux distribution and using the appropriate package manager to install dependencies (curl, tar). It then provides an interactive prompt for selecting fonts, downloads them from GitHub, installs them locally, and refreshes the font cache. This feature simplifies the process of installing Nerd Fonts across different systems.

  3. Bootloader Switching and Backup Script: This new script facilitates seamless switching between GRUB and systemd-boot bootloaders. It includes:

    • Interactive Menu: Detects the current bootloader and offers options to switch to the other bootloader, restore from backups, or exit.
    • Backup and Restore: Backs up GRUB or systemd-boot configurations and allows restoring from previous backups.
    • Automatic Detection: Automatically detects the current bootloader and provides appropriate actions based on the detected bootloader.
  4. Edited Logo: Used ANSI color from ratatui style's color and modifier to create a logo which is in depicted in readme.

  5. Minor correction of word "parent" in hint.rs is made.

These changes aim to streamline user setup and enhance the configuration experience, making it easier for developers to quickly configure their environment and manage bootloader setups.

Testing

  • The Git configuration script has been tested on various distributions (Ubuntu, Fedora, Arch) for SSH key generation, GitHub key addition, and correct handling of user input for key type and passphrase.
  • The Nerd Fonts installer script has been tested across multiple distributions to ensure it correctly installs fonts, refreshes the font cache, and handles package dependencies.
  • The Bootloader Switching and Backup script has been tested for interactive menu functionality, accurate detection of the current bootloader, and successful switching between GRUB and systemd-boot. Backup and restore functionalities have been verified.

Impact

  • Performance: Minimal performance impact since all scripts run only during setup or maintenance processes.
  • Dependencies: Introduces requirements for xclip in the Git configuration script, and ensures curl and tar are installed for the Nerd Fonts installer. The bootloader script uses common system tools and does not introduce additional runtime dependencies.
  • Behavior: Enhances the user setup experience by automating Git configuration, font installation, and providing a streamlined process for managing bootloaders.
  • Colorful: Logo with ASCII art is colored adds to its visual appeal.

Issue related to PR

  • Resolves #256
  • Resolves #307
  • Resolves #160
  • Resolves #308

Additional Information

  • The Git configuration script includes detailed user prompts and instructions for adding SSH keys to GitHub.
  • The Nerd Fonts installer script uses modular, reusable functions for OS detection and dependency installation, ensuring it is extensible for future font management tasks.
  • The Bootloader Switching and Backup script includes comprehensive backup and restoration processes, as well as an intuitive interactive menu for switching and restoring bootloaders.

Checklist

  • [x] My code adheres to the coding and style guidelines of the project.
  • [x] I have performed a self-review of my own code.
  • [x] I have commented my code, particularly in hard-to-understand areas.
  • [ ] I have made corresponding changes to the documentation.
  • [x] My changes generate no errors/warnings/merge conflicts.

fam007e avatar Sep 08 '24 10:09 fam007e

Why are you removing cargo.lock?

ghost avatar Sep 08 '24 20:09 ghost

I hope the commits have fixed the issue. BTW I saw a recent cargo run warning due to a new ratatui version...

cargo run warning mesage shown:

warning: use of deprecated method `ratatui::Frame::<'_>::set_cursor`: the method set_cursor_position indicates more clearly what about the cursor to set
   --> src/filter.rs:111:19
    |
111 |             frame.set_cursor(x, y);
    |                   ^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: use of deprecated method `ratatui::Frame::<'_>::size`: use .area() as it's the more correct name
  --> src/state.rs:81:26
   |
81 |             .split(frame.size());
   |                          ^^^^

warning: `tui` (bin "linutil") generated 2 warnings

fam007e avatar Sep 08 '24 23:09 fam007e

@fam007e These need to be put on separate lines with Resolves before them. image

ghost avatar Sep 09 '24 00:09 ghost

@fam007e You're adding too many things into 1 PR I'd recommend splitting this up into multiple.

ghost avatar Sep 10 '24 07:09 ghost

OK I won't add anymore to this.

fam007e avatar Sep 10 '24 07:09 fam007e

Sorry for the inconvenience. We had a massive restructure of the codebase to improve future development. Because of this can you update your PR to the new structure. Thank you for your assistance and contribution.

ChrisTitusTech avatar Sep 12 '24 18:09 ChrisTitusTech

@fam007e This needs to be rebased.

ghost avatar Sep 14 '24 15:09 ghost

❯ git pull origin main
From github.com:fam007e/linutil
 * branch            main       -> FETCH_HEAD
Already up to date.
❯ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
❯ git rebase origin/main
Current branch main is up to date.

Despite a successful rebase and a clean status, GitHub still indicates that there are conflicts. I’m perplexed by this.

Here’s what I did:

  • Cleared my entire repository and re-added the files to incorporate recent structural changes.
  • Added my scripts and made minor edits to hint.rs to correct a few spelling mistakes.
  • Updated the logo to an ASCII representation of "Linutil" and used ANSI color codes in ratatui to add color (blue) to both the "CTT" and the ASCII logo "Linutil" via changes in state.rs.
  • Adjusted the tabs/system-setup/tab_data.toml file to accommodate the re-added scripts.
  • Ran cargo clean && cargo build && ./target/debug/linutil to test my changes.

As a result, the image in the README.md was updated accordingly.

I would appreciate any guidance on resolving this issue.

fam007e avatar Sep 14 '24 18:09 fam007e

Can you please split this PR into separate feature PRs

jeevithakannan2 avatar Sep 15 '24 05:09 jeevithakannan2

Can you please split this PR into separate feature PRs

I am going for the hard reset. I will make the fork again and make two batches of commits one is for the scripts and another for the .rs files.

fam007e avatar Sep 15 '24 08:09 fam007e

Each of the script should be a separate PR so that it will be easy to check

jeevithakannan2 avatar Sep 15 '24 08:09 jeevithakannan2