diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..b030c80 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +contact@christitus.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..f0b0257 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,70 @@ +# Contributing Guidelines for Linutil + +Thank you for considering contributing to Linutil! We appreciate your effort in helping improve this project. To ensure that your contributions align with the goals and quality standards of Linutil, please follow these guidelines: + +## 1. **Install Rust**: + +Make sure you have Rust installed on your machine. You can install it by following the instructions at [rust-lang.org](https://www.rust-lang.org/tools/install). + +## 2. **Fork and Clone the repo** + +1. Make a fork of the repo in GitHub +2. Clone the fork +```bash +git clone https://github.com/YOUR_USERNAME_HERE/linutil.git +cd linutil + ``` + +## 3. Make your changes + +- **Edit the files you want to change**: Make your changes to the relevant files. +- **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected. + +## 4. Understand the existing code + +- **Have a clear reason**: Don’t change the way things are done without a valid reason. If you propose an alteration, be prepared to explain why it’s necessary and how it improves the project. +- **Respect existing conventions**: Changes should align with the existing code style, design patterns, and overall project philosophy. If you want to introduce a new way of doing things, justify it clearly. + +## 5. Learn from Past Pull Requests (PRs) + +- **Check merged PRs**: Reviewing merged pull requests can give you an idea of what kind of contributions are accepted and how they are implemented. +- **Study rejected PRs**: This is especially important as it helps you avoid making similar mistakes or proposing changes that have already been considered and declined. + +## 6. Write Clean, Descriptive Commit Messages + +- **Be descriptive**: Your commit messages should clearly describe what the change does and why it was made. +- **Use the imperative mood**: For example, "Add feature X" or "Fix bug in Y", rather than "Added feature X" or "Fixed bug in Y". +- **Keep commits clean**: Avoid committing a change and then immediately following it with a fix for that change. Instead, amend your commit or squash it if needed. + +## 7. Keep Your Pull Requests (PRs) Small and Focused + +- **Make small, targeted PRs**: Focus on one feature or fix per pull request. This makes it easier to review and increases the likelihood of acceptance. +- **Avoid combining unrelated changes**: PRs that tackle multiple unrelated issues are harder to review and might be rejected because of a single problem. + +## 8. Understand and Test the Code You Write + +- **Review your code**: Before submitting your changes, take the time to review your code for readability, efficiency and performance. Consider how your changes affect the project. +- **Avoid using LLMs**: Don't submit AI-generated code without reviewing and testing it first. Ensure that any code you submit is thoroughly understood and meets the project's standards. +- **Testing Requirements**: Failure to conduct testing after multiple requests may result in the closure of your Pull Request. + +## 9. Code Review and Feedback + +- **Expect feedback**: PRs will undergo code review. Be open to feedback and willing to make adjustments as needed. +- **Participate in reviews**: If you feel comfortable, review other contributors' PRs as well. Peer review is a great way to learn and ensure high-quality contributions. + +## 10. Contributing Is More Than Just Code + +- **Test the tool**: Running tests and providing feedback on how the tool works in different environments is a valuable contribution. +- **Write well-formed issues**: Clearly describe bugs or problems you encounter, providing as much detail as possible, including steps to reproduce the issue. +- **Propose reasonable feature requests**: When suggesting new features, ensure they fit within the scope, style, and design of the project. Provide clear reasoning and use cases. + +## 11. Documentation + +- **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this. +- **Automatic generation**: If you decide to add functionality through a new shell script, make sure to fill out all fields in `tab_data.toml` and run `cargo xtask docgen`. + +## 12. License + +- **Agree to the license**: By contributing to Linutil, you agree that your contributions will be licensed under the project's MIT license. + +We appreciate your contributions and look forward to collaborating with you to make Linutil better! diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..abae89e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,32 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'bug' +assignees: '' +--- + +## Describe the bug +A clear and concise description of what the bug is. + +## To Reproduce +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +## Expected behavior +A clear and concise description of what you expected to happen. + +## Screenshots +If applicable, add screenshots to help explain your problem. + +## Additional context +Add any other context about the problem here. + +## Checklist +- [ ] I checked for duplicate issues. +- [ ] I checked already existing discussions. +- [ ] This issue is not included in the roadmap. +- [ ] This issue is present on both stable and development branches. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..84d9de8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: 'enhancement' +assignees: '' +--- + +## Is your feature request related to a problem? Please describe. +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +## Describe the solution you'd like +A clear and concise description of what you want to happen. + +## Describe alternatives you've considered +A clear and concise description of any alternative solutions or features you've considered. + +## Additional context +Add any other context or screenshots about the feature request here. + +## Checklist +- [ ] I checked for duplicate issues. +- [ ] I checked already existing discussions. +- [ ] This feature is not included in the roadmap. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4cc787c --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,36 @@ + + +## Type of Change +- [ ] New feature +- [ ] Bug fix +- [ ] Documentation update +- [ ] Refactoring +- [ ] Hotfix +- [ ] Security patch +- [ ] UI/UX improvement + +## Description + + +## Testing + + +## Impact + + +## Issues / other PRs related + +- Resolves # + +## Additional Information + + +## Checklist +- [ ] My code adheres to the coding and style guidelines of the project. +- [ ] I have performed a self-review of my own code. +- [ ] I have commented my code, particularly in hard-to-understand areas. +- [ ] I have made corresponding changes to the documentation. +- [ ] My changes generate no errors/warnings/merge conflicts. diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..1a258e6 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,14 @@ +# Security Policy + +## Supported Versions + +It is recommended that you run the stable version as this is more tested and used by most. The dev branch is bleed-edge commits that are not well tested and aren't meant to be used in production environments + +| Version | Supported | +| ------- | ------------------ | +| latest | :white_check_mark: | +| dev | :x: | + +## Reporting a Vulnerability + +I'd recommend making an Issue for reporting a bug. If you would like privately submit the bug you can email me at contact@christitus.com diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..116841e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" +ignore: + - dependency-name: "actions/stale" + versions: '>= 9' + - dependency-name: "actions/setup-python" + versions: '> 4' + - dependency-name: "crossterm" + versions: '> 0.27.0' diff --git a/.github/mkdocs.yml b/.github/mkdocs.yml new file mode 100644 index 0000000..9f7e003 --- /dev/null +++ b/.github/mkdocs.yml @@ -0,0 +1,89 @@ +site_name: Chris Titus LinUtil Official Documentation +repo_url: https://github.com/ChrisTitusTech/linutil +docs_dir: '../docs' + +nav: + - Introduction: 'index.md' + - User Guide: 'userguide.md' + - Contributing: + - Contributing Guide: 'contributing.md' + - Roadmap: 'roadmap.md' + - Documentation: + - Known Issues: 'KnownIssues.md' + - FAQ: 'faq.md' + +theme: + name: material + custom_dir: '../overrides' + features: + - navigation.tabs + - navigation.sections + - toc.integrate + - navigation.top + - search.suggest + - search.highlight + - content.tabs.link + - content.code.annotation + - content.code.copy + language: en + logo: assets/favicon.png + favicon: assets/favicon.png + palette: + # Palette toggle for automatic mode + - media: "(prefers-color-scheme)" + toggle: + icon: material/brightness-auto + name: Switch to light mode + + # Palette toggle for light mode + - media: "(prefers-color-scheme: light)" + scheme: default + accent: blue + toggle: + icon: material/brightness-7 + name: Switch to dark mode + + # Palette toggle for dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + primary: black + accent: blue + toggle: + icon: material/weather-night + name: Switch to light mode +markdown_extensions: + - admonition + - pymdownx.details + - pymdownx.superfences + - pymdownx.superfences: + custom_fences: + - name: mermaid + class: mermaid + format: !!python/name:pymdownx.superfences.fence_code_format + - abbr + - attr_list + - pymdownx.snippets + - md_in_html + - pymdownx.superfences + - pymdownx.tabbed: + alternate_style: true + - pymdownx.highlight: + anchor_linenums: true + line_spans: __span + pygments_lang_class: true + - pymdownx.inlinehilite + - def_list + - pymdownx.tasklist: + custom_checkbox: true + - toc: + permalink: true + +plugins: + - search + - awesome-pages + - git-revision-date-localized + - minify: + minify_html: true + htmlmin_opts: + remove_comments: true + cache_safe: true diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..ada1b3e --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,23 @@ +changelog: + categories: + - title: '🚀 Features' + label: 'enhancement' + - title: '🐛 Bug Fixes' + label: 'bug' + - title: '⚙️ Refactoring' + label: 'refactor' + - title: '🧩 UI/UX' + label: 'UI/UX' + - title: '📚 Documentation' + label: 'documentation' + - title: '🔒 Security' + label: 'security' + - title: '🧰 GitHub Actions' + label: 'github_actions' + - title: '🦀 Rust' + label: 'rust' + - title: '📃 Scripting' + label: 'script' + exclude: + labels: + - 'skip-changelog' \ No newline at end of file diff --git a/.github/requirements.txt b/.github/requirements.txt new file mode 100644 index 0000000..295ed68 --- /dev/null +++ b/.github/requirements.txt @@ -0,0 +1,51 @@ +Babel==2.15.0 +bracex==2.5 +cairocffi==1.7.1 +CairoSVG==2.7.1 +certifi==2024.7.4 +cffi==1.17.0 +charset-normalizer==3.3.2 +click==8.1.7 +colorama==0.4.6 +csscompressor==0.9.5 +cssselect2==0.7.0 +defusedxml==0.7.1 +ghp-import==2.1.0 +gitdb==4.0.11 +GitPython==3.1.43 +htmlmin2==0.1.13 +idna==3.7 +Jinja2==3.1.4 +jsmin==3.0.1 +Markdown==3.6 +MarkupSafe==2.1.5 +mergedeep==1.3.4 +mkdocs==1.6.0 +mkdocs-awesome-pages-plugin==2.9.3 +mkdocs-get-deps==0.2.0 +mkdocs-git-revision-date-localized-plugin==1.2.6 +mkdocs-material==9.5.31 +mkdocs-material-extensions==1.3.1 +mkdocs-minify-plugin==0.8.0 +natsort==8.4.0 +packaging==24.1 +paginate==0.5.6 +pathspec==0.12.1 +pillow==10.4.0 +platformdirs==4.2.2 +pycparser==2.22 +Pygments==2.18.0 +pymdown-extensions==10.9 +python-dateutil==2.9.0.post0 +pytz==2024.1 +PyYAML==6.0.2 +pyyaml_env_tag==0.1 +regex==2024.7.24 +requests==2.32.3 +six==1.16.0 +smmap==5.0.1 +tinycss2==1.3.0 +urllib3==2.2.2 +watchdog==4.0.1 +wcmatch==9.0 +webencodings==0.5.1 diff --git a/.github/workflows/bashisms.yml b/.github/workflows/bashisms.yml new file mode 100644 index 0000000..7ce39ef --- /dev/null +++ b/.github/workflows/bashisms.yml @@ -0,0 +1,45 @@ +name: Check for bashisms + +on: + pull_request: + paths: + - core/tabs/** + merge_group: + workflow_dispatch: + +jobs: + check-bashisms: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - run: git fetch origin ${{ github.base_ref }} + + - name: Get a list of changed script files + id: get_sh_files + run: | + sh_files=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs | grep '\.sh$' || true) + if [ -n "$sh_files" ]; then + echo "$sh_files" > changed_files + echo "changed=1" >> $GITHUB_OUTPUT + else + echo "changed=0" >> $GITHUB_OUTPUT + fi + + - name: Install devscripts + if: steps.get_sh_files.outputs.changed == 1 + run: sudo apt-get update && sudo apt-get install devscripts + + - name: Check for bashisms + if: steps.get_sh_files.outputs.changed == 1 + run: | + echo "Running for:\n$(cat changed_files)\n" + for file in $(cat changed_files); do + if [[ -f "$file" ]]; then + checkbashisms "$file" + fi + done + + - name: Remove the created file + if: steps.get_sh_files.outputs.changed == 1 + run: rm changed_files diff --git a/.github/workflows/linutil.yml b/.github/workflows/linutil.yml new file mode 100644 index 0000000..517bf36 --- /dev/null +++ b/.github/workflows/linutil.yml @@ -0,0 +1,88 @@ +name: LinUtil Release + +on: + workflow_dispatch: + +permissions: + contents: write + packages: write + +env: + CARGO_TERM_COLOR: always + +jobs: + linutil_build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install musl-tools + run: sudo apt-get update && sudo apt-get install musl-tools + + - name: Cache Cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-registry- + + - name: Cache Cargo index + uses: actions/cache@v4 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-index- + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-unknown-linux-musl + + - name: Install cross-rs for cross-compilation + run: cargo install cross + + - name: Build x86_64 binary + run: cargo build --target-dir=build --release --verbose --target=x86_64-unknown-linux-musl --all-features + + - name: Build aarch64 binary + run: cross build --target-dir=build --release --verbose --target=aarch64-unknown-linux-musl --all-features + + - name: Move binaries to build directory + run: | + mv build/x86_64-unknown-linux-musl/release/linutil build/linutil + mv build/aarch64-unknown-linux-musl/release/linutil build/linutil-aarch64 + + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Commit Linutil + file_pattern: "build/linutil build/linutil-aarch64" + add_options: '--force' + if: success() + + - name: Extract Version + id: extract_version + run: | + version=$(date +"%Y.%m.%d") + echo "version=$version" >> $GITHUB_ENV + shell: bash + + - name: Build linutil binary + run: cargo build --release + + - name: Create and Upload Release + id: create_release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.version }} + name: Pre-Release ${{ env.version }} + body: | + Latest linutil binary release + append_body: true + generate_release_notes: true + files: | + ./target/release/linutil + prerelease: true + env: + version: ${{ env.version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..fd9e190 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,44 @@ +name: Rust Checks + +on: + pull_request: + branches: ["main"] + paths: + - '**/*.rs' + - 'Cargo.toml' + - 'Cargo.lock' + +env: + CARGO_TERM_COLOR: always + +jobs: + lints: + name: Lints + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache Cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-registry- + + - name: Cache Cargo index + uses: actions/cache@v4 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-index- + + - name: Run cargo clippy + run: cargo clippy -- -Dwarnings + + - name: Run cargo fmt + run: cargo fmt --all --check diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..6b1ad42 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,55 @@ +name: ShellCheck + +on: + pull_request: + paths: + - 'core/tabs/**/*.sh' + workflow_dispatch: + +jobs: + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: git fetch origin ${{ github.base_ref }} + + - name: Download, setup, and run ShellCheck + shell: bash {0} + run : | + SC_URL="https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz" + curl -fsSL "$SC_URL" | tar -Jx + chmod +x "./shellcheck-v0.10.0/shellcheck" + + error=0 + files_to_check=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs) + + for file in $files_to_check; do + if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then + sc_output=$(./shellcheck-v0.10.0/shellcheck -fgcc -Serror "$file") + iter_safe_parsed_errors=$(echo -e "$sc_output" | sed -n 's/\(.\+\)\:\([0-9]\+\)\:\([0-9]\+\)\: \(.*\)/::error file=\1,line=\2,col=\3::\4/p' | sed 's/ /:space:/g') + + for error in $iter_safe_parsed_errors; do + echo "$error" | sed 's/:space:/ /g' + error=1 + done + + tabs_detected=$(grep -nP '^\t+\S+' "$file") + + # fast fail on the action runner would fail immediately if there weren't any tabs found + # this check makes sure that we don't continue if there's something really weird going on + if [ "$?" = "2" ]; then + echo "::error file=$file::There was a critical error while grepping $file, aborting" + exit 1 + fi + + iter_safe_parsed_tabs_detected=$(echo "$tabs_detected" | sed -n 's,\([0-9]\+\).*,::error file='"$file"'\,line=\1::Found tab indentations,p' | sed 's/ /:space:/g') + + for error in $iter_safe_parsed_tabs_detected; do + echo "$error" | sed 's/:space:/ /g' + error=1 + done + fi + done + + exit $error diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml new file mode 100644 index 0000000..901d5e7 --- /dev/null +++ b/.github/workflows/typos.yml @@ -0,0 +1,15 @@ +name: Check for typos + +on: + [push, pull_request, workflow_dispatch] + +jobs: + check-typos: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - run: git fetch origin ${{ github.base_ref }} + + - name: Run spellcheck + uses: crate-ci/typos@v1.25.0 diff --git a/.github/workflows/xtask.yml b/.github/workflows/xtask.yml new file mode 100644 index 0000000..fab9393 --- /dev/null +++ b/.github/workflows/xtask.yml @@ -0,0 +1,58 @@ +name: XTasks + +on: + pull_request: + paths: + - "xtask" + - "Cargo.toml" + - "Cargo.lock" + - ".cargo" + - "core/tabs" + - "docs" + push: + paths: + - "xtask" + - "Cargo.toml" + - "Cargo.lock" + - ".cargo" + - "core/tabs" + - "docs" + +env: + CARGO_TERM_COLOR: always + +jobs: + docgen: + name: DocGen + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache Cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-registry- + + - name: Cache Cargo index + uses: actions/cache@v4 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-index- + + - name: Run cargo xtask docgen + run: cargo xtask docgen + + - name: Check uncommitted documentation changes + run: | + git diff + git diff-files --quiet \ + || (echo "Run 'cargo xtask docgen' and push the changes" \ + && exit 1) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7f03765 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/target +/build +rust/target +rust/build +/build/linutil diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..266ed83 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1458 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi-to-tui" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c4af0bef1b514c9b6a32a773caf604c1390fa7913f4eaa23bfe76f251d6a42" +dependencies = [ + "nom", + "ratatui", + "simdutf8", + "smallvec", + "thiserror", +] + +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" + +[[package]] +name = "castaway" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0abae9be0aaf9ea96a3b1b8b1b55c602ca751eba1b1500220cea4ecbafe7c0d5" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cc" +version = "1.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets", +] + +[[package]] +name = "clap" +version = "4.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + +[[package]] +name = "compact_str" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6050c3a16ddab2e412160b31f2c871015704239bca62f72f6e5f0be631d3f644" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "rustversion", + "ryu", + "static_assertions", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crossterm" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" +dependencies = [ + "bitflags 2.6.0", + "crossterm_winapi", + "mio", + "parking_lot", + "rustix", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "ego-tree" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12a0bb14ac04a9fcf170d0bbbef949b44cc492f4452bd20c095636956f653642" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "filedescriptor" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7199d965852c3bac31f779ef99cbb4537f80e952e2d6aa0ffeb30cce00f4f46e" +dependencies = [ + "libc", + "thiserror", + "winapi", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "include_dir" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "indexmap" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "instability" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "ioctl-rs" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7970510895cee30b3e9128319f2cefd4bde883a39f38baa279567ba3a7eb97d" +dependencies = [ + "libc", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" + +[[package]] +name = "linutil_core" +version = "24.9.28" +dependencies = [ + "ego-tree", + "include_dir", + "serde", + "temp-dir", + "toml", + "which", +] + +[[package]] +name = "linutil_tui" +version = "24.9.28" +dependencies = [ + "ansi-to-tui", + "anstyle", + "chrono", + "clap", + "crossterm", + "ego-tree", + "linutil_core", + "oneshot", + "portable-pty", + "rand", + "ratatui", + "temp-dir", + "tree-sitter-bash", + "tree-sitter-highlight", + "tui-term", + "unicode-width 0.2.0", + "zips", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "lru" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "log", + "wasi", + "windows-sys", +] + +[[package]] +name = "nix" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", + "pin-utils", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "oneshot" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e296cf87e61c9cfc1a61c3c63a0f7f286ed4554e0e22be84e8a38e1d264a2a29" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "portable-pty" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "806ee80c2a03dbe1a9fb9534f8d19e4c0546b790cde8fd1fea9d6390644cb0be" +dependencies = [ + "anyhow", + "bitflags 1.3.2", + "downcast-rs", + "filedescriptor", + "lazy_static", + "libc", + "log", + "nix", + "serial", + "shared_library", + "shell-words", + "winapi", + "winreg", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "ratatui" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" +dependencies = [ + "bitflags 2.6.0", + "cassowary", + "compact_str", + "crossterm", + "instability", + "itertools", + "lru", + "paste", + "strum", + "strum_macros", + "unicode-segmentation", + "unicode-truncate", + "unicode-width 0.1.14", +] + +[[package]] +name = "redox_syscall" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "regex" +version = "1.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_spanned" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +dependencies = [ + "serde", +] + +[[package]] +name = "serial" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1237a96570fc377c13baa1b88c7589ab66edced652e43ffb17088f003db3e86" +dependencies = [ + "serial-core", + "serial-unix", + "serial-windows", +] + +[[package]] +name = "serial-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f46209b345401737ae2125fe5b19a77acce90cd53e1658cda928e4fe9a64581" +dependencies = [ + "libc", +] + +[[package]] +name = "serial-unix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f03fbca4c9d866e24a459cbca71283f545a37f8e3e002ad8c70593871453cab7" +dependencies = [ + "ioctl-rs", + "libc", + "serial-core", + "termios", +] + +[[package]] +name = "serial-windows" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c6d3b776267a75d31bbdfd5d36c0ca051251caafc285827052bc53bcdc8162" +dependencies = [ + "libc", + "serial-core", +] + +[[package]] +name = "shared_library" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" +dependencies = [ + "lazy_static", + "libc", +] + +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "temp-dir" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc1ee6eef34f12f765cb94725905c6312b6610ab2b0940889cfe58dae7bc3c72" + +[[package]] +name = "termios" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d9cf598a6d7ce700a4e6a9199da127e6819a61e64b68609683cc9a01b5683a" +dependencies = [ + "libc", +] + +[[package]] +name = "thiserror" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tree-sitter" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b84f60031bf8245b563a80c92c1034e557a914f7958f474bc0afa2eed78b98" +dependencies = [ + "cc", + "regex", + "regex-syntax", + "streaming-iterator", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-bash" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3aa5e1c6bd02c0053f3f68edcf5d8866b38a8640584279e30fca88149ce14dda" +dependencies = [ + "cc", + "tree-sitter-language", +] + +[[package]] +name = "tree-sitter-highlight" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c727fb31f816c09fc54dc0e971d101318926866f7261b2acb820e84a61bf52d" +dependencies = [ + "lazy_static", + "regex", + "streaming-iterator", + "thiserror", + "tree-sitter", +] + +[[package]] +name = "tree-sitter-language" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2545046bd1473dac6c626659cc2567c6c0ff302fc8b84a56c4243378276f7f57" + +[[package]] +name = "tui-term" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07f0233f0d4795d2dc6663cfc3ce56b87bebcee66d6bcc088aa6aff5c072361" +dependencies = [ + "ratatui", + "vt100", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + +[[package]] +name = "unicode-truncate" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" +dependencies = [ + "itertools", + "unicode-segmentation", + "unicode-width 0.1.14", +] + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vt100" +version = "0.15.2" +source = "git+https://github.com/ChrisTitusTech/vt100-rust#e41fb3d8fb5fd01dd2d076c9a25823a31656012f" +dependencies = [ + "itoa", + "log", + "unicode-width 0.1.14", + "vte", +] + +[[package]] +name = "vte" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" +dependencies = [ + "arrayvec", + "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte_generate_state_changes" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" + +[[package]] +name = "which" +version = "6.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" +dependencies = [ + "either", + "home", + "rustix", + "winsafe", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + +[[package]] +name = "xtask" +version = "24.9.28" +dependencies = [ + "linutil_core", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zips" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba09194204fda6b1e206faf9096a3c0658ddf7606560f6edce112da3fcc9b111" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..ef31b2a --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,24 @@ +[workspace.package] +license = "MIT" +version = "24.9.28" +edition = "2021" + +[workspace.dependencies] +ego-tree = "0.6.2" + +[workspace] +members = ["tui", "core", "xtask"] +default-members = ["tui", "core"] +resolver = "2" + +[patch.crates-io] +vt100 = { git = "https://github.com/ChrisTitusTech/vt100-rust" } + +[profile.release] +opt-level = "z" +debug = false +lto = true +codegen-units = 1 +panic = "abort" +strip = true +incremental = false diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000..38770ff --- /dev/null +++ b/_typos.toml @@ -0,0 +1,7 @@ +[files] +extend-exclude = ["tui/cool_tips.txt"] + +[default] +extend-ignore-identifiers-re = [ + "ratatui", +] diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 0000000..d3f4201 --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "linutil_core" +description = "The backend of Linutil." +repository = "https://github.com/ChrisTitusTech/linutil/tree/main/core" +edition = "2021" +version.workspace = true +license.workspace = true +include = [ + "src/*.rs", + "Cargo.toml", + "tabs/**", +] + +[dependencies] +include_dir = "0.7.4" +temp-dir = "0.1.14" +serde = { version = "1.0.205", features = ["derive"], default-features = false } +toml = { version = "0.8.19", features = ["parse"], default-features = false } +which = "6.0.3" +ego-tree = { workspace = true } diff --git a/core/src/inner.rs b/core/src/inner.rs new file mode 100644 index 0000000..a2274df --- /dev/null +++ b/core/src/inner.rs @@ -0,0 +1,272 @@ +use std::{ + fs::File, + io::{BufRead, BufReader, Read}, + os::unix::fs::PermissionsExt, + path::{Path, PathBuf}, + rc::Rc, +}; + +use crate::{Command, ListNode, Tab}; +use ego_tree::{NodeMut, Tree}; +use include_dir::{include_dir, Dir}; +use serde::Deserialize; +use temp_dir::TempDir; + +const TAB_DATA: Dir = include_dir!("$CARGO_MANIFEST_DIR/tabs"); + +pub fn get_tabs(validate: bool) -> (TempDir, Vec) { + let (temp_dir, tab_files) = TabList::get_tabs(); + + let tabs: Vec<_> = tab_files + .into_iter() + .map(|path| { + let directory = path.parent().unwrap().to_owned(); + let data = std::fs::read_to_string(path).expect("Failed to read tab data"); + let mut tab_data: TabEntry = toml::from_str(&data).expect("Failed to parse tab data"); + + if validate { + filter_entries(&mut tab_data.data); + } + (tab_data, directory) + }) + .collect(); + + let tabs: Vec = tabs + .into_iter() + .map( + |( + TabEntry { + name, + data, + multi_selectable, + }, + directory, + )| { + let mut tree = Tree::new(Rc::new(ListNode { + name: "root".to_string(), + description: String::new(), + command: Command::None, + task_list: String::new(), + })); + let mut root = tree.root_mut(); + create_directory(data, &mut root, &directory, validate); + Tab { + name, + tree, + multi_selectable, + } + }, + ) + .collect(); + + if tabs.is_empty() { + panic!("No tabs found"); + } + (temp_dir, tabs) +} + +#[derive(Deserialize)] +struct TabList { + directories: Vec, +} + +#[derive(Deserialize)] +struct TabEntry { + name: String, + data: Vec, + #[serde(default = "default_multi_selectable")] + multi_selectable: bool, +} + +fn default_multi_selectable() -> bool { + true +} + +#[derive(Deserialize)] +struct Entry { + name: String, + #[allow(dead_code)] + #[serde(default)] + description: String, + #[serde(default)] + preconditions: Option>, + #[serde(flatten)] + entry_type: EntryType, + #[serde(default)] + task_list: String, +} + +#[derive(Deserialize)] +enum EntryType { + #[serde(rename = "entries")] + Entries(Vec), + #[serde(rename = "command")] + Command(String), + #[serde(rename = "script")] + Script(PathBuf), +} + +impl Entry { + fn is_supported(&self) -> bool { + self.preconditions.as_deref().map_or(true, |preconditions| { + preconditions.iter().all( + |Precondition { + matches, + data, + values, + }| { + match data { + SystemDataType::Environment(var_name) => std::env::var(var_name) + .map_or(false, |var| values.contains(&var) == *matches), + SystemDataType::File(path) => { + std::fs::read_to_string(path).map_or(false, |data| { + values + .iter() + .any(|matching_value| data.contains(matching_value)) + == *matches + }) + } + SystemDataType::CommandExists => values + .iter() + .all(|command| which::which(command).is_ok() == *matches), + } + }, + ) + }) + } +} + +#[derive(Deserialize)] +struct Precondition { + // If true, the data must be contained within the list of values. + // Otherwise, the data must not be contained within the list of values + matches: bool, + data: SystemDataType, + values: Vec, +} + +#[derive(Deserialize)] +enum SystemDataType { + #[serde(rename = "environment")] + Environment(String), + #[serde(rename = "file")] + File(PathBuf), + #[serde(rename = "command_exists")] + CommandExists, +} + +fn filter_entries(entries: &mut Vec) { + entries.retain_mut(|entry| { + if !entry.is_supported() { + return false; + } + if let EntryType::Entries(entries) = &mut entry.entry_type { + filter_entries(entries); + !entries.is_empty() + } else { + true + } + }); +} + +fn create_directory( + data: Vec, + node: &mut NodeMut>, + command_dir: &Path, + validate: bool, +) { + for entry in data { + match entry.entry_type { + EntryType::Entries(entries) => { + let mut node = node.append(Rc::new(ListNode { + name: entry.name, + description: entry.description, + command: Command::None, + task_list: String::new(), + })); + create_directory(entries, &mut node, command_dir, validate); + } + EntryType::Command(command) => { + node.append(Rc::new(ListNode { + name: entry.name, + description: entry.description, + command: Command::Raw(command), + task_list: String::new(), + })); + } + EntryType::Script(script) => { + let script = command_dir.join(script); + if !script.exists() { + panic!("Script {} does not exist", script.display()); + } + + if let Some((executable, args)) = get_shebang(&script, validate) { + node.append(Rc::new(ListNode { + name: entry.name, + description: entry.description, + command: Command::LocalFile { + executable, + args, + file: script, + }, + task_list: entry.task_list, + })); + } + } + } + } +} + +fn get_shebang(script_path: &Path, validate: bool) -> Option<(String, Vec)> { + let default_executable = || Some(("/bin/sh".into(), vec!["-e".into()])); + + let script = File::open(script_path).expect("Failed to open script file"); + let mut reader = BufReader::new(script); + + // Take the first 2 characters from the reader; check whether it's a shebang + let mut two_chars = [0; 2]; + if reader.read_exact(&mut two_chars).is_err() || two_chars != *b"#!" { + return default_executable(); + } + + let first_line = reader.lines().next().unwrap().unwrap(); + + let mut parts = first_line.split_whitespace(); + + let Some(executable) = parts.next() else { + return default_executable(); + }; + + let is_valid = !validate || is_executable(Path::new(executable)); + + is_valid.then(|| { + let mut args: Vec = parts.map(ToString::to_string).collect(); + args.push(script_path.to_string_lossy().to_string()); + (executable.to_string(), args) + }) +} + +fn is_executable(path: &Path) -> bool { + path.metadata() + .map(|metadata| metadata.is_file() && metadata.permissions().mode() & 0o111 != 0) + .unwrap_or(false) +} + +impl TabList { + fn get_tabs() -> (TempDir, Vec) { + let temp_dir = TempDir::new().unwrap(); + TAB_DATA + .extract(&temp_dir) + .expect("Failed to extract the saved directory"); + + let tab_files = std::fs::read_to_string(temp_dir.path().join("tabs.toml")) + .expect("Failed to read tabs.toml"); + let data: Self = toml::from_str(&tab_files).expect("Failed to parse tabs.toml"); + let tab_paths = data + .directories + .iter() + .map(|path| temp_dir.path().join(path).join("tab_data.toml")) + .collect(); + (temp_dir, tab_paths) + } +} diff --git a/core/src/lib.rs b/core/src/lib.rs new file mode 100644 index 0000000..b7cd631 --- /dev/null +++ b/core/src/lib.rs @@ -0,0 +1,35 @@ +mod inner; + +use std::rc::Rc; + +use ego_tree::Tree; +use std::path::PathBuf; + +pub use inner::get_tabs; + +#[derive(Clone, Hash, Eq, PartialEq)] +pub enum Command { + Raw(String), + LocalFile { + executable: String, + args: Vec, + // The file path is included within the arguments; don't pass this in addition + file: PathBuf, + }, + None, // Directory +} + +#[derive(Clone, Hash, Eq, PartialEq)] +pub struct Tab { + pub name: String, + pub tree: Tree>, + pub multi_selectable: bool, +} + +#[derive(Clone, Hash, Eq, PartialEq)] +pub struct ListNode { + pub name: String, + pub description: String, + pub command: Command, + pub task_list: String, +} diff --git a/core/tabs/applications-setup/docker-setup.sh b/core/tabs/applications-setup/docker-setup.sh new file mode 100755 index 0000000..afcd157 --- /dev/null +++ b/core/tabs/applications-setup/docker-setup.sh @@ -0,0 +1,87 @@ +#!/bin/sh -e + +. ../common-script.sh + +# Function to prompt the user for installation choice +choose_installation() { + clear + printf "%b\n" "${YELLOW}Choose what to install:${RC}" + printf "%b\n" "1. ${YELLOW}Docker${RC}" + printf "%b\n" "2. ${YELLOW}Docker Compose${RC}" + printf "%b\n" "3. ${YELLOW}Both${RC}" + printf "%b" "Enter your choice [1-3]: " + read -r CHOICE + + case "$CHOICE" in + 1) INSTALL_DOCKER=1; INSTALL_COMPOSE=0 ;; + 2) INSTALL_DOCKER=0; INSTALL_COMPOSE=1 ;; + 3) INSTALL_DOCKER=1; INSTALL_COMPOSE=1 ;; + *) printf "%b\n" "${RED}Invalid choice. Exiting.${RC}"; exit 1 ;; + esac +} + +install_docker() { + printf "%b\n" "${YELLOW}Installing Docker...${RC}" + case "$PACKAGER" in + apt-get|nala) + curl -fsSL https://get.docker.com | sh + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker + "$ESCALATION_TOOL" systemctl enable docker + "$ESCALATION_TOOL" systemctl start docker + ;; + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm docker + "$ESCALATION_TOOL" systemctl enable docker + "$ESCALATION_TOOL" systemctl start docker + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac +} + +install_docker_compose() { + printf "%b\n" "${YELLOW}Installing Docker Compose...${RC}" + case "$PACKAGER" in + apt-get|nala) + "$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker-compose + ;; + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm docker-compose + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac +} + +install_components() { + choose_installation + + if [ "$INSTALL_DOCKER" -eq 1 ]; then + if ! command_exists docker; then + install_docker + else + printf "%b\n" "${GREEN}Docker is already installed.${RC}" + fi + fi + + if [ "$INSTALL_COMPOSE" -eq 1 ]; then + if ! command_exists docker-compose || ! command_exists docker compose version; then + install_docker_compose + else + printf "%b\n" "${GREEN}Docker Compose is already installed.${RC}" + fi + fi +} + +checkEnv +checkEscalationTool +install_components \ No newline at end of file diff --git a/core/tabs/applications-setup/fastfetch-setup.sh b/core/tabs/applications-setup/fastfetch-setup.sh new file mode 100644 index 0000000..cb52344 --- /dev/null +++ b/core/tabs/applications-setup/fastfetch-setup.sh @@ -0,0 +1,38 @@ +#!/bin/sh -e + +. ../common-script.sh + +installFastfetch() { + if ! command_exists fastfetch; then + printf "%b\n" "${YELLOW}Installing Fastfetch...${RC}" + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch + ;; + apt-get|nala) + curl -sSLo /tmp/fastfetch.deb https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb + "$ESCALATION_TOOL" "$PACKAGER" install -y /tmp/fastfetch.deb + rm /tmp/fastfetch.deb + ;; + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y fastfetch + ;; + esac + else + printf "%b\n" "${GREEN}Fastfetch is already installed.${RC}" + fi +} + +setupFastfetchConfig() { + printf "%b\n" "${YELLOW}Copying Fastfetch config files...${RC}" + if [ -d "${HOME}/.config/fastfetch" ] && [ ! -d "${HOME}/.config/fastfetch-bak" ]; then + cp -r "${HOME}/.config/fastfetch" "${HOME}/.config/fastfetch-bak" + fi + mkdir -p "${HOME}/.config/fastfetch/" + curl -sSLo "${HOME}/.config/fastfetch/config.jsonc" https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/config.jsonc +} + +checkEnv +checkEscalationTool +installFastfetch +setupFastfetchConfig \ No newline at end of file diff --git a/core/tabs/applications-setup/githubdesktop-setup.sh b/core/tabs/applications-setup/githubdesktop-setup.sh new file mode 100644 index 0000000..33928f2 --- /dev/null +++ b/core/tabs/applications-setup/githubdesktop-setup.sh @@ -0,0 +1,42 @@ +#!/bin/sh -e + +. ../common-script.sh + +installGithubDesktop() { + if ! command_exists github-desktop; then + printf "%b\n" "${YELLOW}Installing Github Desktop...${RC}" + case "$PACKAGER" in + apt-get | nala) + curl -fsSL https://apt.packages.shiftkey.dev/gpg.key | gpg --dearmor | "$ESCALATION_TOOL" tee /usr/share/keyrings/shiftkey-packages.gpg >/dev/null + printf "%b\n" 'deb [arch=amd64 signed-by=/usr/share/keyrings/shiftkey-packages.gpg] https://apt.packages.shiftkey.dev/ubuntu/ any main\n' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/shiftkey-packages.list >/dev/null + "$ESCALATION_TOOL" "$PACKAGER" update + "$ESCALATION_TOOL" "$PACKAGER" install -y github-desktop + ;; + zypper) + "$ESCALATION_TOOL" rpm --import https://rpm.packages.shiftkey.dev/gpg.key + printf "%b\n" '[shiftkey-packages]\nname=GitHub Desktop\nbaseurl=https://rpm.packages.shiftkey.dev/rpm/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://rpm.packages.shiftkey.dev/gpg.key\n' | "$ESCALATION_TOOL" tee /etc/zypp/repos.d/shiftkey-packages.repo >/dev/null + "$ESCALATION_TOOL" "$PACKAGER" refresh + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install github-desktop + ;; + pacman) + "$AUR_HELPER" -S --needed --noconfirm github-desktop-bin + ;; + dnf) + "$ESCALATION_TOOL" rpm --import https://rpm.packages.shiftkey.dev/gpg.key + printf "%b\n" '[shiftkey-packages]\nname=GitHub Desktop\nbaseurl=https://rpm.packages.shiftkey.dev/rpm/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://rpm.packages.shiftkey.dev/gpg.key\n' | "$ESCALATION_TOOL" tee /etc/yum.repos.d/shiftkey-packages.repo >/dev/null + "$ESCALATION_TOOL" "$PACKAGER" install -y github-desktop + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac + else + printf "%b\n" "${GREEN}Github Desktop is already installed.${RC}" + fi +} + +checkEnv +checkEscalationTool +checkAURHelper +installGithubDesktop diff --git a/core/tabs/applications-setup/setup-flatpak.sh b/core/tabs/applications-setup/setup-flatpak.sh new file mode 100755 index 0000000..75da28a --- /dev/null +++ b/core/tabs/applications-setup/setup-flatpak.sh @@ -0,0 +1,75 @@ +#!/bin/sh -e + +. ../common-script.sh + +# Used to detect the desktop environment, Only used for the If statement in the setup_flatpak function. +# Perhaps this should be moved to common-script.sh later on? +detect_de() { + if [ -n "$XDG_CURRENT_DESKTOP" ]; then + case "$XDG_CURRENT_DESKTOP" in + *GNOME*) + DE="GNOME" + ;; + *KDE*) + DE="KDE" + ;; + esac + fi +} + +# Install Flatpak if not already installed. +setup_flatpak() { + if ! command_exists flatpak; then + printf "%b\n" "${YELLOW}Installing Flatpak...${RC}" + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak + ;; + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y flatpak + ;; + esac + printf "%b\n" "Adding Flathub remote..." + "$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + else + if command_exists flatpak; then + if ! flatpak remotes | grep -q "flathub"; then + printf "%b" "${YELLOW}Detected Flatpak package manager but Flathub remote is not added. Would you like to add it? (y/N): ${RC}" + read -r add_remote + case "$add_remote" in + [Yy]*) + printf "%b\n" "Adding Flathub remote..." + "$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + ;; + esac + else + # Needed mostly for systems without a polkit agent running (Error: updating: Unable to connect to system bus) + printf "%b\n" "${GREEN}Flathub already setup. You can quit.${RC}" + fi + fi + fi + + if [ "$PACKAGER" = "apt-get" ] || [ "$PACKAGER" = "nala" ]; then + detect_de + # Only used for Ubuntu GNOME. Ubuntu GNOME doesnt allow flathub to be added as a remote to their store. + # So in case the user wants to use a GUI siftware manager they can setup it here + if [ "$DE" = "GNOME" ]; then + printf "%b" "${YELLOW}Detected GNOME desktop environment. Would you like to install GNOME Software plugin for Flatpak? (y/N): ${RC}" + read -r install_gnome + if [ "$install_gnome" = "y" ] || [ "$install_gnome" = "Y" ]; then + "$ESCALATION_TOOL" "$PACKAGER" install -y gnome-software-plugin-flatpak + fi + # Useful for Debian KDE spin as well + elif [ "$DE" = "KDE" ]; then + printf "%b" "${YELLOW}Detected KDE desktop environment. Would you like to install KDE Plasma Discover backend for Flatpak? (y/N): ${RC}" + read -r install_kde + if [ "$install_kde" = "y" ] || [ "$install_kde" = "Y" ]; then + "$ESCALATION_TOOL" "$PACKAGER" install -y plasma-discover-backend-flatpak + fi + fi + fi +} + +checkEnv +checkEscalationTool +setup_flatpak diff --git a/core/tabs/applications-setup/tab_data.toml b/core/tabs/applications-setup/tab_data.toml new file mode 100644 index 0000000..974e460 --- /dev/null +++ b/core/tabs/applications-setup/tab_data.toml @@ -0,0 +1,38 @@ +name = "Applications Setup" +multi_selectable = false + +[[data]] +name = "Fastfetch" +description = "Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily.\nIt is written mainly in C, with performance and customizability in mind.\nThis command installs fastfetch and configures from CTT's mybash repository.\nhttps://github.com/ChrisTitusTech/mybash" +script = "fastfetch-setup.sh" +task_list = "I" + +[[data]] +name = "Flatpak / Flathub" +description = "Flatpak is a universal application sandbox for Linux that uses isolated packages from Flathub to prevent conflicts and system alterations, while alleviating dependency concerns.\nThis command installs Flatpak and adds the Flathub repository" +script = "setup-flatpak.sh" +task_list = "I" + +[[data]] +name = "github-desktop" +description = "GitHub Desktop is a free Git client that allows you to manage your GitHub repositories on your desktop." +script = "githubdesktop-setup.sh" +task_list = "I" + +[[data]] +name = "xmrig" +description = "xmrig is a CPU miner for the Monero cryptocurrency." +script = "xmrig.sh" +task_list = "I" + +[[data]] +name = "yazi" +description = "yazi is a terminal file manager with a minimal UI and a focus on performance." +script = "yazi.sh" +task_list = "I" + +[[data]] +name = "ytgo" +description = "ytgo is a command-line tool for searching and watching YouTube videos from the terminal." +script = "ytgo.sh" +task_list = "I" diff --git a/core/tabs/applications-setup/xmrig.sh b/core/tabs/applications-setup/xmrig.sh new file mode 100755 index 0000000..5cd4f28 --- /dev/null +++ b/core/tabs/applications-setup/xmrig.sh @@ -0,0 +1,185 @@ +#!/bin/sh -e + +# ANSI color codes +RED='\033[0;31m' +CYAN='\033[0;36m' +YELLOW='\033[0;33m' +LIGHT_GREEN='\033[0;92m' +BOLD='\033[1m' +NC='\033[0m' # No Color + +echo_error() { + printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2 +} + +echo_info() { + printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1" +} + +echo_warning() { + printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1" +} + +echo_note() { + printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1" +} + +# Check if the user is root and set sudo variable if necessary +check_root() { + if [ "$(id -u)" -ne 0 ]; then + if command_exists sudo; then + echo_info "User is not root. Using sudo for privileged operations." + _sudo="sudo" + else + echo_error "No sudo found and you're not root! Can't install packages." + return 1 + fi + else + echo_info "Root access confirmed." + _sudo="" + fi +} + +# < Distribution detection and installation > +get_packager() { + if [ -e /etc/os-release ]; then + echo_info "Detecting distribution..." + . /etc/os-release + + # < Convert $ID and $ID_LIKE to lowercase > + ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]') + ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]') + + case "$ID" in + ubuntu | pop) _install() { + $_sudo apt-get install "$@" --assume-yes + } ;; + debian) _install() { + $_sudo apt-get install "$@" --assume-yes + } ;; + fedora) _install() { + $_sudo dnf install "$@" -y + } ;; + alpine) _install() { + $_sudo apk add "$@" + } ;; + arch | manjaro | garuda | endeavour) _install() { + $_sudo pacman -S "$@" --noconfirm + } ;; + opensuse*) _install() { $_sudo zypper in "$@" -y; } ;; + *) + if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then + _install() { $_sudo apt-get install "$@" --assume-yes; } + elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then + _install() { $_sudo apt-get install "$@" --assume-yes; } + elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then + _install() { $_sudo pacman -S "$@" --noconfirm; } + elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then + _install() { $_sudo dnf install "$@" -y; } + elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then + _install() { $_sudo zypper in "$@" -y; } + else + echo_error "Unsupported distribution: $ID" + exit 1 + fi + ;; + esac + else + echo_error "Unable to detect distribution. /etc/os-release not found." + exit 1 + fi +} + +# Check if a command exists +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + +# Install dependencies +_dependencies() { + tools="git cmake make" + packages="libuv1-dev libssl-dev libhwloc-dev" + + for tool in $tools; do + if command_exists "$tool"; then + echo_note "$tool is already installed" + else + echo_info "Installing $tool.." + _install "$tool" || echo_error "Failed to install $tool" + fi + done + + for package in $packages; do + echo_info "Installing $package" + _install "$package" || echo_error "Failed to install $package" + done + + echo_note "Dependency check completed!" +} + +# Clone the repository and prepare build directory +_git() { + xmrig_dir="$HOME/.bin/xmrig" + + if [ -d "$xmrig_dir" ]; then + echo_warning "$xmrig_dir already exists. Skipping clone." + else + echo_info "Cloning xmrig repository to $xmrig_dir" + mkdir -p "$HOME/.bin" + if ! git clone --depth=1 https://github.com/xmrig/xmrig.git "$xmrig_dir"; then + echo_error "Failed to clone xmrig repository." + return 1 + fi + fi + + build_dir="$xmrig_dir/build" + mkdir -p "$build_dir" || { + echo_error "Failed to create build directory: $build_dir" + return 1 + } + + cd "$build_dir" || { + echo_error "Failed to navigate to build directory: $build_dir" + return 1 + } +} + +# Initialize and build the application +_appinit() { + echo_info "Running cmake .." + if ! cmake ..; then + echo_error "CMake failed." + return 1 + fi + + echo_info "Running make (this could take a while)" + if ! make; then + echo_error "Make failed." + return 1 + fi + + $_sudo ln -s ./xmrig /usr/bin/xmrig || "Link of application failed hard! Is not accessible at /usr/bin/xmrig" +} + +# Main function +main() { + if ! check_root; then + echo_error "Root check failed. Exiting." + return 1 + fi + + if ! get_packager; then + echo_error "Failed to detect distribution or set packager." + return 1 + fi + + _dependencies || return 1 + + if _git; then + _appinit || echo_error "Build initialization failed." + else + echo_error "Failed during Git operations." + fi +} + +main diff --git a/core/tabs/applications-setup/yazi.sh b/core/tabs/applications-setup/yazi.sh new file mode 100644 index 0000000..73f22ed --- /dev/null +++ b/core/tabs/applications-setup/yazi.sh @@ -0,0 +1,135 @@ +#!/bin/sh -e + +# ─< ANSI color codes >─────────────────────────────────────────────────────────────────── +RED='\033[0;31m' +CYAN='\033[0;36m' +YELLOW='\033[0;33m' +LIGHT_GREEN='\033[0;92m' +BOLD='\033[1m' +NC='\033[0m' # No Color + +echo_error() { + printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2 +} + +echo_info() { + printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1" +} + +echo_warning() { + printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1" +} + +echo_note() { + printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1" +} + +# ─< Check if the given command exists silently >───────────────────────────────────────── +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + +# ─< Check if the user is root and set sudo variable if necessary >─────────────────────── +check_root() { + if [ "$(id -u)" -ne 0 ]; then + if command_exists sudo; then + echo_info "User is not root. Using sudo for privileged operations." + _sudo="sudo" + else + echo_error "No sudo found and you're not root! Can't install packages." + return 1 + fi + else + echo_info "Root access confirmed." + _sudo="" + fi +} + +i_cargo() { + # if ! command_exists make || ! command_exists gcc; then + # echo_error "The script might run into issues, because of make and gcc not being installed. Please install it, and run the script again, if it fails!" + # fi + + if command_exists cargo; then + echo_info "Installing yazi through cargo" + cargo install --locked yazi-fm yazi-cli + elif command_exists curl; then + echo_note "no cargo found, using curl to install rustup" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + rustup update + echo_info "Installing yazi through cargo" + cargo install --locked yazi-fm yazi-cli + else + echo_warning "neither cargo, nor curl were found. Cannot continue!" + fi + + c_yazi +} + +i_arch() { + $_sudo pacman -S yazi --noconfirm + c_yazi +} + +i_opensuse() { + $_sudo zypper install yazi + c_yazi +} + +c_yazi() { + if [ -e "$HOME/.config/yazi/package.toml" ]; then + if command_exists ya; then + ya pack -i + fi + else + echo_warning "There was no yazi config found.. " + fi +} + +# ─< Distribution detection and installation >──────────────────────────────────────── +get_packager() { + if [ -e /etc/os-release ]; then + echo_info "Detecting distribution..." + . /etc/os-release + + # ─< Convert $ID and $ID_LIKE to lowercase >────────────────────────────────────────────── + ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]') + ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]') + + case "$ID" in + ubuntu | pop) i_cargo ;; + debian) i_cargo ;; + fedora) i_cargo ;; + alpine) i_cargo ;; + arch | manjaro | garuda | endeavour) i_arch ;; + opensuse*) i_opensuse ;; + *) + if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then + i_cargo + elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then + i_cargo + elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then + i_arch + elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then + i_cargo + elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then + i_opensuse + else + echo_error "Unsupported distribution: $ID" + exit 1 + fi + ;; + esac + else + echo_error "Unable to detect distribution. /etc/os-release not found." + exit 1 + fi +} + +main() { + if check_root; then + get_packager + fi +} + +main diff --git a/core/tabs/applications-setup/ytgo.sh b/core/tabs/applications-setup/ytgo.sh new file mode 100644 index 0000000..1ef873e --- /dev/null +++ b/core/tabs/applications-setup/ytgo.sh @@ -0,0 +1,153 @@ +#!/bin/sh -e + +# ╭───────────────╮ +# │ env functions │ +# ╰───────────────╯ +# ───────────────────────────────────< ANSI color codes >─────────────────────────────────── +RED='\033[0;31m' +CYAN='\033[0;36m' +YELLOW='\033[0;33m' +LIGHT_GREEN='\033[0;92m' +BOLD='\033[1m' +NC='\033[0m' # No Color + +echo_error() { + printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2 +} + +echo_info() { + printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1" +} + +echo_warning() { + printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1" +} + +echo_note() { + printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1" +} + +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + +# ─────────────< Check if the user is root and set sudo variable if necessary >───────────── +check_root() { + if [ "$(id -u)" -ne 0 ]; then + if command_exists sudo; then + echo_info "User is not root. Using sudo for privileged operations." + _sudo="sudo" + else + echo_error "No sudo found and you're not root! Can't install packages." + return 1 + fi + else + echo_info "Root access confirmed." + _sudo="" + fi +} + +# ──────────────────────< Check if the given command exists silently >────────────────────── +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + +# ╭────────────────────────────────────╮ +# │ insert your scripts/functions here │ +# ╰────────────────────────────────────╯ + +# ─< Distribution detection and installation >──────────────────────────────────────── +get_packager() { + if [ -e /etc/os-release ]; then + echo_info "Detecting distribution..." + . /etc/os-release + + # ─< Convert $ID and $ID_LIKE to lowercase >────────────────────────────────────────────── + ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]') + ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]') + + case "$ID" in + ubuntu | pop) _install() { + $_sudo apt-get install --assume-yes "$@" + } ;; + debian) _install() { + $_sudo apt-get install --assume-yes "$@" + } ;; + fedora) _install() { + $_sudo dnf install -y "$@" + } ;; + alpine) inst_alpine ;; + arch | manjaro | garuda | endeavour) _install() { + $_sudo pacman -S --noconfirm "$@" + } ;; + opensuse*) inst_opensuse ;; + *) + if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then + _install() { + $_sudo apt-get install --assume-yes "$@" + } + elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then + _install() { + $_sudo apt-get install --assume-yes "$@" + } + elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then + _install() { + $_sudo pacman -S --noconfirm "$@" + } + elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then + _install() { + $_sudo dnf install -y "$@" + } + elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then + inst_opensuse + else + echo_error "Unsupported distribution: $ID" + exit 1 + fi + ;; + esac + else + echo_error "Unable to detect distribution. /etc/os-release not found." + exit 1 + fi +} + +_dependencies() { + get_packager + _deps="golang git mpv" + + for dependency in $_deps; do + if ! command_exists "$dependency"; then + echo_info "Installing $dependency" + _install "$dependency" || echo_error "$dependency could not be installed!" + else + echo_note "$dependency - was already installed." + fi + done +} + +_clone() { + tmpdir="$(mktemp --dir)" + repo="https://git.k4li.de/pika/ytgo.git" + + cd "$tmpdir" || echo_error "$tmpdir is not a valid directory!" + git clone --depth=1 "$repo" + cd ytgo || echo_error "$tmpdir/ytgo is not a valid directory!" +} + +_build() { + $_sudo make install +} + +# ───────────────────────────────< main function to execute >─────────────────────────────── +main() { + if check_root; then + _dependencies || echo_error "dependency function failed hard!" + _clone || echo_error "clone function failed hard!" + _build || echo_error "build function failed hard!" + else + echo_error "Something went terribly wrong!" + fi +} + +main diff --git a/core/tabs/common-script.sh b/core/tabs/common-script.sh new file mode 100644 index 0000000..12ab114 --- /dev/null +++ b/core/tabs/common-script.sh @@ -0,0 +1,135 @@ +#!/bin/sh -e + +# shellcheck disable=SC2034 + +RC='\033[0m' +RED='\033[31m' +YELLOW='\033[33m' +CYAN='\033[36m' +GREEN='\033[32m' + +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +checkAURHelper() { + ## Check & Install AUR helper + if [ "$PACKAGER" = "pacman" ]; then + if [ -z "$AUR_HELPER_CHECKED" ]; then + AUR_HELPERS="yay paru" + for helper in ${AUR_HELPERS}; do + if command_exists "${helper}"; then + AUR_HELPER=${helper} + printf "%b\n" "${CYAN}Using ${helper} as AUR helper${RC}" + AUR_HELPER_CHECKED=true + return 0 + fi + done + + printf "%b\n" "${YELLOW}Installing yay as AUR helper...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel git + cd /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/yay-bin.git && "$ESCALATION_TOOL" chown -R "$USER":"$USER" ./yay-bin + cd yay-bin && makepkg --noconfirm -si + + if command_exists yay; then + AUR_HELPER="yay" + AUR_HELPER_CHECKED=true + else + printf "%b\n" "${RED}Failed to install AUR helper.${RC}" + exit 1 + fi + fi + fi +} + +checkEscalationTool() { + ## Check for escalation tools. + if [ -z "$ESCALATION_TOOL_CHECKED" ]; then + ESCALATION_TOOLS='sudo doas' + for tool in ${ESCALATION_TOOLS}; do + if command_exists "${tool}"; then + ESCALATION_TOOL=${tool} + printf "%b\n" "${CYAN}Using ${tool} for privilege escalation${RC}" + ESCALATION_TOOL_CHECKED=true + return 0 + fi + done + + printf "%b\n" "${RED}Can't find a supported escalation tool${RC}" + exit 1 + fi +} + +checkCommandRequirements() { + ## Check for requirements. + REQUIREMENTS=$1 + for req in ${REQUIREMENTS}; do + if ! command_exists "${req}"; then + printf "%b\n" "${RED}To run me, you need: ${REQUIREMENTS}${RC}" + exit 1 + fi + done +} + +checkPackageManager() { + ## Check Package Manager + PACKAGEMANAGER=$1 + for pgm in ${PACKAGEMANAGER}; do + if command_exists "${pgm}"; then + PACKAGER=${pgm} + printf "%b\n" "${CYAN}Using ${pgm} as package manager${RC}" + break + fi + done + + if [ -z "$PACKAGER" ]; then + printf "%b\n" "${RED}Can't find a supported package manager${RC}" + exit 1 + fi +} + +checkSuperUser() { + ## Check SuperUser Group + SUPERUSERGROUP='wheel sudo root' + for sug in ${SUPERUSERGROUP}; do + if groups | grep -q "${sug}"; then + SUGROUP=${sug} + printf "%b\n" "${CYAN}Super user group ${SUGROUP}${RC}" + break + fi + done + + ## Check if member of the sudo group. + if ! groups | grep -q "${SUGROUP}"; then + printf "%b\n" "${RED}You need to be a member of the sudo group to run me!${RC}" + exit 1 + fi +} + +checkCurrentDirectoryWritable() { + ## Check if the current directory is writable. + GITPATH="$(dirname "$(realpath "$0")")" + if [ ! -w "$GITPATH" ]; then + printf "%b\n" "${RED}Can't write to $GITPATH${RC}" + exit 1 + fi +} + +checkDistro() { + DTYPE="unknown" # Default to unknown + # Use /etc/os-release for modern distro identification + if [ -f /etc/os-release ]; then + . /etc/os-release + DTYPE=$ID + fi +} + +checkEnv() { + checkEscalationTool + checkCommandRequirements "curl groups $ESCALATION_TOOL" + checkPackageManager 'nala apt-get dnf pacman zypper' + checkCurrentDirectoryWritable + checkSuperUser + checkDistro + checkAURHelper +} diff --git a/core/tabs/system-setup/arch/paru-setup.sh b/core/tabs/system-setup/arch/paru-setup.sh new file mode 100755 index 0000000..fba445e --- /dev/null +++ b/core/tabs/system-setup/arch/paru-setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh -e + +. ../../common-script.sh + +installDepend() { + case "$PACKAGER" in + pacman) + if ! command_exists paru; then + printf "%b\n" "${YELLOW}Installing paru as AUR helper...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel git + cd /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/paru.git && "$ESCALATION_TOOL" chown -R "$USER": ./paru + cd paru && makepkg --noconfirm -si + printf "%b\n" "${GREEN}Paru installed${RC}" + else + printf "%b\n" "${GREEN}Paru already installed${RC}" + fi + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + ;; + esac +} + +checkEnv +checkEscalationTool +installDepend diff --git a/core/tabs/system-setup/arch/server-setup.sh b/core/tabs/system-setup/arch/server-setup.sh new file mode 100755 index 0000000..3a385df --- /dev/null +++ b/core/tabs/system-setup/arch/server-setup.sh @@ -0,0 +1,673 @@ +#!/bin/bash + +# Redirect stdout and stderr to archsetup.txt and still output to console +exec > >(tee -i archsetup.txt) +exec 2>&1 + +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ +██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ +███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ +██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ +██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ +╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- + +Verifying Arch Linux ISO is Booted + +" +if [ ! -f /usr/bin/pacstrap ]; then + echo "This script must be run from an Arch Linux ISO environment." + exit 1 +fi + +root_check() { + if [[ "$(id -u)" != "0" ]]; then + echo -ne "ERROR! This script must be run under the 'root' user!\n" + exit 0 + fi +} + +docker_check() { + if awk -F/ '$2 == "docker"' /proc/self/cgroup | read -r; then + echo -ne "ERROR! Docker container is not supported (at the moment)\n" + exit 0 + elif [[ -f /.dockerenv ]]; then + echo -ne "ERROR! Docker container is not supported (at the moment)\n" + exit 0 + fi +} + +arch_check() { + if [[ ! -e /etc/arch-release ]]; then + echo -ne "ERROR! This script must be run in Arch Linux!\n" + exit 0 + fi +} + +pacman_check() { + if [[ -f /var/lib/pacman/db.lck ]]; then + echo "ERROR! Pacman is blocked." + echo -ne "If not running remove /var/lib/pacman/db.lck.\n" + exit 0 + fi +} + +background_checks() { + root_check + arch_check + pacman_check + docker_check +} + +select_option() { + local options=("$@") + local num_options=${#options[@]} + local selected=0 + local last_selected=-1 + + while true; do + # Move cursor up to the start of the menu + if [ $last_selected -ne -1 ]; then + echo -ne "\033[${num_options}A" + fi + + if [ $last_selected -eq -1 ]; then + echo "Please select an option using the arrow keys and Enter:" + fi + for i in "${!options[@]}"; do + if [ "$i" -eq $selected ]; then + echo "> ${options[$i]}" + else + echo " ${options[$i]}" + fi + done + + last_selected=$selected + + # Read user input + read -rsn1 key + case $key in + $'\x1b') # ESC sequence + read -rsn2 -t 0.1 key + case $key in + '[A') # Up arrow + ((selected--)) + if [ $selected -lt 0 ]; then + selected=$((num_options - 1)) + fi + ;; + '[B') # Down arrow + ((selected++)) + if [ $selected -ge $num_options ]; then + selected=0 + fi + ;; + esac + ;; + '') # Enter key + break + ;; + esac + done + + return $selected +} + +# @description Displays ArchTitus logo +# @noargs +logo () { +# This will be shown on every set as user is progressing +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ +██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ +███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ +██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ +██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ +╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------ + Please select presetup settings for your system +------------------------------------------------------------------------ +" +} +# @description This function will handle file systems. At this movement we are handling only +# btrfs and ext4. Others will be added in future. +filesystem () { + echo -ne " + Please Select your file system for both boot and root + " + options=("btrfs" "ext4" "luks" "exit") + select_option "${options[@]}" + + case $? in + 0) export FS=btrfs;; + 1) export FS=ext4;; + 2) + set_password "LUKS_PASSWORD" + export FS=luks + ;; + 3) exit ;; + *) echo "Wrong option please select again"; filesystem;; + esac +} + +# @description Detects and sets timezone. +timezone () { + # Added this from arch wiki https://wiki.archlinux.org/title/System_time + time_zone="$(curl --fail https://ipapi.co/timezone)" + echo -ne " + System detected your timezone to be '$time_zone' \n" + echo -ne "Is this correct? + " + options=("Yes" "No") + select_option "${options[@]}" + + case ${options[$?]} in + y|Y|yes|Yes|YES) + echo "${time_zone} set as timezone" + export TIMEZONE=$time_zone;; + n|N|no|NO|No) + echo "Please enter your desired timezone e.g. Europe/London :" + read -r new_timezone + echo "${new_timezone} set as timezone" + export TIMEZONE=$new_timezone;; + *) echo "Wrong option. Try again";timezone;; + esac +} +# @description Set user's keyboard mapping. +keymap () { + echo -ne " + Please select key board layout from this list" + # These are default key maps as presented in official arch repo archinstall + options=(us by ca cf cz de dk es et fa fi fr gr hu il it lt lv mk nl no pl ro ru se sg ua uk) + + select_option "${options[@]}" + keymap=${options[$?]} + + echo -ne "Your key boards layout: ${keymap} \n" + export KEYMAP=$keymap +} + +# @description Choose whether drive is SSD or not. +drivessd () { + echo -ne " + Is this an ssd? yes/no: + " + + options=("Yes" "No") + select_option "${options[@]}" + + case ${options[$?]} in + y|Y|yes|Yes|YES) + export MOUNT_OPTIONS="noatime,compress=zstd,ssd,commit=120";; + n|N|no|NO|No) + export MOUNT_OPTIONS="noatime,compress=zstd,commit=120";; + *) echo "Wrong option. Try again";drivessd;; + esac +} + +# @description Disk selection for drive to be used with installation. +diskpart () { +echo -ne " +------------------------------------------------------------------------ + THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK + Please make sure you know what you are doing because + after formatting your disk there is no way to get data back + *****BACKUP YOUR DATA BEFORE CONTINUING***** + ***I AM NOT RESPONSIBLE FOR ANY DATA LOSS*** +------------------------------------------------------------------------ + +" + + PS3=' + Select the disk to install on: ' + options=($(lsblk -n --output TYPE,KNAME,SIZE | awk '$1=="disk"{print "/dev/"$2"|"$3}')) + + select_option "${options[@]}" + disk=${options[$?]%|*} + + echo -e "\n${disk%|*} selected \n" + export DISK=${disk%|*} + + drivessd +} + +# @description Gather username and password to be used for installation. +userinfo () { + # Loop through user input until the user gives a valid username + while true + do + read -r -p "Please enter username: " username + if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]] + then + break + fi + echo "Incorrect username." + done + export USERNAME=$username + + while true + do + read -rs -p "Please enter password: " PASSWORD1 + echo -ne "\n" + read -rs -p "Please re-enter password: " PASSWORD2 + echo -ne "\n" + if [[ "$PASSWORD1" == "$PASSWORD2" ]]; then + break + else + echo -ne "ERROR! Passwords do not match. \n" + fi + done + export PASSWORD=$PASSWORD1 + + # Loop through user input until the user gives a valid hostname, but allow the user to force save + while true + do + read -r -p "Please name your machine: " name_of_machine + # hostname regex (!!couldn't find spec for computer name!!) + if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]] + then + break + fi + # if validation fails allow the user to force saving of the hostname + read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force + if [[ "${force,,}" = "y" ]] + then + break + fi + done + export NAME_OF_MACHINE=$name_of_machine +} + +# Starting functions +background_checks +clear +logo +userinfo +clear +logo +diskpart +clear +logo +filesystem +clear +logo +timezone +clear +logo +keymap + +echo "Setting up mirrors for optimal download" +iso=$(curl -4 ifconfig.co/country-iso) +timedatectl set-ntp true +pacman -Sy +pacman -S --noconfirm archlinux-keyring #update keyrings to latest to prevent packages failing to install +pacman -S --noconfirm --needed pacman-contrib terminus-font +setfont ter-v18b +sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf +pacman -S --noconfirm --needed reflector rsync grub +cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup +echo -ne " +------------------------------------------------------------------------- + Setting up $iso mirrors for faster downloads +------------------------------------------------------------------------- +" +reflector -a 48 -c "$iso" -f 5 -l 20 --sort rate --save /etc/pacman.d/mirrorlist +if [ ! -d "/mnt" ]; then + mkdir /mnt +fi +echo -ne " +------------------------------------------------------------------------- + Installing Prerequisites +------------------------------------------------------------------------- +" +pacman -S --noconfirm --needed gptfdisk btrfs-progs glibc +echo -ne " +------------------------------------------------------------------------- + Formatting Disk +------------------------------------------------------------------------- +" +umount -A --recursive /mnt # make sure everything is unmounted before we start +# disk prep +sgdisk -Z "${DISK}" # zap all on disk +sgdisk -a 2048 -o "${DISK}" # new gpt disk 2048 alignment + +# create partitions +sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' "${DISK}" # partition 1 (BIOS Boot Partition) +sgdisk -n 2::+1GiB --typecode=2:ef00 --change-name=2:'EFIBOOT' "${DISK}" # partition 2 (UEFI Boot Partition) +sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' "${DISK}" # partition 3 (Root), default start, remaining +if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system + sgdisk -A 1:set:2 "${DISK}" +fi +partprobe "${DISK}" # reread partition table to ensure it is correct + +# make filesystems +echo -ne " +------------------------------------------------------------------------- + Creating Filesystems +------------------------------------------------------------------------- +" +# @description Creates the btrfs subvolumes. +createsubvolumes () { + btrfs subvolume create /mnt/@ + btrfs subvolume create /mnt/@home +} + +# @description Mount all btrfs subvolumes after root has been mounted. +mountallsubvol () { + mount -o "${MOUNT_OPTIONS}",subvol=@home "${partition3}" /mnt/home +} + +# @description BTRFS subvolulme creation and mounting. +subvolumesetup () { +# create nonroot subvolumes + createsubvolumes +# unmount root to remount with subvolume + umount /mnt +# mount @ subvolume + mount -o "${MOUNT_OPTIONS}",subvol=@ "${partition3}" /mnt +# make directories home, .snapshots, var, tmp + mkdir -p /mnt/home +# mount subvolumes + mountallsubvol +} + +if [[ "${DISK}" =~ "nvme" ]]; then + partition2=${DISK}p2 + partition3=${DISK}p3 +else + partition2=${DISK}2 + partition3=${DISK}3 +fi + +if [[ "${FS}" == "btrfs" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" "${partition2}" + mkfs.btrfs -L ROOT "${partition3}" -f + mount -t btrfs "${partition3}" /mnt + subvolumesetup +elif [[ "${FS}" == "ext4" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" "${partition2}" + mkfs.ext4 -L ROOT "${partition3}" + mount -t ext4 "${partition3}" /mnt +elif [[ "${FS}" == "luks" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" "${partition2}" +# enter luks password to cryptsetup and format root partition + echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat "${partition3}" - +# open luks container and ROOT will be place holder + echo -n "${LUKS_PASSWORD}" | cryptsetup open "${partition3}" ROOT - +# now format that container + mkfs.btrfs -L ROOT "${partition3}" +# create subvolumes for btrfs + mount -t btrfs "${partition3}" /mnt + subvolumesetup +fi + +sync +if ! mountpoint -q /mnt; then + echo "ERROR! Failed to mount ${partition3} to /mnt after multiple attempts." + exit 1 +fi +mkdir -p /mnt/boot/efi +mount -t vfat -L EFIBOOT /mnt/boot/ + +if ! grep -qs '/mnt' /proc/mounts; then + echo "Drive is not mounted can not continue" + echo "Rebooting in 3 Seconds ..." && sleep 1 + echo "Rebooting in 2 Seconds ..." && sleep 1 + echo "Rebooting in 1 Second ..." && sleep 1 + reboot now +fi + +echo -ne " +------------------------------------------------------------------------- + Arch Install on Main Drive +------------------------------------------------------------------------- +" +if [[ ! -d "/sys/firmware/efi" ]]; then + pacstrap /mnt base base-devel linux-lts linux-firmware --noconfirm --needed +else + pacstrap /mnt base base-devel linux-lts linux-firmware efibootmgr --noconfirm --needed +fi +echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf +cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist + +genfstab -L /mnt >> /mnt/etc/fstab +echo " + Generated /etc/fstab: +" +cat /mnt/etc/fstab +echo -ne " +------------------------------------------------------------------------- + GRUB BIOS Bootloader Install & Check +------------------------------------------------------------------------- +" +if [[ ! -d "/sys/firmware/efi" ]]; then + grub-install --boot-directory=/mnt/boot "${DISK}" +fi +echo -ne " +------------------------------------------------------------------------- + Checking for low memory systems <8G +------------------------------------------------------------------------- +" +TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') +if [[ $TOTAL_MEM -lt 8000000 ]]; then + # Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything. + mkdir -p /mnt/opt/swap # make a dir that we can apply NOCOW to to make it btrfs-friendly. + if findmnt -n -o FSTYPE /mnt | grep -q btrfs; then + chattr +C /mnt/opt/swap # apply NOCOW, btrfs needs that. + fi + dd if=/dev/zero of=/mnt/opt/swap/swapfile bs=1M count=2048 status=progress + chmod 600 /mnt/opt/swap/swapfile # set permissions. + chown root /mnt/opt/swap/swapfile + mkswap /mnt/opt/swap/swapfile + swapon /mnt/opt/swap/swapfile + # The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself. + echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation. +fi + +gpu_type=$(lspci | grep -E "VGA|3D|Display") + +arch-chroot /mnt /bin/bash -c "KEYMAP='${KEYMAP}' /bin/bash" < /etc/vconsole.conf +echo "XKBLAYOUT=${KEYMAP}" >> /etc/vconsole.conf +echo "Keymap set to: ${KEYMAP}" + +# Add sudo no password rights +sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers +sed -i 's/^# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers + +#Add parallel downloading +sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf + +#Enable multilib +sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf +pacman -Sy --noconfirm --needed + +echo -ne " +------------------------------------------------------------------------- + Installing Microcode +------------------------------------------------------------------------- +" +# determine processor type and install microcode +if grep -q "GenuineIntel" /proc/cpuinfo; then + echo "Installing Intel microcode" + pacman -S --noconfirm --needed intel-ucode +elif grep -q "AuthenticAMD" /proc/cpuinfo; then + echo "Installing AMD microcode" + pacman -S --noconfirm --needed amd-ucode +else + echo "Unable to determine CPU vendor. Skipping microcode installation." +fi + +echo -ne " +------------------------------------------------------------------------- + Installing Graphics Drivers +------------------------------------------------------------------------- +" +# Graphics Drivers find and install +if echo "${gpu_type}" | grep -E "NVIDIA|GeForce"; then + echo "Installing NVIDIA drivers: nvidia-lts" + pacman -S --noconfirm --needed nvidia-lts +elif echo "${gpu_type}" | grep 'VGA' | grep -E "Radeon|AMD"; then + echo "Installing AMD drivers: xf86-video-amdgpu" + pacman -S --noconfirm --needed xf86-video-amdgpu +elif echo "${gpu_type}" | grep -E "Integrated Graphics Controller"; then + echo "Installing Intel drivers:" + pacman -S --noconfirm --needed libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa +elif echo "${gpu_type}" | grep -E "Intel Corporation UHD"; then + echo "Installing Intel UHD drivers:" + pacman -S --noconfirm --needed libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa +fi + +echo -ne " +------------------------------------------------------------------------- + Adding User +------------------------------------------------------------------------- +" +groupadd libvirt +useradd -m -G wheel,libvirt -s /bin/bash $USERNAME +echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash" +echo "$USERNAME:$PASSWORD" | chpasswd +echo "$USERNAME password set" +echo $NAME_OF_MACHINE > /etc/hostname + +if [[ ${FS} == "luks" ]]; then +# Making sure to edit mkinitcpio conf if luks is selected +# add encrypt in mkinitcpio.conf before filesystems in hooks + sed -i 's/filesystems/encrypt filesystems/g' /etc/mkinitcpio.conf +# making mkinitcpio with linux kernel + mkinitcpio -p linux-lts +fi + +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ +██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ +███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ +██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ +██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ +╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- + +Final Setup and Configurations +GRUB EFI Bootloader Install & Check +" + +if [[ -d "/sys/firmware/efi" ]]; then + grub-install --efi-directory=/boot ${DISK} +fi + +echo -ne " +------------------------------------------------------------------------- + Creating (and Theming) Grub Boot Menu +------------------------------------------------------------------------- +" +# set kernel parameter for decrypting the drive +if [[ "${FS}" == "luks" ]]; then +sed -i "s%GRUB_CMDLINE_LINUX_DEFAULT=\"%GRUB_CMDLINE_LINUX_DEFAULT=\"cryptdevice=UUID=${ENCRYPTED_PARTITION_UUID}:ROOT root=/dev/mapper/ROOT %g" /etc/default/grub +fi +# set kernel parameter for adding splash screen +sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& splash /' /etc/default/grub + +echo -e "Installing CyberRe Grub theme..." +THEME_DIR="/boot/grub/themes/CyberRe" +echo -e "Creating the theme directory..." +mkdir -p "${THEME_DIR}" + +# Clone the theme +cd "${THEME_DIR}" || exit +git init +git remote add -f origin https://github.com/ChrisTitusTech/Top-5-Bootloader-Themes.git +git config core.sparseCheckout true +echo "themes/CyberRe/*" >> .git/info/sparse-checkout +git pull origin main +mv themes/CyberRe/* . +rm -rf themes +rm -rf .git + +echo "CyberRe theme has been cloned to ${THEME_DIR}" +echo -e "Backing up Grub config..." +cp -an /etc/default/grub /etc/default/grub.bak +echo -e "Setting the theme as the default..." +grep "GRUB_THEME=" /etc/default/grub 2>&1 >/dev/null && sed -i '/GRUB_THEME=/d' /etc/default/grub +echo "GRUB_THEME=\"${THEME_DIR}/theme.txt\"" >> /etc/default/grub +echo -e "Updating grub..." +grub-mkconfig -o /boot/grub/grub.cfg +echo -e "All set!" + +echo -ne " +------------------------------------------------------------------------- + Enabling Essential Services +------------------------------------------------------------------------- +" +ntpd -qg +systemctl enable ntpd.service +echo " NTP enabled" +systemctl disable dhcpcd.service +echo " DHCP disabled" +systemctl stop dhcpcd.service +echo " DHCP stopped" +systemctl enable NetworkManager.service +echo " NetworkManager enabled" + +echo -ne " +------------------------------------------------------------------------- + Cleaning +------------------------------------------------------------------------- +" +# Remove no password sudo rights +sed -i 's/^%wheel ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers +sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers +# Add sudo rights +sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers +sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers +EOF diff --git a/core/tabs/system-setup/arch/yay-setup.sh b/core/tabs/system-setup/arch/yay-setup.sh new file mode 100755 index 0000000..fd80f1f --- /dev/null +++ b/core/tabs/system-setup/arch/yay-setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh -e + +. ../../common-script.sh + +installDepend() { + case "$PACKAGER" in + pacman) + if ! command_exists yay; then + printf "%b\n" "${YELLOW}Installing yay as AUR helper...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel git + cd /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/yay-bin.git && "$ESCALATION_TOOL" chown -R "$USER": ./yay-bin + cd yay-bin && makepkg --noconfirm -si + printf "%b\n" "${GREEN}Yay installed${RC}" + else + printf "%b\n" "${GREEN}Aur helper already installed${RC}" + fi + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + ;; + esac +} + +checkEnv +checkEscalationTool +installDepend diff --git a/core/tabs/system-setup/fedora/configure-dnf.sh b/core/tabs/system-setup/fedora/configure-dnf.sh new file mode 100644 index 0000000..977ea6d --- /dev/null +++ b/core/tabs/system-setup/fedora/configure-dnf.sh @@ -0,0 +1,23 @@ +#!/bin/sh -e + +. ../../common-script.sh + +configureDNF() { + case "$PACKAGER" in + dnf) + printf "%b\n" "${YELLOW}Configuring DNF...${RC}" + "$ESCALATION_TOOL" sed -i '/^max_parallel_downloads=/c\max_parallel_downloads=10' /etc/dnf/dnf.conf || echo 'max_parallel_downloads=10' >> /etc/dnf/dnf.conf + echo "fastestmirror=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null + echo "defaultyes=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null + "$ESCALATION_TOOL" "$PACKAGER" -y install dnf-plugins-core + printf "%b\n" "${GREEN}DNF Configured Successfully.${RC}" + ;; + *) + printf "%b\n" "${RED}Unsupported distribution: $DTYPE${RC}" + ;; + esac +} + +checkEnv +checkEscalationTool +configureDNF diff --git a/core/tabs/system-setup/fedora/multimedia-codecs.sh b/core/tabs/system-setup/fedora/multimedia-codecs.sh new file mode 100644 index 0000000..751e454 --- /dev/null +++ b/core/tabs/system-setup/fedora/multimedia-codecs.sh @@ -0,0 +1,26 @@ +#!/bin/sh -e + +. ../../common-script.sh + +multimedia() { + case "$PACKAGER" in + dnf) + if [ -e /etc/yum.repos.d/rpmfusion-free.repo ] && [ -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then + printf "%b\n" "${YELLOW}Installing Multimedia Codecs...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" swap ffmpeg-free ffmpeg --allowerasing -y + "$ESCALATION_TOOL" "$PACKAGER" update @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin -y + "$ESCALATION_TOOL" "$PACKAGER" update @sound-and-video -y + printf "%b\n" "${GREEN}Multimedia Codecs Installed...${RC}" + else + printf "%b\n" "${RED}RPM Fusion repositories not found. Please set up RPM Fusion first!${RC}" + fi + ;; + *) + printf "%b\n" "${RED}Unsupported distribution: $DTYPE${RC}" + ;; + esac +} + +checkEnv +checkEscalationTool +multimedia \ No newline at end of file diff --git a/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh b/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh new file mode 100755 index 0000000..e123e8f --- /dev/null +++ b/core/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh @@ -0,0 +1,94 @@ +#!/bin/sh -e + +. ../../common-script.sh +# This script allows user to download proprietary drivers for nvidia in fedora + +# It also disables nouveau nvidia drivers + +# Installation guide link: https://rpmfusion.org/Howto/NVIDIA + +# NOTE: Currently script only provides drivers for gpu 2014 and above (510+ and above) + +checkRepo() { + REPO_ID="rpmfusion-nonfree-nvidia-driver" + + if [ "$(dnf repolist enabled 2>/dev/null | grep -c "$REPO_ID")" -gt 0 ]; then + printf "%b\n" "${GREEN}Nvidia non-free repository is already enabled.${RC}" + else + printf "%b\n" "${YELLOW}Nvidia non-free repository is not enabled. Enabling now...${RC}" + + # Enable the repository + "$ESCALATION_TOOL" dnf config-manager --set-enabled "$REPO_ID" + + # Refreshing repository list + "$ESCALATION_TOOL" dnf makecache + + # Verify if the repository is enabled + if [ "$(dnf repolist enabled 2>/dev/null | grep -c "$REPO_ID")" -gt 0 ]; then + printf "%b\n" "${GREEN}Nvidia non-free repository is now enabled...${RC}" + else + printf "%b\n" "${RED}Failed to enable nvidia non-free repository...${RC}" + exit 1 + fi + fi +} + +checkDriverInstallation() { + if modinfo -F version nvidia >/dev/null 2>&1; then + return 0 + else + return 1 + fi +} + +installDriver() { + + if checkDriverInstallation; then + printf "%b\n" "${GREEN}NVIDIA driver is already installed.${RC}" + exit 0 + fi + + # NOTE:: Installing graphics driver. + "$ESCALATION_TOOL" dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y + printf "%b\n" "${YELLOW}Building the drivers may take upto 5 minutes. Please don't kill the script!\n If the build failed try running the script again, select \"Remove Nvidia Drivers\" and reboot the system, then try installing drivers again.${RC}" + + for i in $(seq 1 5); do + if checkDriverInstallation; then + printf "%b\n" "${GREEN}Driver installed successfully.${RC}" + printf "%b\n" "${GREEN}Installed driver version $(modinfo -F version nvidia)${RC}" + break + fi + printf "%b\n" "${YELLOW}Waiting for driver to be built..." + sleep 1m + done + + printf "%b\n" "${GREEN}Now you can reboot the system.${RC}" + +} + +# NOTE: A confirmation option to proceed or not +userConfirmation() { + printf "%b" "${YELLOW}Do you want to continue? (y/N): ${RC}" + read -r choice + case "$choice" in + y | Y) + checkRepo + installDriver + return + ;; + n | N) + printf "%b\n" "${RED} Exiting the Script ${RC}" + return + ;; + *) + printf "%b\n" "${RED} Invalid Option! ${RC}" + userConfirmation + ;; + esac +} + +printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free repository and only install drivers for GPUs from 2014 or later. It works on fedora 34 and above.\n It is recommended remove this driver while updating your kernel packages to newer version.${RC}" + +checkEnv +checkEscalationTool +userConfirmation diff --git a/core/tabs/system-setup/fedora/rpm-fusion-setup.sh b/core/tabs/system-setup/fedora/rpm-fusion-setup.sh new file mode 100644 index 0000000..aeb7d24 --- /dev/null +++ b/core/tabs/system-setup/fedora/rpm-fusion-setup.sh @@ -0,0 +1,29 @@ +#!/bin/sh -e + +. ../../common-script.sh + +# https://rpmfusion.org/Configuration + +installRPMFusion() { + case "$PACKAGER" in + dnf) + if [ ! -e /etc/yum.repos.d/rpmfusion-free.repo ] || [ ! -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then + printf "%b\n" "${YELLOW}Installing RPM Fusion...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" install "https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm + "$ESCALATION_TOOL" "$PACKAGER" config-manager --enable fedora-cisco-openh264 + "$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled rpmfusion-nonfree-updates + "$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled rpmfusion-free-updates + printf "%b\n" "${GREEN}RPM Fusion installed and enabled${RC}" + else + printf "%b\n" "${GREEN}RPM Fusion already installed${RC}" + fi + ;; + *) + printf "%b\n" "${RED}Unsupported distribution: $DTYPE${RC}" + ;; + esac +} + +checkEnv +checkEscalationTool +installRPMFusion \ No newline at end of file diff --git a/core/tabs/system-setup/fedora/virtualization.sh b/core/tabs/system-setup/fedora/virtualization.sh new file mode 100644 index 0000000..3359efe --- /dev/null +++ b/core/tabs/system-setup/fedora/virtualization.sh @@ -0,0 +1,21 @@ +#!/bin/sh -e + +. ../../common-script.sh + +# Install virtualization tools to enable virtual machines +configureVirtualization() { + case "$PACKAGER" in + dnf) + printf "%b\n" "${YELLOW}Installing virtualization tools...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" install -y @virtualization + printf "%b\n" "${GREEN}Installed virtualization tools...${RC}" + ;; + *) + printf "%b\n" "${RED}Unsupported distribution: $DTYPE${RC}" + ;; + esac +} + +checkEnv +checkEscalationTool +configureVirtualization diff --git a/core/tabs/system-setup/gaming-setup.sh b/core/tabs/system-setup/gaming-setup.sh new file mode 100755 index 0000000..92c666c --- /dev/null +++ b/core/tabs/system-setup/gaming-setup.sh @@ -0,0 +1,106 @@ +#!/bin/sh -e + +. ../common-script.sh + +installDepend() { + # Check for dependencies + DEPENDENCIES='wine dbus' + printf "%b\n" "${YELLOW}Installing dependencies...${RC}" + case "$PACKAGER" in + pacman) + #Check for multilib + if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then + echo "[multilib]" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf + echo "Include = /etc/pacman.d/mirrorlist" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf + "$ESCALATION_TOOL" "$PACKAGER" -Syu + else + printf "%b\n" "${GREEN}Multilib is already enabled.${RC}" + fi + + DISTRO_DEPS="gnutls lib32-gnutls base-devel gtk2 gtk3 lib32-gtk2 lib32-gtk3 libpulse lib32-libpulse alsa-lib lib32-alsa-lib \ + alsa-utils alsa-plugins lib32-alsa-plugins alsa-lib lib32-alsa-lib giflib lib32-giflib libpng lib32-libpng \ + libldap lib32-libldap openal lib32-openal libxcomposite lib32-libxcomposite libxinerama lib32-libxinerama \ + ncurses lib32-ncurses vulkan-icd-loader lib32-vulkan-icd-loader ocl-icd lib32-ocl-icd libva lib32-libva \ + gst-plugins-base-libs lib32-gst-plugins-base-libs sdl2" + + $AUR_HELPER -S --needed --noconfirm $DEPENDENCIES $DISTRO_DEPS + ;; + apt-get|nala) + DISTRO_DEPS="libasound2 libsdl2 wine64 wine32" + + "$ESCALATION_TOOL" "$PACKAGER" update + "$ESCALATION_TOOL" dpkg --add-architecture i386 + "$ESCALATION_TOOL" "$PACKAGER" install -y software-properties-common + "$ESCALATION_TOOL" apt-add-repository contrib -y + "$ESCALATION_TOOL" "$PACKAGER" update + "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS + ;; + dnf) + if [ "$(rpm -E %fedora)" -le 41 ]; then + "$ESCALATION_TOOL" "$PACKAGER" install ffmpeg ffmpeg-libs -y + "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES + else + printf "%b\n" "${CYAN}Fedora < 41 detected. Installing rpmfusion repos.${RC}" + "$ESCALATION_TOOL" "$PACKAGER" install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm -y + "$ESCALATION_TOOL" "$PACKAGER" config-manager --enable fedora-cisco-openh264 -y + "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES + fi + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" -n install $DEPENDENCIES + ;; + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES + ;; + esac +} + +installAdditionalDepend() { + case "$PACKAGER" in + pacman) + DISTRO_DEPS='steam lutris goverlay' + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm $DISTRO_DEPS + ;; + apt-get|nala) + version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris | + grep -v 'beta' | + tail -n1 | + cut -d '/' --fields=3) + + version_no_v=$(echo "$version" | tr -d v) + curl -sSLo "lutris_${version_no_v}_all.deb" "https://github.com/lutris/lutris/releases/download/${version}/lutris_${version_no_v}_all.deb" + + printf "%b\n" "${YELLOW}Installing Lutris...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" install ./lutris_"${version_no_v}"_all.deb + + rm lutris_"${version_no_v}"_all.deb + + printf "%b\n" "${GREEN}Lutris Installation complete.${RC}" + printf "%b\n" "${YELLOW}Installing steam...${RC}" + + if lsb_release -i | grep -qi Debian; then + "$ESCALATION_TOOL" apt-add-repository non-free -y + "$ESCALATION_TOOL" "$PACKAGER" install steam-installer -y + else + "$ESCALATION_TOOL" "$PACKAGER" install -y steam + fi + ;; + dnf) + DISTRO_DEPS='steam lutris' + "$ESCALATION_TOOL" "$PACKAGER" install -y $DISTRO_DEPS + ;; + zypper) + # Flatpak + DISTRO_DEPS='lutris' + "$ESCALATION_TOOL" "$PACKAGER" -n install $DISTRO_DEPS + ;; + *) + ;; + esac +} + +checkEnv +checkAURHelper +checkEscalationTool +installDepend +installAdditionalDepend diff --git a/core/tabs/system-setup/postinstall.sh b/core/tabs/system-setup/postinstall.sh new file mode 100755 index 0000000..6ccff11 --- /dev/null +++ b/core/tabs/system-setup/postinstall.sh @@ -0,0 +1,466 @@ +#!/bin/sh -e + +# ANSI color codes +RED='\033[0;31m' +CYAN='\033[0;36m' +YELLOW='\033[0;33m' +LIGHT_GREEN='\033[0;92m' +BOLD='\033[1m' +NC='\033[0m' + +# Initialize storage variables +_STORED_ERRORS="" +_STORED_WARNINGS="" +_STORED_INFOS="" +_STORED_NOTES="" + +# Modified echo functions that store and display messages +echo_error() { + message="${RED}$1${NC}\n" + printf "$message" >&2 + _STORED_ERRORS="${_STORED_ERRORS}${message}" +} + +echo_warning() { + message="${YELLOW}$1${NC}\n" + printf "$message" + _STORED_WARNINGS="${_STORED_WARNINGS}${message}" +} + +echo_info() { + message="${CYAN}$1${NC}\n" + printf "$message" + _STORED_INFOS="${_STORED_INFOS}${message}" +} + +echo_note() { + message="${LIGHT_GREEN}$1${NC}\n" + printf "$message" + _STORED_NOTES="${_STORED_NOTES}${message}" +} + +echo_db() { + message="${LIGHT_GREEN}$1${NC}\n" + printf "$message" +} + +# ─< Check if the given command exists silently >───────────────────────────────────────── +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + +# ─< to get the alias to install everything either with your shell or inside your script! >─ +if command_exists curl; then + install_pkg() { + sh -c "$(curl -sSL https://git.k4li.de/pika/scripts/raw/branch/main/bash/snippets/install_pkg.sh)" -- "$@" + } +else + echo_error "curl is not installed, universal install disabled!" +fi + +# Check if the user is root and set sudo variable if necessary +check_root() { + if [ "$(id -u)" -ne 0 ]; then + if command_exists sudo; then + echo_info "User is not root. Using sudo for privileged operations." + _sudo="sudo" + else + echo_error "No sudo found and you're not root! Can't install packages." + return 1 + fi + else + echo_info "Root access confirmed." + _sudo="" + fi +} + +comment_cd_sources() { + # Path to sources.list + sources_file="/etc/apt/sources.list" + + # Check if file exists + if [ ! -f "$sources_file" ]; then + echo_error "Error: $sources_file not found" + return 1 + fi + + # Comment out CD-ROM entries using sudo + $_sudo sed -i 's/^[[:space:]]*deb[[:space:]]\+cdrom:/#&/' "$sources_file" + echo_info "CD-ROM entries have been commented out in $sources_file" +} + +i_yazi() { + if command_exists curl; then + curl -fsSL https://git.k4li.de/pika/scripts/raw/branch/main/bash/installs/yazi.sh | sh + else + echo_error "No curl was found" + fi +} + +deps="zsh tmux gdu rsync fzf unzip go btop make stow git npm bc pv zoxide ripgrep trash-cli" + +check_nala() { + deb_pkger="" + echo_info "Updating sources.." + if ! $_sudo apt-get update; then + echo_error "Maybe you need a proxy?" + fi + if ! command_exists sudo; then + echo_note "Installing sudo" + apt-get install sudo --assume-yes + fi + if command_exists nala; then + deb_pkger="nala" + echo_info "Nala is already present, fetching mirros now! (This might take a minute or two, depending on your internet speed)" + $_sudo nala fetch --auto --assume-yes + else + echo_note "Nala is not installed on the system, do you want to install it now? (Y/n): " + read -r inst_nala + case "$inst_nala" in + N | n) + deb_pkger="apt-get" + echo_warning "All right, continue without nala!" + ;; + *) + echo_note "Installing nala.." + $_sudo apt-get install nala --assume-yes && + deb_pkger="nala" + + echo_info "Fetching best mirrors" + $_sudo nala fetch --auto --assume-yes + ;; + esac + fi +} + +inst_debian() { + comment_cd_sources + check_nala + if command_exists nano; then + if command_exists vi; then + echo_note "Removing nano" + $_sudo $deb_pkger remove nano --assume-yes + else + echo_info "Removing nano and installing vi as a backup" + $_sudo $deb_pkger remove nano --assume-yes && $_sudo apt-get install vi --assume-yes + fi + fi + + echo_note "Installing base packages: $deps" + for _deps in $deps; do + if ! command_exists "$_deps"; then + if ! $_sudo $deb_pkger install "$_deps" --assume-yes; then + echo_error "$_deps - failed to install" + fi + else + echo_note "$_deps - was already installed" + fi + done + + i_yazi +} + +inst_ubuntu() { + comment_cd_sources + check_nala + if command_exists nano; then + if command_exists vi; then + echo_note "Removing nano" + $_sudo $deb_pkger remove nano --assume-yes + else + echo_note "Removing nano and installing vi as a backup" + $_sudo $deb_pkger remove nano --assume-yes && $_sudo apt-get install vi --assume-yes + fi + fi + + echo_note "Installing base packages: $deps" + for _deps in $deps; do + if ! command_exists "$_deps"; then + if ! $_sudo $deb_pkger install "$_deps" --assume-yes; then + echo_error "$_deps - failed to install" + fi + else + echo_note "$_deps - was already installed" + fi + done + + i_yazi +} + +inst_fedora() { + if command_exists nano; then + if command_exists vi; then + echo_note "Removing nano" + $_sudo dnf remove nano ──────────────────────────────────────── +get_packager() { + if [ -e /etc/os-release ]; then + echo_info "Detecting distribution..." + . /etc/os-release + + # Convert $ID and $ID_LIKE to lowercase + ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]') + ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]') + + case "$ID" in + ubuntu | pop | zorin) inst_ubuntu ;; + debian) inst_debian ;; + fedora) inst_fedora ;; + alpine) inst_alpine ;; + arch | manjaro | garuda | endeavour) inst_arch ;; + opensuse*) inst_opensuse ;; + *) + # Use standard [ ] syntax for string matching + if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then + inst_debian + elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then + inst_ubuntu + elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then + inst_arch + elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then + inst_fedora + elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then + inst_opensuse + else + echo_error "Unsupported distribution: $ID" + exit 1 + fi + ;; + esac + else + echo_error "Unable to detect distribution. /etc/os-release not found." + exit 1 + fi +} + +# Improved display function that only shows categories with content +display_stored_messages() { + has_messages=0 + + # First check if we have any messages at all + if [ -z "$_STORED_ERRORS" ] && [ -z "$_STORED_WARNINGS" ] && [ -z "$_STORED_INFOS" ] && [ -z "$_STORED_NOTES" ]; then + return 0 + fi + + # Now display each non-empty category with proper spacing + if [ -n "$_STORED_ERRORS" ]; then + printf "\n${BOLD}${RED}=== Errors ===${NC}\n" + printf "$_STORED_ERRORS" + has_messages=1 + fi + + if [ -n "$_STORED_WARNINGS" ]; then + [ "$has_messages" -eq 1 ] && printf "\n" + printf "${BOLD}${YELLOW}=== Warnings ===${NC}\n" + printf "$_STORED_WARNINGS" + has_messages=1 + fi + + if [ -n "$_STORED_INFOS" ]; then + [ "$has_messages" -eq 1 ] && printf "\n" + printf "${BOLD}${CYAN}=== Info ===${NC}\n" + printf "$_STORED_INFOS" + has_messages=1 + fi + + if [ -n "$_STORED_NOTES" ]; then + [ "$has_messages" -eq 1 ] && printf "\n" + printf "${BOLD}${LIGHT_GREEN}=== Notes ===${NC}\n" + printf "$_STORED_NOTES" + fi +} + +_inst_docker() { + if ! command_exists docker; then + bash --norc -c "$(curl -fsSL https://git.k4li.de/pika/scripts/raw/branch/main/bash/installs/docker.sh)" + else + echo_note "Docker is already installed, do you need to activate it and make the group changes for $(whoami)? (y/n): " + read -r _docker + case "$_docker" in + N | n) + return 1 + ;; + *) + $_sudo systemctl enable --now docker && + $_sudo usermod -aG docker "$(whoami)" + echo_info "Docker was configured" + ;; + esac + fi +} + +_inst_lazydocker() { + if [ ! -e "$HOME/.local/bin/lazydocker" ]; then + if command_exists curl; then + curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash + else + echo_error "curl is not installed, cannot continue!" + exit 1 + fi + else + echo_warning "$HOME/.local/bin/lazydocker is already present." + fi + _dashboard +} + +_check_gitpath() { + if [ ! -d "$HOME/git/" ]; then + mkdir $HOME/git + else + echo_note "git dir is already present" + fi +} + +_ytgo() { + if ! command_exists go; then + if ! install_pkg golang; then + echo_error "Something went wrong, couldn't install golang" + fi + fi + + if ! command_exists ytgo; then + cd "$(mktemp --dir)" + git clone --depth=1 https://git.k4li.de/pika/ytgo.git + cd ytgo + make install + else + echo_info "ytgo is already present at $(whereis ytgo)" + fi +} + +_init_dotfiles() { + _check_gitpath + echo_db "What dotfiles do you want to clone? + 1. homelab-dotfiles + 2. hyprdots + 3. tty-dotfiles + q. Quit" + read -r _dotfiles_db + case "$_dotfiles_db" in + 1) + git clone --recursive --depth=1 https://git.k4li.de/dotfiles/homelab-dotfiles.git $HOME/git/homelab-dotfiles + ;; + 2) + git clone --recursive --depth=1 https://git.k4li.de/dotfiles/hyprdots.git $HOME/git/hyprdots + ;; + 3) + git clone --recursive --depth=1 https://git.k4li.de/dotfiles/tty-dotfiles.git $HOME/git/tty-dotfiles + ;; + q) + return 1 + ;; + *) + echo default + ;; + esac + _dashboard +} + +_dashboard() { + echo_db "What else can I do for you? + 1. Docker installation + 2. Dotfile initialization + 3. lazydocker installation + 4. ytgo + q. Quit" + read -r _db /dev/null 2>&1 + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}" + ;; + esac +} + +common_cleanup() { + if [ -d /var/tmp ]; then + "$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete + fi + if [ -d /tmp ]; then + "$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete + fi + if [ -d /var/log ]; then + "$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \; + fi + "$ESCALATION_TOOL" journalctl --vacuum-time=3d +} + +clean_data() { + printf "%b" "${YELLOW}Clean up old cache files and empty the trash? (y/N): ${RC}" + read -r clean_response + case $clean_response in + y|Y) + printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}" + if [ -d "$HOME/.cache" ]; then + find "$HOME/.cache/" -type f -atime +5 -delete + fi + if [ -d "$HOME/.local/share/Trash" ]; then + find "$HOME/.local/share/Trash" -mindepth 1 -delete + fi + printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}" + ;; + *) + printf "%b\n" "${YELLOW}Skipping cache and trash cleanup.${RC}" + ;; + esac +} + +checkEnv +checkEscalationTool +cleanup_system +common_cleanup +clean_data diff --git a/core/tabs/system-setup/system-update.sh b/core/tabs/system-setup/system-update.sh new file mode 100755 index 0000000..c213156 --- /dev/null +++ b/core/tabs/system-setup/system-update.sh @@ -0,0 +1,106 @@ +#!/bin/sh -e + +. ../common-script.sh + +fastUpdate() { + case "$PACKAGER" in + pacman) + + $AUR_HELPER -S --needed --noconfirm rate-mirrors-bin + + printf "%b\n" "${YELLOW}Generating a new list of mirrors using rate-mirrors. This process may take a few seconds...${RC}" + + if [ -s /etc/pacman.d/mirrorlist ]; then + "$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak + fi + + # If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail + dtype_local=${DTYPE} + if [ "${DTYPE}" = "unknown" ]; then + dtype_local="arch" + fi + + "$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local} + if [ $? -ne 0 ] || [ ! -s /etc/pacman.d/mirrorlist ]; then + printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}" + "$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist + fi + ;; + + apt-get|nala) + "$ESCALATION_TOOL" apt-get update + if ! command_exists nala; then + "$ESCALATION_TOOL" apt-get install -y nala || { printf "%b\n" "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; } + fi + + if [ "$PACKAGER" = "nala" ]; then + "$ESCALATION_TOOL" cp /etc/apt/sources.list /etc/apt/sources.list.bak + "$ESCALATION_TOOL" nala update + PACKAGER="nala" + fi + + "$ESCALATION_TOOL" "$PACKAGER" upgrade -y + ;; + dnf) + "$ESCALATION_TOOL" "$PACKAGER" update -y + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" ref + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + exit 1 + ;; + esac +} + +updateSystem() { + printf "%b\n" "${GREEN}Updating system${RC}" + case "$PACKAGER" in + apt-get|nala) + "$ESCALATION_TOOL" "$PACKAGER" update + "$ESCALATION_TOOL" "$PACKAGER" upgrade -y + ;; + dnf) + "$ESCALATION_TOOL" "$PACKAGER" update -y + "$ESCALATION_TOOL" "$PACKAGER" upgrade -y + ;; + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -Sy --noconfirm --needed archlinux-keyring + "$ESCALATION_TOOL" "$PACKAGER" -Su --noconfirm + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" ref + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + exit 1 + ;; + esac +} + +updateFlatpaks() { + if command_exists flatpak; then + printf "%b\n" "${YELLOW}Updating installed Flathub apps...${RC}" + installed_apps=$(flatpak list --app --columns=application) + + if [ -z "$installed_apps" ]; then + printf "%b\n" "${RED}No Flathub apps are installed.${RC}" + return + fi + + for app in $installed_apps; do + printf "%b\n" "${YELLOW}Updating $app...${RC}" + flatpak update -y "$app" + done + fi +} + +checkEnv +checkAURHelper +checkEscalationTool +fastUpdate +updateSystem +updateFlatpaks diff --git a/core/tabs/system-setup/tab_data.toml b/core/tabs/system-setup/tab_data.toml new file mode 100644 index 0000000..84b8ef7 --- /dev/null +++ b/core/tabs/system-setup/tab_data.toml @@ -0,0 +1,102 @@ +name = "System Setup" +multi_selectable = false + +[[data]] +name = "Arch Linux" + +[[data.preconditions]] +matches = true +data = "command_exists" +values = ["pacman"] + +[[data.entries]] +name = "Arch Server Setup" +description = "This command installs a minimal arch server setup under 5 minutes." +script = "arch/server-setup.sh" +task_list = "SI D" + +[[data.entries]] +name = "Paru AUR Helper" +description = "Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction.\nTo know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers" +script = "arch/paru-setup.sh" +task_list = "I" + +[[data.entries]] +name = "Yay AUR Helper" +description = "Yet Another Yogurt - An AUR Helper Written in Go.\nTo know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers" +script = "arch/yay-setup.sh" +task_list = "I" + +[[data]] +name = "Fedora" + +[[data.preconditions]] +matches = true +data = "command_exists" +values = ["dnf"] + +[[data.entries]] +name = "Configure DNF" +description = "Optimizes DNF for parallel downloads" +script = "fedora/configure-dnf.sh" +task_list = "PFM" + +[[data.entries]] +name = "Multimedia Codecs" +description = "This script is designed to install multimedia codecs, and to ensure RPM Fusion repositories are installed." +script = "fedora/multimedia-codecs.sh" +task_list = "I" + +[[data.entries]] +name = "Nvidia Proprietary Drivers" +description = "This script is designed to download the proprietary NVIDIA drivers in Fedora." +script = "fedora/nvidia-proprietary-driver-setup.sh" +task_list = "I" + +[[data.entries]] +name = "RPM Fusion" +description = "RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship.\nThat software is provided as precompiled RPMs for all current Fedora versions and current Red Hat Enterprise Linux or clones versions; you can use the RPM Fusion repositories with tools like yum and PackageKit.\nFor more information visit: https://rpmfusion.org/" +script = "fedora/rpm-fusion-setup.sh" +task_list = "MP" + +[[data.entries]] +name = "Virtualization" +description = "Enables Virtualization through dnf" +script = "fedora/virtualization.sh" +task_list = "I" + +[[data]] +name = "Full System Cleanup" +description = "This script is designed to remove unnecessary packages, clean old cache files, remove temporary files, and to empty the trash." +script = "system-cleanup.sh" +task_list = "RP PFM" + +[[data]] +name = "Full System Update" +description = "This command updates your system to the latest packages available for your distro" +script = "system-update.sh" +task_list = "PFM" + +[[data]] +name = "Gaming Dependencies" +description = "This script is designed to handle the installation of gaming dependencies across different Linux distributions" +script = "gaming-setup.sh" +task_list = "I" + +[[data]] +name = "Postinstallation Script" +description = "This script is designed to handle the installation of various software dependencies across different Linux distributions" +script = "postinstall.sh" +task_list = "I" + +[[data]] +name = "Remove Snaps" +description = "This script is designed to remove snap" +script = "remove-snaps.sh" +task_list = "RP" + +[[data]] +name = "TTY Fonts" +description = "This Script will set the default TTY font to Terminus size 32 Bold" +script = "terminus-tty.sh" +task_list = "I PFM" \ No newline at end of file diff --git a/core/tabs/system-setup/terminus-tty.sh b/core/tabs/system-setup/terminus-tty.sh new file mode 100755 index 0000000..2c1deaa --- /dev/null +++ b/core/tabs/system-setup/terminus-tty.sh @@ -0,0 +1,66 @@ +#!/bin/sh -e + +. ../common-script.sh +InstallTermiusFonts() { + if [ ! -f "/usr/share/kbd/consolefonts/ter-c18b.psf.gz" ] && + [ ! -f "/usr/share/consolefonts/Uni3-TerminusBold18x10.psf.gz" ] && + [ ! -f "/usr/lib/kbd/consolefonts/ter-p32n.psf.gz" ]; then + printf "%b\n" "${YELLOW}Installing Terminus Fonts...${RC}" + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm terminus-font + ;; + apt-get|nala) + "$ESCALATION_TOOL" "$PACKAGER" install -y fonts-terminus + ;; + dnf) + "$ESCALATION_TOOL" "$PACKAGER" install -y terminus-fonts-console + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac + else + printf "%b\n" "${GREEN}Terminus Fonts is already installed.${RC}" + fi +} + +SetTermiusFonts() { + case "$DTYPE" in + arch) + printf "%b\n" "${YELLOW}Updating FONT= line in /etc/vconsole.conf...${RC}" + "$ESCALATION_TOOL" sed -i 's/^FONT=.*/FONT=ter-v32b/' /etc/vconsole.conf + if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then + "$ESCALATION_TOOL" setfont -C /dev/tty1 ter-v32b + fi + printf "%b\n" "${GREEN}Terminus font set for TTY.${RC}" + ;; + debian) + + printf "%b\n" "${YELLOW}Updating console-setup configuration...${RC}" + "$ESCALATION_TOOL" sed -i 's/^CODESET=.*/CODESET="guess"/' /etc/default/console-setup + "$ESCALATION_TOOL" sed -i 's/^FONTFACE=.*/FONTFACE="TerminusBold"/' /etc/default/console-setup + "$ESCALATION_TOOL" sed -i 's/^FONTSIZE=.*/FONTSIZE="16x32"/' /etc/default/console-setup + printf "%b\n" "${GREEN}Console-setup configuration updated for Terminus font.${RC}" + # Editing console-setup requires initramfs to be regenerated + "$ESCALATION_TOOL" update-initramfs -u + if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then + "$ESCALATION_TOOL" setfont -C /dev/tty1 /usr/share/consolefonts/Uni3-TerminusBold32x16.psf.gz + fi + printf "%b\n" "${GREEN}Terminus font has been set for TTY.${RC}" + ;; + fedora) + printf "%b\n" "${YELLOW}Updating FONT= line in /etc/vconsole.conf...${RC}" + "$ESCALATION_TOOL" sed -i 's/^FONT=.*/FONT=ter-v32b/' /etc/vconsole.conf + if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then + "$ESCALATION_TOOL" setfont -C /dev/tty1 ter-v32b + fi + printf "%b\n" "${GREEN}Terminus font has been set for TTY.${RC}" + ;; + esac +} + +checkEnv +InstallTermiusFonts +SetTermiusFonts diff --git a/core/tabs/tabs.toml b/core/tabs/tabs.toml new file mode 100644 index 0000000..ea53a82 --- /dev/null +++ b/core/tabs/tabs.toml @@ -0,0 +1,7 @@ +directories = [ + "applications-setup", + # "gaming", + # "security", + "system-setup", + "utils" +] diff --git a/core/tabs/utils/auto-login.sh b/core/tabs/utils/auto-login.sh new file mode 100644 index 0000000..561250d --- /dev/null +++ b/core/tabs/utils/auto-login.sh @@ -0,0 +1,175 @@ +#!/bin/sh -e + +. ../common-script.sh + +# Function to list common session options +list_sessions() { + printf "%b\n" "Select the session:" + printf "%b\n" "1) GNOME (gnome.desktop)" + printf "%b\n" "2) KDE Plasma (plasma.desktop)" + printf "%b\n" "3) XFCE (xfce.desktop)" + printf "%b\n" "4) LXDE (LXDE.desktop)" + printf "%b\n" "5) LXQt (lxqt.desktop)" + printf "%b\n" "6) Cinnamon (cinnamon.desktop)" + printf "%b\n" "7) MATE (mate.desktop)" + printf "%b\n" "8) Openbox (openbox.desktop)" + printf "%b\n" "9) i3 (i3.desktop)" + printf "%b\n" "10) Custom session" + printf "%b" "Enter your choice (1-10): " + read -r session_choice + + case "$session_choice" in + 1) session="gnome.desktop" ;; + 2) session="plasma.desktop" ;; + 3) session="xfce.desktop" ;; + 4) session="LXDE.desktop" ;; + 5) session="lxqt.desktop" ;; + 6) session="cinnamon.desktop" ;; + 7) session="mate.desktop" ;; + 8) session="openbox.desktop" ;; + 9) session="i3.desktop" ;; + 10) + printf "%b" "Enter custom session name (e.g., mysession): " + read -r session ;; + *) + printf "%b\n" "Invalid option selected." + exit 1 ;; + esac +} + +# Function to configure LightDM +configure_lightdm() { + printf "%b\n" "Configuring LightDM for autologin..." + printf "%b" "Enter username for LightDM autologin: " + read -r user + + printf "%b\n" '[Seat:*]' | "$ESCALATION_TOOL" tee -a /etc/lightdm/lightdm.conf + printf "%s\n" "autologin-user=$user" | "$ESCALATION_TOOL" tee -a /etc/lightdm/lightdm.conf + printf "%b\n" 'autologin-user-timeout=0' | "$ESCALATION_TOOL" tee -a /etc/lightdm/lightdm.conf + + printf "%b\n" "LightDM has been configured for autologin." +} + +# Function to remove LightDM autologin +remove_lightdm_autologin() { + printf "%b\n" "Removing LightDM autologin configuration..." + "$ESCALATION_TOOL" sed -i'' '/^\[Seat:\*]/d' /etc/lightdm/lightdm.conf + "$ESCALATION_TOOL" sed -i'' '/^autologin-/d' /etc/lightdm/lightdm.conf + printf "%b\n" "LightDM autologin configuration has been removed." +} + +# Function to configure GDM +configure_gdm() { + printf "%b\n" "Configuring GDM for autologin..." + printf "%b" "Enter username for GDM autologin: " + read -r user + + printf "%b\n" '[daemon]' | "$ESCALATION_TOOL" tee -a /etc/gdm/custom.conf + printf "%b\n" 'AutomaticLoginEnable = true' | "$ESCALATION_TOOL" tee -a /etc/gdm/custom.conf + printf "%s\n" "AutomaticLogin = $user" | "$ESCALATION_TOOL" tee -a /etc/gdm/custom.conf + + printf "%b\n" "GDM has been configured for autologin." +} + +# Function to remove GDM autologin +remove_gdm_autologin() { + printf "%b\n" "Removing GDM autologin configuration..." + "$ESCALATION_TOOL" sed -i'' '/AutomaticLoginEnable/d' /etc/gdm/custom.conf + "$ESCALATION_TOOL" sed -i'' '/AutomaticLogin/d' /etc/gdm/custom.conf + printf "%b\n" "GDM autologin configuration has been removed." +} + +# Function to configure SDDM +configure_sddm() { + printf "%b\n" "Configuring SDDM for autologin..." + printf "%b" "Enter username for SDDM autologin: " + read -r user + list_sessions # Show session options + + printf "%b\n" '[Autologin]' | "$ESCALATION_TOOL" tee -a /etc/sddm.conf + printf "%s\n" "User=$user" | "$ESCALATION_TOOL" tee -a /etc/sddm.conf + printf "%s\n" "Session=$session" | "$ESCALATION_TOOL" tee -a /etc/sddm.conf + + printf "%b\n" "SDDM has been configured for autologin." +} + +# Function to remove SDDM autologin +remove_sddm_autologin() { + printf "%b\n" "Removing SDDM autologin configuration..." + "$ESCALATION_TOOL" sed -i'' '/\[Autologin\]/,+2d' /etc/sddm.conf + printf "%b\n" "SDDM autologin configuration has been removed." +} + +# Function to configure LXDM +configure_lxdm() { + printf "%b\n" "Configuring LXDM for autologin..." + printf "%b" "Enter username for LXDM autologin: " + read -r user + list_sessions # Show session options + + "$ESCALATION_TOOL" sed -i'' "s/^#.*autologin=.*$/autologin=${user}/" /etc/lxdm/lxdm.conf + "$ESCALATION_TOOL" sed -i'' "s|^#.*session=.*$|session=/usr/bin/${session}|; s|^session=.*$|session=/usr/bin/${session}|" /etc/lxdm/lxdm.conf + + printf "%b\n" "LXDM has been configured for autologin." +} + +# Function to remove LXDM autologin +remove_lxdm_autologin() { + printf "%b\n" "Removing LXDM autologin configuration..." + "$ESCALATION_TOOL" sed -i'' "s/^autologin=.*$/#autologin=/" /etc/lxdm/lxdm.conf + "$ESCALATION_TOOL" sed -i'' "s/^session=.*$/#session=/" /etc/lxdm/lxdm.conf + printf "%b\n" "LXDM autologin configuration has been removed." +} + +# Function to configure or remove autologin based on user choice +configure_or_remove_autologin() { + printf "%b\n" "Do you want to add or remove autologin?" + printf "%b\n" "1) Add autologin" + printf "%b\n" "2) Remove autologin" + printf "%b" "Enter your choice (1-2): " + read -r action_choice + + if [ "$action_choice" = "1" ]; then + printf "%b\n" "Choose the display manager to configure:" + printf "%b\n" "1) LightDM" + printf "%b\n" "2) GDM" + printf "%b\n" "3) SDDM" + printf "%b\n" "4) LXDM" + printf "%b" "Enter your choice (1-4): " + read -r choice + + case "$choice" in + 1) configure_lightdm ;; + 2) configure_gdm ;; + 3) configure_sddm ;; + 4) configure_lxdm ;; + *) printf "%b\n" "Invalid option selected." ;; + esac + elif [ "$action_choice" = "2" ]; then + printf "%b\n" "Choose the display manager to remove autologin:" + printf "%b\n" "1) LightDM" + printf "%b\n" "2) GDM" + printf "%b\n" "3) SDDM" + printf "%b\n" "4) LXDM" + printf "%b" "Enter your choice (1-4): " + read -r choice + + case "$choice" in + 1) remove_lightdm_autologin ;; + 2) remove_gdm_autologin ;; + 3) remove_sddm_autologin ;; + 4) remove_lxdm_autologin ;; + *) printf "%b\n" "Invalid option selected." ;; + esac + else + printf "%b\n" "Invalid choice. Exiting..." + exit 1 + fi + + printf "%b\n" "Action completed. Exiting..." + exit 0 +} + +checkEnv +checkEscalationTool +configure_or_remove_autologin diff --git a/core/tabs/utils/ssh-keyperm.sh b/core/tabs/utils/ssh-keyperm.sh new file mode 100755 index 0000000..d76322d --- /dev/null +++ b/core/tabs/utils/ssh-keyperm.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# ssh-permissions script for linux +# ─< ANSI color codes >─────────────────────────────────────────────────────────────────── +RED='\033[0;31m' +CYAN='\033[0;36m' +YELLOW='\033[0;33m' +LIGHT_GREEN='\033[0;92m' +BOLD='\033[1m' +NC='\033[0m' # No Color + +echo_error() { + printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2 +} + +echo_info() { + printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1" +} + +echo_warning() { + printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1" +} + +echo_note() { + printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1" +} + +# ─< Check if the user is root and set sudo variable if necessary >─────────────────────── +check_root() { + if [ "$(id -u)" -ne 0 ]; then + if command -v sudo >/dev/null; then + echo_info "User is not root. Using sudo for privileged operations." + _sudo="sudo" + else + echo_error "No sudo found and you're not root! Can't install packages." + return 1 + fi + else + echo_note "Root access confirmed." + _sudo="" + fi +} + +set_perm() { + check_root + if [[ -d "$HOME/.ssh" ]]; then + echo_note "chmod 700 $HOME/.ssh" + "$_sudo" chmod 700 $HOME/.ssh >/dev/null 2>&1 + if ls $HOME/.ssh/*.pub >/dev/null 2>&1; then + echo_note "chmod 600 $HOME/.ssh/*id*" + "$_sudo" chmod 600 $HOME/.ssh/*id* >/dev/null 2>&1 + echo_note "chmod 666 $HOME/.ssh/*.pub" + "$_sudo" chmod 666 $HOME/.ssh/*.pub >/dev/null 2>&1 + else + echo_error "There is no *.pub file in the $HOME/.ssh/ directory! Aborting now!" + fi + else + echo_error "No .ssh folder found in $HOME - exiting now!" + exit 1 + fi +} + +set_perm diff --git a/core/tabs/utils/tab_data.toml b/core/tabs/utils/tab_data.toml new file mode 100644 index 0000000..de9ad5d --- /dev/null +++ b/core/tabs/utils/tab_data.toml @@ -0,0 +1,13 @@ +name = "Utilities" +multi_selectable = false + +[[data]] +name = "Auto Login" +script = "auto-login.sh" +task_list = "DE setup" + +[[data]] +name = "SSH Permissions" +script = "ssh-keyperm.sh" +description = "This script will set the SSH permissions" +task_list = "I" diff --git a/docs/KnownIssues.md b/docs/KnownIssues.md new file mode 100644 index 0000000..0d12097 --- /dev/null +++ b/docs/KnownIssues.md @@ -0,0 +1,4 @@ +# Known Issues +--- + +- [Known Issues](https://github.com/ChrisTitusTech/linutil/issues) diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png new file mode 100644 index 0000000..a4f4bc5 Binary files /dev/null and b/docs/assets/favicon.png differ diff --git a/docs/assets/preview.gif b/docs/assets/preview.gif new file mode 100644 index 0000000..c8e49da Binary files /dev/null and b/docs/assets/preview.gif differ diff --git a/docs/assets/preview.tape b/docs/assets/preview.tape new file mode 100644 index 0000000..66b1c35 --- /dev/null +++ b/docs/assets/preview.tape @@ -0,0 +1,89 @@ +# VHS documentation +# +# Output: +# Output .gif Create a GIF output at the given +# Output .mp4 Create an MP4 output at the given +# Output .webm Create a WebM output at the given +# +# Require: +# Require Ensure a program is on the $PATH to proceed +# +# Settings: +# Set FontSize Set the font size of the terminal +# Set FontFamily Set the font family of the terminal +# Set Height Set the height of the terminal +# Set Width Set the width of the terminal +# Set LetterSpacing Set the font letter spacing (tracking) +# Set LineHeight Set the font line height +# Set LoopOffset % Set the starting frame offset for the GIF loop +# Set Theme Set the theme of the terminal +# Set Padding Set the padding of the terminal +# Set Framerate Set the framerate of the recording +# Set PlaybackSpeed Set the playback speed of the recording +# Set MarginFill Set the file or color the margin will be filled with. +# Set Margin Set the size of the margin. Has no effect if MarginFill isn't set. +# Set BorderRadius Set terminal border radius, in pixels. +# Set WindowBar Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight) +# Set WindowBarSize Set window bar size, in pixels. Default is 40. +# Set TypingSpeed