mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-12-24 12:29:44 +00:00
Merge branch 'main' into Adding-Steam-And-Lutris-And-Goverlay-Install-For-Archlinux
This commit is contained in:
commit
7cb0672b6e
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -1,7 +1,7 @@
|
|||
# Pull Request
|
||||
|
||||
## Title
|
||||
[Provide a succinct and descriptive title for the pull request.]
|
||||
<!--[Provide a succinct and descriptive title for the pull request.]-->
|
||||
|
||||
## Type of Change
|
||||
- [ ] New feature
|
||||
|
@ -13,20 +13,20 @@
|
|||
- [ ] UI/UX improvement
|
||||
|
||||
## Description
|
||||
[Provide a detailed explanation of the changes you have made. Include the reasons behind these changes and any relevant context. Link any related issues.]
|
||||
<!--[Provide a detailed explanation of the changes you have made. Include the reasons behind these changes and any relevant context. Link any related issues.]-->
|
||||
|
||||
## Testing
|
||||
[Detail the testing you have performed to ensure that these changes function as intended. Include information about any added tests.]
|
||||
<!--[Detail the testing you have performed to ensure that these changes function as intended. Include information about any added tests.]-->
|
||||
|
||||
## Impact
|
||||
[Discuss the impact of your changes on the project. This might include effects on performance, new dependencies, or changes in behaviour.]
|
||||
<!--[Discuss the impact of your changes on the project. This might include effects on performance, new dependencies, or changes in behaviour.]-->
|
||||
|
||||
## Issue related to PR
|
||||
[What issue/discussion is related to this PR (if any)]
|
||||
<!--[What issue/discussion is related to this PR (if any)]-->
|
||||
- Resolves #
|
||||
|
||||
## Additional Information
|
||||
[Any additional information that reviewers should be aware of.]
|
||||
<!--[Any additional information that reviewers should be aware of.]-->
|
||||
|
||||
## Checklist
|
||||
- [ ] My code adheres to the coding and style guidelines of the project.
|
||||
|
|
16
.github/workflows/linutil.yml
vendored
16
.github/workflows/linutil.yml
vendored
|
@ -17,39 +17,45 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- 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
|
||||
- name: Build aarch64 binary
|
||||
run: cross build --target-dir=build --release --verbose --target=aarch64-unknown-linux-musl
|
||||
|
||||
- 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
|
||||
|
||||
- name: Pull latest changes
|
||||
run: |
|
||||
git config --global user.email "github-actions@github.com"
|
||||
git config --global user.name "GitHub Actions"
|
||||
git pull origin main
|
||||
|
||||
- uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: Commit Linutil
|
||||
file_pattern: "build/linutil build/linutil-aarch64"
|
||||
if: success()
|
||||
file_pattern: "build/linutil"
|
||||
add_options: '--force'
|
||||
if: success()
|
||||
|
|
7
.github/workflows/pre-release.yaml
vendored
7
.github/workflows/pre-release.yaml
vendored
|
@ -6,6 +6,10 @@ permissions:
|
|||
|
||||
on:
|
||||
workflow_dispatch: # Manual trigger added
|
||||
workflow_run:
|
||||
workflows: ["LinUtil Release"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
build-runspace:
|
||||
|
@ -31,9 +35,8 @@ jobs:
|
|||
append_body: false
|
||||
files: |
|
||||
./build/linutil
|
||||
./build/linutil-aarch64
|
||||
prerelease: true
|
||||
generate_release_notes: true
|
||||
env:
|
||||
version: ${{ env.version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
/target
|
||||
rust/target
|
||||
/build
|
||||
rust/target
|
||||
rust/build
|
||||
|
|
|
@ -2,54 +2,60 @@
|
|||
|
||||
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. Setting Up Your Development Environment
|
||||
## 1. **Install Rust**:
|
||||
|
||||
1. **Clone the repo**: Start by cloning the Linutil repository to your local machine.
|
||||
```bash
|
||||
git clone https://github.com/christitustech/linutil.git
|
||||
cd linutil
|
||||
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
|
||||
```
|
||||
2. **Install Rust**: Make sure you have Rust installed on your machine. If you don't, you can install it by following the instructions at [rust-lang.org](https://www.rust-lang.org/tools/install).
|
||||
3. **Edit the files you want to change**: Make your changes to the relevant files.
|
||||
4. **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected.
|
||||
|
||||
## 2. Make Meaningful Changes
|
||||
## 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.
|
||||
|
||||
## 3. Learn from Past Pull Requests (PRs)
|
||||
## 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.
|
||||
|
||||
## 4. Write Clean, Descriptive Commit Messages
|
||||
## 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.
|
||||
|
||||
## 5. Keep Your Pull Requests (PRs) Small and Focused
|
||||
## 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.
|
||||
|
||||
## 6. Code Review and Feedback
|
||||
## 8. 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.
|
||||
|
||||
## 7. Contributing Is More Than Just Code
|
||||
## 9. 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.
|
||||
|
||||
## 8. Documentation
|
||||
## 10. Documentation
|
||||
|
||||
- **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this.
|
||||
|
||||
## 9. License
|
||||
## 11. License
|
||||
|
||||
- **Agree to the license**: By contributing to Linutil, you agree that your contributions will be licensed under the project's MIT license.
|
||||
|
||||
|
|
165
Cargo.lock
generated
165
Cargo.lock
generated
|
@ -52,9 +52,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.7"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
|
||||
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
|
@ -163,9 +163,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.13"
|
||||
version = "4.5.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc"
|
||||
checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
|
@ -173,9 +173,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.13"
|
||||
version = "4.5.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99"
|
||||
checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
|
@ -269,6 +269,22 @@ version = "1.12.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
|
||||
|
||||
[[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 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filedescriptor"
|
||||
version = "0.8.2"
|
||||
|
@ -302,6 +318,15 @@ version = "0.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.60"
|
||||
|
@ -344,6 +369,16 @@ dependencies = [
|
|||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ioctl-rs"
|
||||
version = "0.1.6"
|
||||
|
@ -395,6 +430,12 @@ version = "0.2.155"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||
|
||||
[[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"
|
||||
|
@ -420,6 +461,12 @@ 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"
|
||||
|
@ -626,6 +673,19 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.17"
|
||||
|
@ -644,6 +704,35 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.205"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.205"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1"
|
||||
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"
|
||||
|
@ -832,6 +921,40 @@ dependencies = [
|
|||
"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 = "tui"
|
||||
version = "0.1.0"
|
||||
|
@ -844,8 +967,11 @@ dependencies = [
|
|||
"oneshot",
|
||||
"portable-pty",
|
||||
"ratatui",
|
||||
"serde",
|
||||
"tempdir",
|
||||
"toml",
|
||||
"tui-term",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -992,6 +1118,18 @@ version = "0.2.92"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
||||
|
||||
[[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"
|
||||
|
@ -1162,6 +1300,15 @@ version = "0.52.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||
|
||||
[[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"
|
||||
|
@ -1171,6 +1318,12 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winsafe"
|
||||
version = "0.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.34"
|
||||
|
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
chrono = "0.4.33"
|
||||
clap = { version = "4.5.13", features = ["derive"] }
|
||||
clap = { version = "4.5.16", features = ["derive"] }
|
||||
crossterm = "0.27.0"
|
||||
ego-tree = "0.6.2"
|
||||
oneshot = "0.1.8"
|
||||
|
@ -14,6 +14,9 @@ ratatui = "0.27.0"
|
|||
tui-term = "0.1.12"
|
||||
include_dir = "0.7.4"
|
||||
tempdir = "0.3.7"
|
||||
serde = { version = "1.0.205", features = ["derive"] }
|
||||
toml = "0.8.19"
|
||||
which = "6.0.3"
|
||||
|
||||
[[bin]]
|
||||
name = "linutil"
|
||||
|
|
11
README.md
11
README.md
|
@ -7,14 +7,19 @@
|
|||
|
||||
**Linutil** is a distro-agnostic toolbox designed to simplify everyday Linux tasks. It helps you set up applications and optimize your system for specific use cases. The utility is actively developed in Rust 🦀, providing performance and reliability.
|
||||
|
||||
*Note:* Since the project is still in active development, you may encounter some issues. Please consider [submitting feedback](https://github.com/ChrisTitusTech/linutil/issues) if you do.
|
||||
> [!NOTE]
|
||||
> Since the project is still in active development, you may encounter some issues. Please consider [submitting feedback](https://github.com/ChrisTitusTech/linutil/issues) if you do.
|
||||
|
||||
## 💡 Usage
|
||||
|
||||
To get started, open your terminal and run the following command:
|
||||
To get started, pick which branch you would like to use, then run the command in your terminal:
|
||||
### Stable Branch (Recommended)
|
||||
```bash
|
||||
curl -fsSL https://christitus.com/linux | sh
|
||||
```
|
||||
### Dev branch
|
||||
```bash
|
||||
curl -fsSL https://christitus.com/linuxdev | sh
|
||||
```
|
||||
## 💖 Support
|
||||
|
||||
If you find Linutil helpful, please consider giving it a ⭐️ to show your support!
|
||||
|
|
4
build.rs
Normal file
4
build.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
// Rebuild program if any file in commands directory changes.
|
||||
println!("cargo:rerun-if-changed=src/commands");
|
||||
}
|
Binary file not shown.
BIN
build/linutil
BIN
build/linutil
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 34 KiB |
7
linutil.desktop
Executable file
7
linutil.desktop
Executable file
|
@ -0,0 +1,7 @@
|
|||
[Desktop Entry]
|
||||
Name=Linutil
|
||||
Exec=sh -c "$HOME/.local/bin/linutil"
|
||||
Icon=utilities-terminal
|
||||
Type=Application
|
||||
Terminal=true
|
||||
Categories=Utility;
|
|
@ -1,16 +1,16 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
setupAlacritty() {
|
||||
echo "Install Alacritty if not already installed..."
|
||||
if ! command_exists alacritty; then
|
||||
case ${PACKAGER} in
|
||||
pacman)
|
||||
sudo ${PACKAGER} -S --needed --noconfirm alacritty
|
||||
$ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm alacritty
|
||||
;;
|
||||
*)
|
||||
sudo ${PACKAGER} install -y alacritty
|
||||
$ESCALATION_TOOL ${PACKAGER} install -y alacritty
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
@ -26,4 +26,5 @@ setupAlacritty() {
|
|||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
setupAlacritty
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
#!/bin/sh -e
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
makeDWM(){
|
||||
cd $HOME && git clone https://github.com/ChrisTitusTech/dwm-titus.git # CD to Home directory to install dwm-titus
|
||||
# This path can be changed (e.g. to linux-toolbox directory)
|
||||
cd dwm-titus/ # Hardcoded path, maybe not the best.
|
||||
sudo ./setup.sh # Run setup
|
||||
sudo make clean install # Run make clean install
|
||||
makeDWM() {
|
||||
cd "$HOME" && git clone https://github.com/ChrisTitusTech/dwm-titus.git # CD to Home directory to install dwm-titus
|
||||
# This path can be changed (e.g. to linux-toolbox directory)
|
||||
cd dwm-titus/ # Hardcoded path, maybe not the best.
|
||||
$ESCALATION_TOOL ./setup.sh # Run setup
|
||||
$ESCALATION_TOOL make clean install # Run make clean install
|
||||
}
|
||||
|
||||
setupDWM() {
|
||||
echo "Installing DWM-Titus if not already installed"
|
||||
case "$PACKAGER" in # Install pre-Requisites
|
||||
pacman)
|
||||
sudo "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2
|
||||
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2
|
||||
;;
|
||||
*)
|
||||
sudo "$PACKAGER" install -y build-essential libx11-dev libxinerama-dev libxft-dev libimlib2-dev
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y build-essential libx11-dev libxinerama-dev libxft-dev libimlib2-dev
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
setupDWM
|
||||
makeDWM
|
||||
makeDWM
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
setupKitty() {
|
||||
echo "Install Kitty if not already installed..."
|
||||
if ! command_exists kitty; then
|
||||
case ${PACKAGER} in
|
||||
pacman)
|
||||
sudo "${PACKAGER}" -S --needed --noconfirm kitty
|
||||
$ESCALATION_TOOL "${PACKAGER}" -S --needed --noconfirm kitty
|
||||
;;
|
||||
*)
|
||||
sudo "${PACKAGER}" install -y kitty
|
||||
$ESCALATION_TOOL "${PACKAGER}" install -y kitty
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
@ -18,12 +18,13 @@ setupKitty() {
|
|||
fi
|
||||
echo "Copy Kitty config files"
|
||||
if [ -d "${HOME}/.config/kitty" ]; then
|
||||
cp -r "${HOME}"/.config/kitty "${HOME}"/.config/kitty-bak
|
||||
cp -r "${HOME}/.config/kitty" "${HOME}/.config/kitty-bak"
|
||||
fi
|
||||
mkdir -p "${HOME}"/.config/kitty/
|
||||
wget -O "${HOME}"/.config/kitty/kitty.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf
|
||||
wget -O "${HOME}"/.config/kitty/nord.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf
|
||||
mkdir -p "${HOME}/.config/kitty/"
|
||||
wget -O "${HOME}/.config/kitty/kitty.conf" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf
|
||||
wget -O "${HOME}/.config/kitty/nord.conf" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
setupKitty
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
setupRofi() {
|
||||
echo "Install Rofi if not already installed..."
|
||||
if ! command_exists rofi; then
|
||||
case "$PACKAGER" in
|
||||
pacman)
|
||||
sudo "$PACKAGER" -S --needed --noconfirm rofi
|
||||
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm rofi
|
||||
;;
|
||||
*)
|
||||
sudo "$PACKAGER" install -y rofi
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y rofi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
@ -31,4 +31,5 @@ setupRofi() {
|
|||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
setupRofi
|
||||
|
|
29
src/commands/applications-setup/tab_data.toml
Normal file
29
src/commands/applications-setup/tab_data.toml
Normal file
|
@ -0,0 +1,29 @@
|
|||
name = "Applications Setup"
|
||||
|
||||
[[data]]
|
||||
name = "Alacritty"
|
||||
script = "alacritty-setup.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Bash Prompt"
|
||||
command = "bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/setup.sh)\""
|
||||
|
||||
[[data]]
|
||||
name = "DWM-Titus"
|
||||
script = "dwmtitus-setup.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Kitty"
|
||||
script = "kitty-setup.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Neovim"
|
||||
command = "bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/neovim/main/setup.sh)\""
|
||||
|
||||
[[data]]
|
||||
name = "Rofi"
|
||||
script = "rofi-setup.sh"
|
||||
|
||||
[[data]]
|
||||
name = "ZSH Prompt"
|
||||
script = "zsh-setup.sh"
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
# Function to install zsh
|
||||
install_zsh() {
|
||||
|
@ -8,10 +8,10 @@ install_zsh() {
|
|||
if ! command_exists zsh; then
|
||||
case "$PACKAGER" in
|
||||
pacman)
|
||||
sudo "$PACKAGER" -S --needed --noconfirm zsh
|
||||
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm zsh
|
||||
;;
|
||||
*)
|
||||
sudo "$PACKAGER" install -y zsh
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y zsh
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
@ -43,9 +43,10 @@ RPROMPT='%F{15}(%F{166}%D{%H:%M}%F{15})%f'
|
|||
EOL
|
||||
|
||||
# Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory
|
||||
echo 'export ZDOTDIR="$HOME/.config/zsh"' | sudo tee -a /etc/zsh/zshenv
|
||||
echo 'export ZDOTDIR="$HOME/.config/zsh"' | $ESCALATION_TOOL tee -a /etc/zsh/zshenv
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
install_zsh
|
||||
setup_zsh_config
|
||||
install_zsh
|
|
@ -11,6 +11,23 @@ command_exists() {
|
|||
which "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
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}
|
||||
echo "Using ${tool} for privilege escalation"
|
||||
ESCALATION_TOOL_CHECKED=true
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "${RED}Can't find a supported escalation tool${RC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommandRequirements() {
|
||||
## Check for requirements.
|
||||
|
@ -82,4 +99,5 @@ checkEnv() {
|
|||
checkCurrentDirectoryWritable
|
||||
checkSuperUser
|
||||
checkDistro
|
||||
checkEscalationTool
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
installPkg() {
|
||||
echo "Install UFW if not already installed..."
|
||||
if ! command_exists ufw; then
|
||||
case ${PACKAGER} in
|
||||
pacman)
|
||||
sudo "${PACKAGER}" -S --needed --noconfirm ufw
|
||||
$ESCALATION_TOOL "${PACKAGER}" -S --needed --noconfirm ufw
|
||||
;;
|
||||
*)
|
||||
sudo "${PACKAGER}" install -y ufw
|
||||
$ESCALATION_TOOL "${PACKAGER}" install -y ufw
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
@ -22,27 +22,28 @@ configureUFW() {
|
|||
echo -e "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}"
|
||||
|
||||
echo "Disabling UFW"
|
||||
sudo ufw disable
|
||||
$ESCALATION_TOOL ufw disable
|
||||
|
||||
echo "Limiting port 22/tcp (UFW)"
|
||||
sudo ufw limit 22/tcp
|
||||
$ESCALATION_TOOL ufw limit 22/tcp
|
||||
|
||||
echo "Allowing port 80/tcp (UFW)"
|
||||
sudo ufw allow 80/tcp
|
||||
$ESCALATION_TOOL ufw allow 80/tcp
|
||||
|
||||
echo "Allowing port 443/tcp (UFW)"
|
||||
sudo ufw allow 443/tcp
|
||||
$ESCALATION_TOOL ufw allow 443/tcp
|
||||
|
||||
echo "Denying Incoming Packets by Default(UFW)"
|
||||
sudo ufw default deny incoming
|
||||
$ESCALATION_TOOL ufw default deny incoming
|
||||
|
||||
echo "Allowing Outcoming Packets by Default(UFW)"
|
||||
sudo ufw default allow outgoing
|
||||
$ESCALATION_TOOL ufw default allow outgoing
|
||||
|
||||
sudo ufw enable
|
||||
$ESCALATION_TOOL ufw enable
|
||||
echo -e "${GREEN}Enabled Firewall with Baselines!${RC}"
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
installPkg
|
||||
configureUFW
|
||||
|
|
5
src/commands/security/tab_data.toml
Normal file
5
src/commands/security/tab_data.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
name = "Security"
|
||||
|
||||
[[data]]
|
||||
name = "Firewall Baselines (CTT)"
|
||||
script = "firewall-baselines.sh"
|
|
@ -1,28 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
|
||||
# Check if the home directory and linuxtoolbox folder exist, create them if they don't
|
||||
LINUXTOOLBOXDIR="$HOME/linuxtoolbox"
|
||||
|
||||
if [ ! -d "$LINUXTOOLBOXDIR" ]; then
|
||||
echo -e "${YELLOW}Creating linuxtoolbox directory: $LINUXTOOLBOXDIR${RC}"
|
||||
mkdir -p "$LINUXTOOLBOXDIR"
|
||||
echo -e "${GREEN}linuxtoolbox directory created: $LINUXTOOLBOXDIR${RC}"
|
||||
fi
|
||||
|
||||
if [ ! -d "$LINUXTOOLBOXDIR/linutil" ]; then
|
||||
echo -e "${YELLOW}Cloning linutil repository into: $LINUXTOOLBOXDIR/linutil${RC}"
|
||||
git clone https://github.com/ChrisTitusTech/linutil "$LINUXTOOLBOXDIR/linutil"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}Successfully cloned linutil repository${RC}"
|
||||
else
|
||||
echo -e "${RED}Failed to clone linutil repository${RC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "$LINUXTOOLBOXDIR/linutil" || exit
|
||||
. ../common-script.sh
|
||||
|
||||
installDepend() {
|
||||
## Check for dependencies.
|
||||
|
@ -31,16 +9,16 @@ installDepend() {
|
|||
case $PACKAGER in
|
||||
pacman)
|
||||
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
|
||||
echo "[multilib]" | sudo tee -a /etc/pacman.conf
|
||||
echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf
|
||||
sudo "$PACKAGER" -Syu
|
||||
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
|
||||
echo "Multilib is already enabled."
|
||||
fi
|
||||
if ! command_exists yay && ! command_exists paru; then
|
||||
echo "Installing yay as AUR helper..."
|
||||
sudo "$PACKAGER" -S --needed --noconfirm base-devel
|
||||
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R "$USER":"$USER" ./yay-git
|
||||
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel
|
||||
cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R "$USER":"$USER" ./yay-git
|
||||
cd yay-git && makepkg --noconfirm -si
|
||||
else
|
||||
echo "Aur helper already installed"
|
||||
|
@ -53,30 +31,30 @@ installDepend() {
|
|||
echo "No AUR helper found. Please install yay or paru."
|
||||
exit 1
|
||||
fi
|
||||
"$AUR_HELPER" -S --needed --noconfirm "$DEPENDENCIES"
|
||||
$AUR_HELPER -S --needed --noconfirm "$DEPENDENCIES"
|
||||
;;
|
||||
apt-get|nala)
|
||||
COMPILEDEPS='build-essential'
|
||||
sudo "$PACKAGER" update
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo "$PACKAGER" update
|
||||
sudo "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
|
||||
$ESCALATION_TOOL "$PACKAGER" update
|
||||
$ESCALATION_TOOL dpkg --add-architecture i386
|
||||
$ESCALATION_TOOL "$PACKAGER" update
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
|
||||
;;
|
||||
dnf)
|
||||
COMPILEDEPS='@development-tools'
|
||||
sudo "$PACKAGER" update
|
||||
sudo "$PACKAGER" config-manager --set-enabled powertools
|
||||
sudo "$PACKAGER" install -y "$DEPENDENCIES" $COMPILEDEPS
|
||||
sudo "$PACKAGER" install -y glibc-devel.i686 libgcc.i686
|
||||
$ESCALATION_TOOL "$PACKAGER" update
|
||||
$ESCALATION_TOOL "$PACKAGER" config-manager --set-enabled powertools
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y "$DEPENDENCIES" $COMPILEDEPS
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y glibc-devel.i686 libgcc.i686
|
||||
;;
|
||||
zypper)
|
||||
COMPILEDEPS='patterns-devel-base-devel_basis'
|
||||
sudo "$PACKAGER" refresh
|
||||
sudo "$PACKAGER" --non-interactive install "$DEPENDENCIES" $COMPILEDEPS
|
||||
sudo "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit
|
||||
$ESCALATION_TOOL "$PACKAGER" refresh
|
||||
$ESCALATION_TOOL "$PACKAGER" --non-interactive install "$DEPENDENCIES" $COMPILEDEPS
|
||||
$ESCALATION_TOOL "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit
|
||||
;;
|
||||
*)
|
||||
sudo "$PACKAGER" install -y $DEPENDENCIES # Fixed bug where no packages found on debian-based
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y $DEPENDENCIES # Fixed bug where no packages found on debian-based
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
@ -102,5 +80,6 @@ install_additional_dependencies() {
|
|||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
installDepend
|
||||
install_additional_dependencies
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
installDepend() {
|
||||
## Check for dependencies.
|
||||
echo -e "${YELLOW}Installing dependencies...${RC}"
|
||||
if [ "$PACKAGER" = "pacman" ]; then
|
||||
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
|
||||
echo "[multilib]" | sudo tee -a /etc/pacman.conf
|
||||
echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf
|
||||
sudo ${PACKAGER} -Syu
|
||||
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
|
||||
echo "Multilib is already enabled."
|
||||
fi
|
||||
if ! command_exists yay && ! command_exists paru; then
|
||||
echo "Installing yay as AUR helper..."
|
||||
sudo ${PACKAGER} -S --needed --noconfirm base-devel
|
||||
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git
|
||||
$ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm base-devel
|
||||
cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R ${USER}:${USER} ./yay-git
|
||||
cd yay-git && makepkg --noconfirm -si
|
||||
else
|
||||
echo "Aur helper already installed"
|
||||
|
@ -29,24 +29,24 @@ installDepend() {
|
|||
echo "No AUR helper found. Please install yay or paru."
|
||||
exit 1
|
||||
fi
|
||||
${AUR_HELPER} -S --needed --noconfirm wine giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap gnutls lib32-gnutls \
|
||||
$AUR_HELPER -S --needed --noconfirm wine giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap gnutls lib32-gnutls \
|
||||
mpg123 lib32-mpg123 openal lib32-openal v4l-utils lib32-v4l-utils libpulse lib32-libpulse libgpg-error \
|
||||
lib32-libgpg-error alsa-plugins lib32-alsa-plugins alsa-lib lib32-alsa-lib libjpeg-turbo lib32-libjpeg-turbo \
|
||||
sqlite lib32-sqlite libxcomposite lib32-libxcomposite libxinerama lib32-libgcrypt libgcrypt lib32-libxinerama \
|
||||
ncurses lib32-ncurses ocl-icd lib32-ocl-icd libxslt lib32-libxslt libva lib32-libva gtk3 \
|
||||
lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader lib32-vulkan-icd-loader
|
||||
elif [ "$PACKAGER" = "apt-get" ]; then
|
||||
sudo ${PACKAGER} update
|
||||
sudo ${PACKAGER} install -y wine64 wine32 libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386
|
||||
$ESCALATION_TOOL ${PACKAGER} update
|
||||
$ESCALATION_TOOL ${PACKAGER} install -y wine64 wine32 libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386
|
||||
elif [ "$PACKAGER" = "dnf" ] || [ "$PACKAGER" = "zypper" ]; then
|
||||
sudo ${PACKAGER} install -y wine
|
||||
$ESCALATION_TOOL ${PACKAGER} install -y wine
|
||||
else
|
||||
sudo ${PACKAGER} install -y ${DEPENDENCIES}
|
||||
$ESCALATION_TOOL ${PACKAGER} install -y ${DEPENDENCIES}
|
||||
fi
|
||||
}
|
||||
|
||||
install_additional_dependencies() {
|
||||
case $(which apt-get || which zypper || which dnf || which pacman) in
|
||||
case $(command -v apt-get || command -v zypper || command -v dnf || command -v pacman) in
|
||||
*apt-get)
|
||||
version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris |
|
||||
grep -v 'beta' |
|
||||
|
@ -58,8 +58,8 @@ install_additional_dependencies() {
|
|||
|
||||
# Install the downloaded .deb package using apt-get
|
||||
echo "Installing lutris_${version_no_v}_all.deb"
|
||||
sudo apt-get update
|
||||
sudo apt-get install ./lutris_${version_no_v}_all.deb
|
||||
$ESCALATION_TOOL apt-get update
|
||||
$ESCALATION_TOOL apt-get install ./lutris_${version_no_v}_all.deb
|
||||
|
||||
# Clean up the downloaded .deb file
|
||||
rm lutris_${version_no_v}_all.deb
|
||||
|
@ -70,44 +70,45 @@ install_additional_dependencies() {
|
|||
#Install steam on Debian
|
||||
if (lsb_release -i | grep -qi Debian); then
|
||||
#Enable i386 repos
|
||||
sudo dpkg --add-architecture i386
|
||||
$ESCALATION_TOOL dpkg --add-architecture i386
|
||||
# Install software-properties-common to be able to add repos
|
||||
sudo apt-get install -y software-properties-common
|
||||
$ESCALATION_TOOL apt-get install -y software-properties-common
|
||||
# Add repos necessary for installing steam
|
||||
sudo apt-add-repository contrib -y
|
||||
sudo apt-add-repository non-free -y
|
||||
$ESCALATION_TOOL apt-add-repository contrib -y
|
||||
$ESCALATION_TOOL apt-add-repository non-free -y
|
||||
#Install steam
|
||||
sudo apt-get install steam-installer -y
|
||||
$ESCALATION_TOOL apt-get install steam-installer -y
|
||||
else
|
||||
#Install steam on Ubuntu
|
||||
sudo apt-get install -y steam
|
||||
$ESCALATION_TOOL apt-get install -y steam
|
||||
fi
|
||||
;;
|
||||
*zypper)
|
||||
|
||||
|
||||
;;
|
||||
*dnf)
|
||||
|
||||
|
||||
;;
|
||||
*pacman)
|
||||
echo "Installing Steam for Arch Linux..."
|
||||
sudo pacman -S --needed --noconfirm steam
|
||||
$ESCALATION_TOOL pacman -S --needed --noconfirm steam
|
||||
echo "Steam installation complete."
|
||||
|
||||
echo "Installing Lutris for Arch Linux..."
|
||||
sudo pacman -S --needed --noconfirm lutris
|
||||
$ESCALATION_TOOL pacman -S --needed --noconfirm lutris
|
||||
echo "Lutris installation complete."
|
||||
|
||||
echo "Installing GOverlay for Arch Linux..."
|
||||
sudo pacman -S --needed --noconfirm goverlay
|
||||
$ESCALATION_TOOL pacman -S --needed --noconfirm goverlay
|
||||
echo "GOverlay installation complete."
|
||||
;;
|
||||
*)
|
||||
|
||||
;;
|
||||
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
installDepend
|
||||
install_additional_dependencies
|
||||
|
|
|
@ -1,35 +1,24 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
|
||||
# Check if the home directory and linuxtoolbox folder exist, create them if they don't
|
||||
LINUXTOOLBOXDIR="$HOME/linuxtoolbox"
|
||||
|
||||
if [ ! -d "$LINUXTOOLBOXDIR" ]; then
|
||||
printf "${YELLOW}Creating linuxtoolbox directory: %s${RC}\n" "$LINUXTOOLBOXDIR"
|
||||
mkdir -p "$LINUXTOOLBOXDIR"
|
||||
printf "${GREEN}linuxtoolbox directory created: %s${RC}\n" "$LINUXTOOLBOXDIR"
|
||||
fi
|
||||
|
||||
cd "$LINUXTOOLBOXDIR" || exit
|
||||
. ../common-script.sh
|
||||
|
||||
install_theme_tools() {
|
||||
printf "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}\n"
|
||||
case $PACKAGER in
|
||||
apt-get)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y qt6ct kvantum
|
||||
$ESCALATION_TOOL apt-get update
|
||||
$ESCALATION_TOOL apt-get install -y qt6ct kvantum
|
||||
;;
|
||||
zypper)
|
||||
sudo zypper refresh
|
||||
sudo zypper --non-interactive install qt6ct kvantum
|
||||
$ESCALATION_TOOL zypper refresh
|
||||
$ESCALATION_TOOL zypper --non-interactive install qt6ct kvantum
|
||||
;;
|
||||
dnf)
|
||||
sudo dnf update
|
||||
sudo dnf install -y qt6ct kvantum
|
||||
$ESCALATION_TOOL dnf update
|
||||
$ESCALATION_TOOL dnf install -y qt6ct kvantum
|
||||
;;
|
||||
pacman)
|
||||
sudo pacman -S --needed --noconfirm qt6ct kvantum
|
||||
$ESCALATION_TOOL pacman -S --needed --noconfirm qt6ct kvantum
|
||||
;;
|
||||
*)
|
||||
printf "${RED}Unsupported package manager. Please install qt6ct and kvantum manually.${RC}\n"
|
||||
|
@ -52,7 +41,7 @@ EOF
|
|||
# Add QT_QPA_PLATFORMTHEME to /etc/environment
|
||||
if ! grep -q "QT_QPA_PLATFORMTHEME=qt6ct" /etc/environment; then
|
||||
printf "${YELLOW}Adding QT_QPA_PLATFORMTHEME to /etc/environment...${RC}\n"
|
||||
echo "QT_QPA_PLATFORMTHEME=qt6ct" | sudo tee -a /etc/environment > /dev/null
|
||||
echo "QT_QPA_PLATFORMTHEME=qt6ct" | $ESCALATION_TOOL tee -a /etc/environment > /dev/null
|
||||
printf "${GREEN}QT_QPA_PLATFORMTHEME added to /etc/environment.${RC}\n"
|
||||
else
|
||||
printf "${GREEN}QT_QPA_PLATFORMTHEME already set in /etc/environment.${RC}\n"
|
||||
|
@ -70,6 +59,7 @@ EOF
|
|||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
install_theme_tools
|
||||
configure_qt6ct
|
||||
configure_kvantum
|
||||
|
|
|
@ -1,28 +1,30 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
removeSnaps() {
|
||||
case $PACKAGER in
|
||||
pacman)
|
||||
sudo ${PACKAGER} -Rns snapd
|
||||
$ESCALATION_TOOL ${PACKAGER} -Rns snapd
|
||||
;;
|
||||
apt-get|nala)
|
||||
sudo ${PACKAGER} autoremove --purge snapd
|
||||
$ESCALATION_TOOL ${PACKAGER} autoremove --purge snapd
|
||||
if [ "$ID" = ubuntu ]; then
|
||||
sudo apt-mark hold snapd
|
||||
$ESCALATION_TOOL apt-mark hold snapd
|
||||
fi
|
||||
;;
|
||||
dnf)
|
||||
sudo ${PACKAGER} remove snapd
|
||||
$ESCALATION_TOOL ${PACKAGER} remove snapd
|
||||
;;
|
||||
zypper)
|
||||
sudo ${PACKAGER} remove snapd
|
||||
$ESCALATION_TOOL ${PACKAGER} remove snapd
|
||||
;;
|
||||
*)
|
||||
echo "removing snapd not implemented for this package manager"
|
||||
echo "Removing snapd not implemented for this package manager"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
removeSnaps
|
||||
|
|
7
src/commands/system-setup/arch/paru-setup.sh
Normal file → Executable file
7
src/commands/system-setup/arch/paru-setup.sh
Normal file → Executable file
|
@ -7,8 +7,8 @@ installDepend() {
|
|||
pacman)
|
||||
if ! command_exists paru; then
|
||||
echo "Installing paru as AUR helper..."
|
||||
sudo "$PACKAGER" -S --needed --noconfirm base-devel
|
||||
cd /opt && sudo git clone https://aur.archlinux.org/paru.git && sudo chown -R "$USER": ./paru
|
||||
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel
|
||||
cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/paru.git && $ESCALATION_TOOL chown -R "$USER": ./paru
|
||||
cd paru && makepkg --noconfirm -si
|
||||
echo "Paru installed"
|
||||
else
|
||||
|
@ -22,4 +22,5 @@ installDepend() {
|
|||
}
|
||||
|
||||
checkEnv
|
||||
installDepend
|
||||
checkEscalationTool
|
||||
installDepend
|
||||
|
|
676
src/commands/system-setup/arch/server-setup.sh
Executable file
676
src/commands/system-setup/arch/server-setup.sh
Executable file
|
@ -0,0 +1,676 @@
|
|||
#!/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 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 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 formating 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 -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 -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 -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 -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 "
|
||||
-------------------------------------------------------------------------
|
||||
Formating 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::+300M --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
|
||||
btrfs subvolume create /mnt/@var
|
||||
btrfs subvolume create /mnt/@tmp
|
||||
btrfs subvolume create /mnt/@.snapshots
|
||||
}
|
||||
|
||||
# @description Mount all btrfs subvolumes after root has been mounted.
|
||||
mountallsubvol () {
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@home ${partition3} /mnt/home
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@tmp ${partition3} /mnt/tmp
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@var ${partition3} /mnt/var
|
||||
mount -o ${MOUNT_OPTIONS},subvol=@.snapshots ${partition3} /mnt/.snapshots
|
||||
}
|
||||
|
||||
# @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,var,tmp,.snapshots}
|
||||
# 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 <<EOF
|
||||
|
||||
echo -ne "
|
||||
-------------------------------------------------------------------------
|
||||
Network Setup
|
||||
-------------------------------------------------------------------------
|
||||
"
|
||||
pacman -S --noconfirm --needed networkmanager dhclient
|
||||
systemctl enable --now NetworkManager
|
||||
echo -ne "
|
||||
-------------------------------------------------------------------------
|
||||
Setting up mirrors for optimal download
|
||||
-------------------------------------------------------------------------
|
||||
"
|
||||
pacman -S --noconfirm --needed pacman-contrib curl
|
||||
pacman -S --noconfirm --needed reflector rsync grub arch-install-scripts git ntp wget
|
||||
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
|
||||
|
||||
nc=$(grep -c ^processor /proc/cpuinfo)
|
||||
echo -ne "
|
||||
-------------------------------------------------------------------------
|
||||
You have " $nc" cores. And
|
||||
changing the makeflags for " $nc" cores. Aswell as
|
||||
changing the compression settings.
|
||||
-------------------------------------------------------------------------
|
||||
"
|
||||
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
|
||||
if [[ $TOTAL_MEM -gt 8000000 ]]; then
|
||||
sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$nc\"/g" /etc/makepkg.conf
|
||||
sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf
|
||||
fi
|
||||
echo -ne "
|
||||
-------------------------------------------------------------------------
|
||||
Setup Language to US and set locale
|
||||
-------------------------------------------------------------------------
|
||||
"
|
||||
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
||||
locale-gen
|
||||
timedatectl --no-ask-password set-timezone ${TIMEZONE}
|
||||
timedatectl --no-ask-password set-ntp 1
|
||||
localectl --no-ask-password set-locale LANG="en_US.UTF-8" LC_TIME="en_US.UTF-8"
|
||||
ln -s /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
|
||||
# Set keymaps
|
||||
localectl --no-ask-password set-keymap ${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
|
||||
|
||||
# Replace in the same state
|
||||
cd "$(pwd)" || exit
|
||||
EOF
|
7
src/commands/system-setup/arch/yay-setup.sh
Normal file → Executable file
7
src/commands/system-setup/arch/yay-setup.sh
Normal file → Executable file
|
@ -7,8 +7,8 @@ installDepend() {
|
|||
pacman)
|
||||
if ! command_exists yay; then
|
||||
echo "Installing yay as AUR helper..."
|
||||
sudo "$PACKAGER" -S --needed --noconfirm base-devel
|
||||
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R "$USER": ./yay-git
|
||||
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel
|
||||
cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R "$USER": ./yay-git
|
||||
cd yay-git && makepkg --noconfirm -si
|
||||
echo "Yay installed"
|
||||
else
|
||||
|
@ -22,4 +22,5 @@ installDepend() {
|
|||
}
|
||||
|
||||
checkEnv
|
||||
installDepend
|
||||
checkEscalationTool
|
||||
installDepend
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./common-script.sh
|
||||
. ../common-script.sh
|
||||
|
||||
fastUpdate() {
|
||||
case ${PACKAGER} in
|
||||
pacman)
|
||||
if ! command_exists yay && ! command_exists paru; then
|
||||
echo "Installing yay as AUR helper..."
|
||||
sudo ${PACKAGER} -S --needed --noconfirm base-devel || { echo -e "${RED}Failed to install base-devel${RC}"; exit 1; }
|
||||
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git
|
||||
$ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm base-devel || { echo -e "${RED}Failed to install base-devel${RC}"; exit 1; }
|
||||
cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R ${USER}:${USER} ./yay-git
|
||||
cd yay-git && makepkg --noconfirm -si || { echo -e "${RED}Failed to install yay${RC}"; exit 1; }
|
||||
else
|
||||
echo "Aur helper already installed"
|
||||
|
@ -21,9 +21,9 @@ fastUpdate() {
|
|||
echo "No AUR helper found. Please install yay or paru."
|
||||
exit 1
|
||||
fi
|
||||
${AUR_HELPER} -S --needed --noconfirm rate-mirrors-bin
|
||||
$AUR_HELPER -S --needed --noconfirm rate-mirrors-bin
|
||||
if [ -s /etc/pacman.d/mirrorlist ]; then
|
||||
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
|
||||
$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
|
||||
|
@ -31,33 +31,33 @@ fastUpdate() {
|
|||
if [ "${DTYPE}" = "unknown" ]; then
|
||||
dtype_local="arch"
|
||||
fi
|
||||
sudo rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local}
|
||||
$ESCALATION_TOOL rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local}
|
||||
;;
|
||||
apt-get|nala)
|
||||
sudo apt-get update
|
||||
$ESCALATION_TOOL apt-get update
|
||||
if ! command_exists nala; then
|
||||
sudo apt-get install -y nala || { echo -e "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; }
|
||||
$ESCALATION_TOOL apt-get install -y nala || { echo -e "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; }
|
||||
fi
|
||||
if [ "${PACKAGER}" = "nala" ]; then
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
sudo nala update
|
||||
$ESCALATION_TOOL cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
$ESCALATION_TOOL nala update
|
||||
PACKAGER="nala"
|
||||
fi
|
||||
sudo ${PACKAGER} upgrade -y
|
||||
$ESCALATION_TOOL ${PACKAGER} upgrade -y
|
||||
;;
|
||||
dnf)
|
||||
sudo ${PACKAGER} update -y
|
||||
$ESCALATION_TOOL ${PACKAGER} update -y
|
||||
;;
|
||||
zypper)
|
||||
sudo ${PACKAGER} ref
|
||||
sudo ${PACKAGER} --non-interactive dup
|
||||
$ESCALATION_TOOL ${PACKAGER} ref
|
||||
$ESCALATION_TOOL ${PACKAGER} --non-interactive dup
|
||||
;;
|
||||
yum)
|
||||
sudo ${PACKAGER} update -y
|
||||
sudo ${PACKAGER} upgrade -y
|
||||
$ESCALATION_TOOL ${PACKAGER} update -y
|
||||
$ESCALATION_TOOL ${PACKAGER} upgrade -y
|
||||
;;
|
||||
xbps-install)
|
||||
sudo ${PACKAGER} -Syu
|
||||
$ESCALATION_TOOL ${PACKAGER} -Syu
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported package manager: $PACKAGER${RC}"
|
||||
|
@ -70,23 +70,23 @@ updateSystem() {
|
|||
echo -e "${GREEN}Updating system${RC}"
|
||||
case ${PACKAGER} in
|
||||
nala|apt-get)
|
||||
sudo "${PACKAGER}" update -y
|
||||
sudo "${PACKAGER}" upgrade -y
|
||||
$ESCALATION_TOOL "${PACKAGER}" update -y
|
||||
$ESCALATION_TOOL "${PACKAGER}" upgrade -y
|
||||
;;
|
||||
yum|dnf)
|
||||
sudo "${PACKAGER}" update -y
|
||||
sudo "${PACKAGER}" upgrade -y
|
||||
$ESCALATION_TOOL "${PACKAGER}" update -y
|
||||
$ESCALATION_TOOL "${PACKAGER}" upgrade -y
|
||||
;;
|
||||
pacman)
|
||||
sudo "${PACKAGER}" -Sy --noconfirm --needed archlinux-keyring
|
||||
sudo "${PACKAGER}" -Su --noconfirm
|
||||
$ESCALATION_TOOL "${PACKAGER}" -Sy --noconfirm --needed archlinux-keyring
|
||||
$ESCALATION_TOOL "${PACKAGER}" -Su --noconfirm
|
||||
;;
|
||||
zypper)
|
||||
sudo ${PACKAGER} ref
|
||||
sudo ${PACKAGER} --non-interactive dup
|
||||
$ESCALATION_TOOL ${PACKAGER} ref
|
||||
$ESCALATION_TOOL ${PACKAGER} --non-interactive dup
|
||||
;;
|
||||
xbps-install)
|
||||
sudo ${PACKAGER} -Syu
|
||||
$ESCALATION_TOOL ${PACKAGER} -Syu
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}"
|
||||
|
@ -102,6 +102,7 @@ updateFlatpaks() {
|
|||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
fastUpdate
|
||||
updateSystem
|
||||
updateFlatpaks
|
41
src/commands/system-setup/tab_data.toml
Normal file
41
src/commands/system-setup/tab_data.toml
Normal file
|
@ -0,0 +1,41 @@
|
|||
name = "System Setup"
|
||||
|
||||
[[data]]
|
||||
name = "Arch Linux"
|
||||
|
||||
[[data.preconditions]]
|
||||
matches = true
|
||||
data = "command_exists"
|
||||
values = ["pacman"]
|
||||
|
||||
[[data.entries]]
|
||||
name = "Arch Server Setup"
|
||||
script = "arch/server-setup.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Paru AUR Helper"
|
||||
script = "arch/paru-setup.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Yay AUR Helper"
|
||||
script = "arch/yay-setup.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Full System Update"
|
||||
script = "system-update.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Build Prerequisites"
|
||||
script = "1-compile-setup.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Gaming Dependencies"
|
||||
script = "2-gaming-setup.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Global Theme"
|
||||
script = "3-global-theme.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Remove Snaps"
|
||||
script = "4-remove-snaps.sh"
|
1
src/commands/tabs.toml
Normal file
1
src/commands/tabs.toml
Normal file
|
@ -0,0 +1 @@
|
|||
directories = ["system-setup", "applications-setup", "security", "utils"]
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
# Function to auto-detect displays and set common resolution
|
||||
auto_detect_displays() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
# Function to change monitor orientation
|
||||
change_orientation() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
RESET='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
# Function to duplicate displays
|
||||
duplicate_displays() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
RESET='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
# Function to extend displays
|
||||
extend_displays() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
# Function to manage monitor arrangement
|
||||
manage_arrangement() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
# Function to reset scaling back to 1 (native resolution) for all monitors
|
||||
reset_scaling() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
# Function to scale smaller monitors to the highest resolution of a bigger monitor
|
||||
scale_monitors() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
# Function to set a monitor as primary
|
||||
set_primary_monitor() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
source ./utils/monitor-control/utility_functions.sh
|
||||
source ./utility_functions.sh
|
||||
|
||||
RESET='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
|
|
60
src/commands/utils/numlock.sh
Executable file
60
src/commands/utils/numlock.sh
Executable file
|
@ -0,0 +1,60 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# setleds can be used in all distros
|
||||
# This method works by calling a script using systemd service
|
||||
|
||||
# Create a script to toggle numlock
|
||||
create_file() {
|
||||
echo "Creating script..."
|
||||
sudo tee "/usr/local/bin/numlock" >/dev/null <<'EOF'
|
||||
#!/bin/bash
|
||||
|
||||
for tty in /dev/tty{1..6}
|
||||
do
|
||||
/usr/bin/setleds -D +num < "$tty";
|
||||
done
|
||||
EOF
|
||||
|
||||
sudo chmod +x /usr/local/bin/numlock
|
||||
}
|
||||
|
||||
# Create a systemd service to run the script on boot
|
||||
create_service() {
|
||||
echo "Creating service..."
|
||||
sudo tee "/etc/systemd/system/numlock.service" >/dev/null <<'EOF'
|
||||
[Unit]
|
||||
Description=numlock
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/numlock
|
||||
StandardInput=tty
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
# Check if the script and service files exists
|
||||
if [ ! -f "/usr/local/bin/numlock" ]; then
|
||||
create_file
|
||||
fi
|
||||
|
||||
if [ ! -f "/etc/systemd/system/numlock.service" ]; then
|
||||
create_service
|
||||
fi
|
||||
|
||||
printf "Do you want to enable Numlock on boot? (y/n): "
|
||||
read -r confirm
|
||||
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
|
||||
sudo systemctl enable numlock.service --quiet
|
||||
echo "Numlock will be enabled on boot"
|
||||
else
|
||||
sudo systemctl disable numlock.service --quiet
|
||||
echo "Numlock will not be enabled on boot"
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
70
src/commands/utils/tab_data.toml
Normal file
70
src/commands/utils/tab_data.toml
Normal file
|
@ -0,0 +1,70 @@
|
|||
name = "Utilities"
|
||||
|
||||
[[data]]
|
||||
name = "WiFi Manager"
|
||||
script = "wifi-control.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Bluetooth Manager"
|
||||
script = "bluetooth-control.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Numlock on Startup"
|
||||
script = "numlock.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Monitor Control"
|
||||
|
||||
[[data.preconditions]]
|
||||
matches = true
|
||||
data = { environment = "XDG_SESSION_TYPE" }
|
||||
values = ["x11"]
|
||||
|
||||
[[data.entries]]
|
||||
name = "Set Resolution"
|
||||
script = "monitor-control/set_resolutions.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Set Resolution"
|
||||
script = "monitor-control/set_resolutions.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Duplicate Displays"
|
||||
script = "monitor-control/duplicate_displays.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Extend Displays"
|
||||
script = "monitor-control/extend_displays.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Auto Detect Displays"
|
||||
script = "monitor-control/auto_detect_displays.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Enable Monitor"
|
||||
script = "monitor-control/enable_monitor.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Disable Monitor"
|
||||
script = "monitor-control/disable_monitor.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Set Primary Monitor"
|
||||
script = "monitor-control/set_primary_monitor.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Change Orientation"
|
||||
script = "monitor-control/change_orientation.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Manage Arrangement"
|
||||
script = "monitor-control/manage_arrangement.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Scale Monitors"
|
||||
script = "monitor-control/scale_monitor.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Reset Scaling"
|
||||
script = "monitor-control/reset_scaling.sh"
|
||||
matches = true
|
|
@ -7,7 +7,6 @@ use ratatui::{
|
|||
widgets::{Block, Borders, List},
|
||||
Frame,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub struct FloatingText {
|
||||
text: Vec<String>,
|
||||
|
@ -19,7 +18,7 @@ impl FloatingText {
|
|||
Self { text, scroll: 0 }
|
||||
}
|
||||
|
||||
pub fn from_command(command: &Command, mut full_path: PathBuf) -> Option<Self> {
|
||||
pub fn from_command(command: &Command) -> Option<Self> {
|
||||
let lines = match command {
|
||||
Command::Raw(cmd) => {
|
||||
// Reconstruct the line breaks and file formatting after the
|
||||
|
@ -27,9 +26,8 @@ impl FloatingText {
|
|||
cmd.lines().map(|line| line.to_string()).collect()
|
||||
}
|
||||
Command::LocalFile(file_path) => {
|
||||
full_path.push(file_path);
|
||||
let file_contents = std::fs::read_to_string(&full_path)
|
||||
.map_err(|_| format!("File not found: {:?}", &full_path))
|
||||
let file_contents = std::fs::read_to_string(file_path)
|
||||
.map_err(|_| format!("File not found: {:?}", file_path))
|
||||
.unwrap();
|
||||
file_contents.lines().map(|line| line.to_string()).collect()
|
||||
}
|
||||
|
|
|
@ -34,20 +34,21 @@ struct Args {
|
|||
#[arg(default_value_t = Theme::Default)]
|
||||
#[arg(help = "Set the theme to use in the application")]
|
||||
theme: Theme,
|
||||
#[arg(long, default_value_t = false)]
|
||||
#[clap(help = "Show all available options, disregarding compatibility checks (UNSAFE)")]
|
||||
override_validation: bool,
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let theme = args.theme;
|
||||
|
||||
let commands_dir = include_dir!("src/commands");
|
||||
let temp_dir: TempDir = TempDir::new("linutil_scripts").unwrap();
|
||||
commands_dir
|
||||
.extract(temp_dir.path())
|
||||
.expect("Failed to extract the saved directory");
|
||||
|
||||
let mut state = AppState::new(theme, temp_dir.path().to_owned());
|
||||
let mut state = AppState::new(args.theme, temp_dir.path(), args.override_validation);
|
||||
|
||||
stdout().execute(EnterAlternateScreen)?;
|
||||
enable_raw_mode()?;
|
||||
|
|
|
@ -13,7 +13,7 @@ use ratatui::{
|
|||
};
|
||||
use std::{
|
||||
io::Write,
|
||||
path::Path,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex},
|
||||
thread::JoinHandle,
|
||||
};
|
||||
|
@ -22,10 +22,10 @@ use tui_term::{
|
|||
widget::PseudoTerminal,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Hash, Eq, PartialEq)]
|
||||
pub enum Command {
|
||||
Raw(&'static str),
|
||||
LocalFile(&'static str),
|
||||
Raw(String),
|
||||
LocalFile(PathBuf),
|
||||
None, // Directory
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ impl FloatContent for RunningCommand {
|
|||
}
|
||||
|
||||
impl RunningCommand {
|
||||
pub fn new(command: Command, temp_path: &Path) -> Self {
|
||||
pub fn new(command: Command) -> Self {
|
||||
let pty_system = NativePtySystem::default();
|
||||
|
||||
// Build the command based on the provided Command enum variant
|
||||
|
@ -137,13 +137,14 @@ impl RunningCommand {
|
|||
cmd.arg(prompt);
|
||||
}
|
||||
Command::LocalFile(file) => {
|
||||
cmd.arg(file);
|
||||
cmd.arg(&file);
|
||||
if let Some(parent) = file.parent() {
|
||||
cmd.cwd(parent);
|
||||
}
|
||||
}
|
||||
Command::None => panic!("Command::None was treated as a command"),
|
||||
}
|
||||
|
||||
cmd.cwd(temp_path);
|
||||
|
||||
// Open a pseudo-terminal with initial size
|
||||
let pair = pty_system
|
||||
.openpty(PtySize {
|
||||
|
|
43
src/state.rs
43
src/state.rs
|
@ -2,7 +2,7 @@ use crate::{
|
|||
float::{Float, FloatContent},
|
||||
floating_text::FloatingText,
|
||||
running_command::{Command, RunningCommand},
|
||||
tabs::{ListNode, TABS},
|
||||
tabs::{ListNode, Tab},
|
||||
theme::Theme,
|
||||
};
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyEventKind};
|
||||
|
@ -14,15 +14,15 @@ use ratatui::{
|
|||
widgets::{Block, Borders, List, ListState, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
use std::path::Path;
|
||||
|
||||
pub struct AppState {
|
||||
/// Selected theme
|
||||
pub theme: Theme,
|
||||
/// Path to the root of the unpacked files in /tmp
|
||||
temp_path: PathBuf,
|
||||
theme: Theme,
|
||||
/// Currently focused area
|
||||
focus: Focus,
|
||||
/// List of tabs
|
||||
tabs: Vec<Tab>,
|
||||
/// Current tab
|
||||
current_tab: ListState,
|
||||
/// Current search query
|
||||
|
@ -51,12 +51,13 @@ struct ListEntry {
|
|||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new(theme: Theme, temp_path: PathBuf) -> Self {
|
||||
let root_id = TABS[0].tree.root().id();
|
||||
pub fn new(theme: Theme, temp_path: &Path, override_validation: bool) -> Self {
|
||||
let tabs = crate::tabs::get_tabs(temp_path, !override_validation);
|
||||
let root_id = tabs[0].tree.root().id();
|
||||
let mut state = Self {
|
||||
theme,
|
||||
temp_path,
|
||||
focus: Focus::List,
|
||||
tabs,
|
||||
current_tab: ListState::default().with_selected(Some(0)),
|
||||
search_query: String::new(),
|
||||
items: vec![],
|
||||
|
@ -67,7 +68,8 @@ impl AppState {
|
|||
state
|
||||
}
|
||||
pub fn draw(&mut self, frame: &mut Frame) {
|
||||
let longest_tab_display_len = TABS
|
||||
let longest_tab_display_len = self
|
||||
.tabs
|
||||
.iter()
|
||||
.map(|tab| tab.name.len() + self.theme.tab_icon().len())
|
||||
.max()
|
||||
|
@ -85,7 +87,11 @@ impl AppState {
|
|||
.constraints([Constraint::Length(3), Constraint::Min(1)])
|
||||
.split(horizontal[0]);
|
||||
|
||||
let tabs = TABS.iter().map(|tab| tab.name).collect::<Vec<_>>();
|
||||
let tabs = self
|
||||
.tabs
|
||||
.iter()
|
||||
.map(|tab| tab.name.as_str())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let tab_hl_style = if let Focus::TabList = self.focus {
|
||||
Style::default().reversed().fg(self.theme.tab_color())
|
||||
|
@ -186,7 +192,7 @@ impl AppState {
|
|||
self.focus = Focus::List
|
||||
}
|
||||
KeyCode::Char('j') | KeyCode::Down
|
||||
if self.current_tab.selected().unwrap() + 1 < TABS.len() =>
|
||||
if self.current_tab.selected().unwrap() + 1 < self.tabs.len() =>
|
||||
{
|
||||
self.current_tab.select_next();
|
||||
self.refresh_tab();
|
||||
|
@ -224,7 +230,7 @@ impl AppState {
|
|||
}
|
||||
pub fn update_items(&mut self) {
|
||||
if self.search_query.is_empty() {
|
||||
let curr = TABS[self.current_tab.selected().unwrap()]
|
||||
let curr = self.tabs[self.current_tab.selected().unwrap()]
|
||||
.tree
|
||||
.get(*self.visit_stack.last().unwrap())
|
||||
.unwrap();
|
||||
|
@ -241,7 +247,7 @@ impl AppState {
|
|||
self.items.clear();
|
||||
|
||||
let query_lower = self.search_query.to_lowercase();
|
||||
for tab in TABS.iter() {
|
||||
for tab in self.tabs.iter() {
|
||||
let mut stack = vec![tab.tree.root().id()];
|
||||
while let Some(node_id) = stack.pop() {
|
||||
let node = tab.tree.get(node_id).unwrap();
|
||||
|
@ -259,7 +265,7 @@ impl AppState {
|
|||
stack.extend(node.children().map(|child| child.id()));
|
||||
}
|
||||
}
|
||||
self.items.sort_by(|a, b| a.node.name.cmp(b.node.name));
|
||||
self.items.sort_by(|a, b| a.node.name.cmp(&b.node.name));
|
||||
}
|
||||
}
|
||||
/// Checks ehther the current tree node is the root node (can we go up the tree or no)
|
||||
|
@ -299,14 +305,14 @@ impl AppState {
|
|||
}
|
||||
fn enable_preview(&mut self) {
|
||||
if let Some(command) = self.get_selected_command(false) {
|
||||
if let Some(preview) = FloatingText::from_command(&command, self.temp_path.clone()) {
|
||||
if let Some(preview) = FloatingText::from_command(&command) {
|
||||
self.spawn_float(preview, 80, 80);
|
||||
}
|
||||
}
|
||||
}
|
||||
fn handle_enter(&mut self) {
|
||||
if let Some(cmd) = self.get_selected_command(true) {
|
||||
let command = RunningCommand::new(cmd, &self.temp_path);
|
||||
let command = RunningCommand::new(cmd);
|
||||
self.spawn_float(command, 80, 80);
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +329,10 @@ impl AppState {
|
|||
self.update_items();
|
||||
}
|
||||
fn refresh_tab(&mut self) {
|
||||
self.visit_stack = vec![TABS[self.current_tab.selected().unwrap()].tree.root().id()];
|
||||
self.visit_stack = vec![self.tabs[self.current_tab.selected().unwrap()]
|
||||
.tree
|
||||
.root()
|
||||
.id()];
|
||||
self.selection.select(Some(0));
|
||||
self.update_items();
|
||||
}
|
||||
|
|
341
src/tabs.rs
341
src/tabs.rs
|
@ -1,175 +1,190 @@
|
|||
use std::sync::LazyLock;
|
||||
|
||||
use ego_tree::{tree, Tree};
|
||||
|
||||
use crate::running_command::Command;
|
||||
use ego_tree::{NodeMut, Tree};
|
||||
use serde::Deserialize;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct TabList {
|
||||
directories: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct TabEntry {
|
||||
name: String,
|
||||
data: Vec<Entry>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Entry {
|
||||
name: String,
|
||||
#[allow(dead_code)]
|
||||
#[serde(default)]
|
||||
description: String,
|
||||
#[serde(default)]
|
||||
preconditions: Option<Vec<Precondition>>,
|
||||
#[serde(default)]
|
||||
entries: Option<Vec<Entry>>,
|
||||
#[serde(default)]
|
||||
command: Option<String>,
|
||||
#[serde(default)]
|
||||
script: Option<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<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
enum SystemDataType {
|
||||
#[serde(rename = "environment")]
|
||||
Environment(String),
|
||||
#[serde(rename = "file")]
|
||||
File(PathBuf),
|
||||
#[serde(rename = "command_exists")]
|
||||
CommandExists,
|
||||
}
|
||||
|
||||
#[derive(Hash, Eq, PartialEq)]
|
||||
pub struct Tab {
|
||||
pub name: &'static str,
|
||||
pub name: String,
|
||||
pub tree: Tree<ListNode>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Hash, Eq, PartialEq)]
|
||||
pub struct ListNode {
|
||||
pub name: &'static str,
|
||||
pub name: String,
|
||||
pub command: Command,
|
||||
}
|
||||
|
||||
pub static TABS: LazyLock<Vec<Tab>> = LazyLock::new(|| {
|
||||
vec![
|
||||
Tab {
|
||||
name: "System Setup",
|
||||
tree: tree!(ListNode {
|
||||
name: "root",
|
||||
pub fn get_tabs(command_dir: &Path, validate: bool) -> Vec<Tab> {
|
||||
let tab_files = TabList::get_tabs(command_dir);
|
||||
let tabs = 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)
|
||||
});
|
||||
|
||||
let tabs: Vec<Tab> = tabs
|
||||
.map(|(TabEntry { name, data }, directory)| {
|
||||
let mut tree = Tree::new(ListNode {
|
||||
name: "root".to_string(),
|
||||
command: Command::None,
|
||||
} => {
|
||||
ListNode {
|
||||
name: "Arch Linux",
|
||||
command: Command::None,
|
||||
} => {
|
||||
ListNode {
|
||||
name: "Yay AUR Helper",
|
||||
command: Command::LocalFile("system-setup/arch/yay-setup.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Paru AUR Helper",
|
||||
command: Command::LocalFile("system-setup/arch/paru-setup.sh"),
|
||||
}
|
||||
},
|
||||
ListNode {
|
||||
name: "Full System Update",
|
||||
command: Command::LocalFile("system-update.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Build Prerequisites",
|
||||
command: Command::LocalFile("system-setup/1-compile-setup.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Gaming Dependencies",
|
||||
command: Command::LocalFile("system-setup/2-gaming-setup.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Global Theme",
|
||||
command: Command::LocalFile("system-setup/3-global-theme.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Remove Snaps",
|
||||
command: Command::LocalFile("system-setup/4-remove-snaps.sh"),
|
||||
}
|
||||
}),
|
||||
},
|
||||
Tab {
|
||||
name: "Applications Setup",
|
||||
tree: tree!(ListNode {
|
||||
name: "root",
|
||||
});
|
||||
let mut root = tree.root_mut();
|
||||
create_directory(data, &mut root, &directory);
|
||||
Tab { name, tree }
|
||||
})
|
||||
.collect();
|
||||
|
||||
if tabs.is_empty() {
|
||||
panic!("No tabs found");
|
||||
}
|
||||
tabs
|
||||
}
|
||||
|
||||
fn filter_entries(entries: &mut Vec<Entry>) {
|
||||
entries.retain_mut(|entry| {
|
||||
if !entry.is_supported() {
|
||||
return false;
|
||||
}
|
||||
if let Some(entries) = &mut entry.entries {
|
||||
filter_entries(entries);
|
||||
!entries.is_empty()
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn create_directory(data: Vec<Entry>, node: &mut NodeMut<ListNode>, command_dir: &Path) {
|
||||
for entry in data {
|
||||
if [
|
||||
entry.entries.is_some(),
|
||||
entry.command.is_some(),
|
||||
entry.script.is_some(),
|
||||
]
|
||||
.iter()
|
||||
.filter(|&&x| x)
|
||||
.count()
|
||||
> 1
|
||||
{
|
||||
panic!("Entry must have only one data type");
|
||||
}
|
||||
|
||||
if let Some(entries) = entry.entries {
|
||||
let mut node = node.append(ListNode {
|
||||
name: entry.name,
|
||||
command: Command::None,
|
||||
} => {
|
||||
ListNode {
|
||||
name: "Alacritty",
|
||||
command: Command::LocalFile("applications-setup/alacritty-setup.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Bash Prompt",
|
||||
command: Command::Raw("bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/setup.sh)\""),
|
||||
},
|
||||
ListNode {
|
||||
name: "DWM-Titus",
|
||||
command: Command::LocalFile("applications-setup/dwmtitus-setup.sh")
|
||||
},
|
||||
ListNode {
|
||||
name: "Kitty",
|
||||
command: Command::LocalFile("applications-setup/kitty-setup.sh")
|
||||
},
|
||||
ListNode {
|
||||
name: "Neovim",
|
||||
command: Command::Raw("bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/neovim/main/setup.sh)\""),
|
||||
},
|
||||
ListNode {
|
||||
name: "Rofi",
|
||||
command: Command::LocalFile("applications-setup/rofi-setup.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "ZSH Prompt",
|
||||
command: Command::LocalFile("applications-setup/zsh-setup.sh"),
|
||||
}
|
||||
}),
|
||||
},
|
||||
Tab {
|
||||
name: "Security",
|
||||
tree: tree!(ListNode {
|
||||
name: "root",
|
||||
command: Command::None,
|
||||
} => {
|
||||
ListNode {
|
||||
name: "Firewall Baselines (CTT)",
|
||||
command: Command::LocalFile("security/firewall-baselines.sh"),
|
||||
}
|
||||
}),
|
||||
},
|
||||
Tab {
|
||||
name: "Utilities",
|
||||
tree: tree!(ListNode {
|
||||
name: "root",
|
||||
command: Command::None,
|
||||
} => {
|
||||
ListNode {
|
||||
name: "Wifi Manager",
|
||||
command: Command::LocalFile("utils/wifi-control.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Bluetooth Manager",
|
||||
command: Command::LocalFile("utils/bluetooth-control.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "MonitorControl(xorg)",
|
||||
command: Command::None,
|
||||
} => {
|
||||
ListNode {
|
||||
name: "Set Resolution",
|
||||
command: Command::LocalFile("utils/monitor-control/set_resolutions.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Duplicate Displays",
|
||||
command: Command::LocalFile("utils/monitor-control/duplicate_displays.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Extend Displays",
|
||||
command: Command::LocalFile("utils/monitor-control/extend_displays.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Auto Detect Displays",
|
||||
command: Command::LocalFile("utils/monitor-control/auto_detect_displays.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Enable Monitor",
|
||||
command: Command::LocalFile("utils/monitor-control/enable_monitor.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Disable Monitor",
|
||||
command: Command::LocalFile("utils/monitor-control/disable_monitor.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Set Primary Monitor",
|
||||
command: Command::LocalFile("utils/monitor-control/set_primary_monitor.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Change Orientation",
|
||||
command: Command::LocalFile("utils/monitor-control/change_orientation.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Manage Arrangement",
|
||||
command: Command::LocalFile("utils/monitor-control/manage_arrangement.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Scale Monitors",
|
||||
command: Command::LocalFile("utils/monitor-control/scale_monitor.sh"),
|
||||
},
|
||||
ListNode {
|
||||
name: "Reset Scaling",
|
||||
command: Command::LocalFile("utils/monitor-control/reset_scaling.sh"),
|
||||
}
|
||||
},
|
||||
}),
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
create_directory(entries, &mut node, command_dir);
|
||||
} else if let Some(command) = entry.command {
|
||||
node.append(ListNode {
|
||||
name: entry.name,
|
||||
command: Command::Raw(command),
|
||||
});
|
||||
} else if let Some(script) = entry.script {
|
||||
let dir = command_dir.join(script);
|
||||
if !dir.exists() {
|
||||
panic!("Script {} does not exist", dir.display());
|
||||
}
|
||||
node.append(ListNode {
|
||||
name: entry.name,
|
||||
command: Command::LocalFile(dir),
|
||||
});
|
||||
} else {
|
||||
panic!("Entry must have data");
|
||||
}
|
||||
}
|
||||
}
|
||||
impl TabList {
|
||||
fn get_tabs(command_dir: &Path) -> Vec<PathBuf> {
|
||||
let tab_files = std::fs::read_to_string(command_dir.join("tabs.toml"))
|
||||
.expect("Failed to read tabs.toml");
|
||||
let data: Self = toml::from_str(&tab_files).expect("Failed to parse tabs.toml");
|
||||
|
||||
data.directories
|
||||
.into_iter()
|
||||
.map(|path| command_dir.join(path).join("tab_data.toml"))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user