mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 05:12:27 +00:00
Merge branch 'main' of https://github.com/ChrisTitusTech/linutil
This commit is contained in:
commit
72ebf08811
8
.github/workflows/bashisms.yml
vendored
8
.github/workflows/bashisms.yml
vendored
|
@ -3,11 +3,11 @@ name: Check for bashisms
|
|||
on:
|
||||
# push:
|
||||
# paths:
|
||||
# - tabs/**
|
||||
# - core/tabs/**
|
||||
# branches: [ "main" ]
|
||||
pull_request:
|
||||
paths:
|
||||
- tabs/**
|
||||
- core/tabs/**
|
||||
merge_group:
|
||||
workflow_dispatch:
|
||||
|
||||
|
@ -24,8 +24,8 @@ jobs:
|
|||
|
||||
- name: Check for bashisms in changed files
|
||||
run: |
|
||||
for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD tabs); do
|
||||
if [[ "$file" == *.sh ]]; then
|
||||
for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs); do
|
||||
if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then
|
||||
checkbashisms "$file"
|
||||
fi
|
||||
done
|
||||
|
|
25
.github/workflows/shellcheck.yml
vendored
25
.github/workflows/shellcheck.yml
vendored
|
@ -3,7 +3,7 @@ name: ShellCheck
|
|||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'tabs/**/*.sh'
|
||||
- 'core/tabs/**/*.sh'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
@ -11,9 +11,20 @@ jobs:
|
|||
name: Shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
with:
|
||||
scandir: 'tabs'
|
||||
severity: error
|
||||
- uses: actions/checkout@v4
|
||||
- run: git fetch origin ${{ github.base_ref }}
|
||||
|
||||
- name: Download and set up shellcheck
|
||||
run : |
|
||||
wget https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz
|
||||
tar -xf shellcheck-v0.10.0.linux.x86_64.tar.xz
|
||||
cd shellcheck-v0.10.0
|
||||
chmod +x shellcheck
|
||||
|
||||
- name: Run shellcheck
|
||||
run: |
|
||||
for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs); do
|
||||
if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then
|
||||
./shellcheck-v0.10.0/shellcheck -S error "$file"
|
||||
fi
|
||||
done
|
||||
|
|
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -452,7 +452,7 @@ checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
|||
|
||||
[[package]]
|
||||
name = "linutil_core"
|
||||
version = "0.1.0"
|
||||
version = "24.9.19"
|
||||
dependencies = [
|
||||
"ego-tree",
|
||||
"include_dir",
|
||||
|
@ -464,7 +464,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "linutil_tui"
|
||||
version = "0.1.0"
|
||||
version = "24.9.19"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[workspace.package]
|
||||
license = "MIT"
|
||||
version = "0.1.0"
|
||||
version = "24.9.19"
|
||||
|
||||
[workspace.dependencies]
|
||||
ego-tree = "0.6.2"
|
||||
|
|
11
README.md
11
README.md
|
@ -5,7 +5,7 @@
|
|||
[![](https://dcbadge.limes.pink/api/server/https://discord.gg/bujFYKAHSp)](https://discord.gg/bujFYKAHSp)
|
||||
|
||||
<!-- TODO: crates.io package here + <br> -->
|
||||
[![linutil AUR Version](https://img.shields.io/aur/version/linutil?style=for-the-badge&label=%5BAUR%5D%20linutil&color=%23230567ff)](https://aur.archlinux.org/packages/linutil) [![linutil-bin AUR Version](https://img.shields.io/aur/version/linutil-bin?style=for-the-badge&label=%5BAUR%5D%20linutil-bin&color=%23230567ff)](https://aur.archlinux.org/packages/linutil-bin)
|
||||
[![Crates.io Version](https://img.shields.io/crates/v/linutil_tui?style=for-the-badge&color=%23af3a03)](https://crates.io/crates/linutil_tui) [![linutil AUR Version](https://img.shields.io/aur/version/linutil?style=for-the-badge&label=%5BAUR%5D%20linutil&color=%23230567ff)](https://aur.archlinux.org/packages/linutil) [![linutil-bin AUR Version](https://img.shields.io/aur/version/linutil-bin?style=for-the-badge&label=%5BAUR%5D%20linutil-bin&color=%23230567ff)](https://aur.archlinux.org/packages/linutil-bin)
|
||||
|
||||
![Preview](docs/assets/preview.png)
|
||||
|
||||
|
@ -44,6 +44,11 @@ Thank you to everyone who has contributed to the development of Linutil. Your ef
|
|||
|
||||
[![Contributors](https://contrib.rocks/image?repo=ChrisTitusTech/linutil)](https://github.com/ChrisTitusTech/linutil/graphs/contributors)
|
||||
|
||||
## 📜 Credits
|
||||
## 📜 Contributor Milestones
|
||||
|
||||
Linutil’s Rust shell was developed by [@JustLinuxUser](https://github.com/JustLinuxUser).
|
||||
- 2024/07 - Original Linutil Rust TUI was developed by [@JustLinuxUser](https://github.com/JustLinuxUser).
|
||||
- 2024/09 - TabList (Left Column) and various Rust Core/TUI Improvements developed by [@lj3954](https://github.com/lj3954)
|
||||
- 2024/09 - Cargo Publish, AUR, Rust, and Bash additions done by [@adamperkowski](https://github.com/adamperkowski)
|
||||
- 2024/09 - Rust TUI Min/Max, MultiSelection, and Bash additions done by [@jeevithakannan2](https://github.com/jeevithakannan2)
|
||||
- 2024/09 - Various bash updates and standardization done by [@nnyyxxxx](https://github.com/nnyyxxxx)
|
||||
- 2024/09 - Multiple bash script additions done by [@guruswarupa](https://github.com/guruswarupa)
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
[package]
|
||||
name = "linutil_core"
|
||||
description = "The backend of Linutil."
|
||||
repository = "https://github.com/ChrisTitusTech/linutil/tree/main/core"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
license.workspace = true
|
||||
include = [
|
||||
"src/*.rs",
|
||||
"Cargo.toml",
|
||||
"tabs/**",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
include_dir = "0.7.4"
|
||||
|
|
|
@ -5,7 +5,7 @@ use serde::Deserialize;
|
|||
use std::path::{Path, PathBuf};
|
||||
use tempdir::TempDir;
|
||||
|
||||
const TAB_DATA: Dir = include_dir!("$CARGO_MANIFEST_DIR/../tabs");
|
||||
const TAB_DATA: Dir = include_dir!("$CARGO_MANIFEST_DIR/tabs");
|
||||
|
||||
pub fn get_tabs(validate: bool) -> Vec<Tab> {
|
||||
let tab_files = TabList::get_tabs();
|
||||
|
|
62
core/tabs/applications-setup/linutil-installer.sh
Executable file
62
core/tabs/applications-setup/linutil-installer.sh
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
installLinutil() {
|
||||
printf "%b\n" "${YELLOW}Installing Linutil...${RC}"
|
||||
case "$PACKAGER" in
|
||||
pacman)
|
||||
printf "%b\n" "-----------------------------------------------------"
|
||||
printf "%b\n" "Select the package to install:"
|
||||
printf "%b\n" "1. ${CYAN}linutil${RC} (stable release compiled from source)"
|
||||
printf "%b\n" "2. ${CYAN}linutil-bin${RC} (stable release pre-compiled)"
|
||||
printf "%b\n" "3. ${CYAN}linutil-git${RC} (compiled from the latest commit)"
|
||||
printf "%b\n" "-----------------------------------------------------"
|
||||
printf "%b" "Enter your choice: "
|
||||
read -r choice
|
||||
case $choice in
|
||||
1) "$AUR_HELPER" -S --noconfirm linutil ;;
|
||||
2) "$AUR_HELPER" -S --noconfirm linutil-bin ;;
|
||||
3) "$AUR_HELPER" -S --noconfirm linutil-git ;;
|
||||
*)
|
||||
printf "%b\n" "${RED}Invalid choice:${RC} $choice"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
printf "%b\n" "${GREEN}Installed successfully.${RC}"
|
||||
;;
|
||||
*)
|
||||
printf "%b\n" "${RED}There are no official packages for your distro.${RC}"
|
||||
printf "%b" "${YELLOW}Do you want to install the crates.io package? (y/N) ${RC}"
|
||||
read -r choice
|
||||
case $choice in
|
||||
y|Y)
|
||||
if ! command_exists cargo; then
|
||||
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
|
||||
case "$PACKAGER" in
|
||||
pacman)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
|
||||
;;
|
||||
zypper)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
. $HOME/.cargo/env
|
||||
;;
|
||||
*)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rustup default stable
|
||||
cargo install --force linutil_tui
|
||||
printf "%b\n" "${GREEN}Installed successfully.${RC}"
|
||||
;;
|
||||
*) printf "%b\n" "${RED}Linutil not installed.${RC}" ;;
|
||||
esac
|
||||
esac
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
checkAURHelper
|
||||
installLinutil
|
45
core/tabs/applications-setup/linutil-updater.sh
Executable file
45
core/tabs/applications-setup/linutil-updater.sh
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
updateLinutil() {
|
||||
if [ ! -e "$HOME/.cargo/bin/linutil" ]; then
|
||||
printf "%b\n" "${RED}This script only updates the binary installed through cargo.\nlinutil_tui is not installed.${RC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command_exists cargo; then
|
||||
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
|
||||
case "$PACKAGER" in
|
||||
pacman)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
|
||||
;;
|
||||
zypper)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
. $HOME/.cargo/env
|
||||
;;
|
||||
*)
|
||||
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
INSTALLED_VERSION=$(cargo install --list | grep "linutil_tui" | awk '{print $2}' | tr -d 'v:')
|
||||
LATEST_VERSION=$(curl -s https://crates.io/api/v1/crates/linutil_tui | grep -oP '"max_version":\s*"\K[^"]+')
|
||||
|
||||
if [ "$INSTALLED_VERSION" = "$LATEST_VERSION" ]; then
|
||||
printf "%b\n" "${GREEN}linutil_tui is up to date.${RC}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "%b\n" "${YELLOW}Updating linutil_tui...${RC}"
|
||||
rustup default stable
|
||||
cargo install --force linutil_tui
|
||||
printf "%b\n" "${GREEN}Updated successfully.${RC}"
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
checkAURHelper
|
||||
updateLinutil
|
|
@ -53,3 +53,23 @@ script = "rofi-setup.sh"
|
|||
name = "ZSH Prompt"
|
||||
description = "The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.\nThis command installs ZSH prompt and provides basic configuration."
|
||||
script = "zsh-setup.sh"
|
||||
|
||||
[[data]]
|
||||
name = "Install Linutil"
|
||||
description = "Installs a distro-specific Linutil package locally."
|
||||
script = "linutil-installer.sh"
|
||||
|
||||
[[data.preconditions]]
|
||||
matches = false
|
||||
data = "command_exists"
|
||||
values = [ "linutil" ]
|
||||
|
||||
[[data]]
|
||||
name = "Update Linutil"
|
||||
description = "Updates your local Linutil crate installation."
|
||||
script = "linutil-updater.sh"
|
||||
|
||||
[[data.preconditions]]
|
||||
matches = true
|
||||
data = "command_exists"
|
||||
values = [ "linutil" ]
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
themeinstall(){
|
|
@ -157,8 +157,8 @@ configure_firewall() {
|
|||
}
|
||||
|
||||
setup_ssh_samba(){
|
||||
printf "Samba and SSH Setup Script\n"
|
||||
printf "----------------------------\n"
|
||||
printf "%b\n" "Samba and SSH Setup Script"
|
||||
printf "%b\n" "--------------------------"
|
||||
clear
|
||||
|
||||
# Display menu
|
|
@ -4,18 +4,18 @@
|
|||
|
||||
# Function to list common session options
|
||||
list_sessions() {
|
||||
printf "Select the session:\n"
|
||||
printf "1) GNOME (gnome.desktop)\n"
|
||||
printf "2) KDE Plasma (plasma.desktop)\n"
|
||||
printf "3) XFCE (xfce.desktop)\n"
|
||||
printf "4) LXDE (LXDE.desktop)\n"
|
||||
printf "5) LXQt (lxqt.desktop)\n"
|
||||
printf "6) Cinnamon (cinnamon.desktop)\n"
|
||||
printf "7) MATE (mate.desktop)\n"
|
||||
printf "8) Openbox (openbox.desktop)\n"
|
||||
printf "9) i3 (i3.desktop)\n"
|
||||
printf "10) Custom session\n"
|
||||
printf "Enter your choice [1-10]: "
|
||||
printf "%b\n" "Select the session:"
|
||||
printf "%b\n" "1) GNOME (gnome.desktop)"
|
||||
printf "%b\n" "2) KDE Plasma (plasma.desktop)"
|
||||
printf "%b\n" "3) XFCE (xfce.desktop)"
|
||||
printf "%b\n" "4) LXDE (LXDE.desktop)"
|
||||
printf "%b\n" "5) LXQt (lxqt.desktop)"
|
||||
printf "%b\n" "6) Cinnamon (cinnamon.desktop)"
|
||||
printf "%b\n" "7) MATE (mate.desktop)"
|
||||
printf "%b\n" "8) Openbox (openbox.desktop)"
|
||||
printf "%b\n" "9) i3 (i3.desktop)"
|
||||
printf "%b\n" "10) Custom session"
|
||||
printf "%b\n" "Enter your choice [1-10]: "
|
||||
read -r session_choice
|
||||
|
||||
case "$session_choice" in
|
||||
|
@ -29,62 +29,59 @@ list_sessions() {
|
|||
8) session="openbox.desktop" ;;
|
||||
9) session="i3.desktop" ;;
|
||||
10)
|
||||
printf "Enter custom session name (e.g., mysession.desktop): "
|
||||
printf "%b\n" "Enter custom session name (e.g., mysession.desktop): "
|
||||
read -r session ;;
|
||||
*)
|
||||
printf "Invalid option selected.\n"
|
||||
printf "%b\n" "Invalid option selected."
|
||||
exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to configure LightDM
|
||||
configure_lightdm() {
|
||||
printf "Configuring LightDM for autologin...\n"
|
||||
|
||||
printf "Enter username for LightDM autologin: "
|
||||
printf "%b\n" "Configuring LightDM for autologin..."
|
||||
printf "%b\n" "Enter username for LightDM autologin: "
|
||||
read -r user
|
||||
|
||||
"$ESCALATION_TOOL" "printf '[Seat:*]' > /etc/lightdm/lightdm.conf.d/50-autologin.conf"
|
||||
"$ESCALATION_TOOL" "printf 'autologin-user=$user' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf"
|
||||
"$ESCALATION_TOOL" "printf 'autologin-user-timeout=0' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf"
|
||||
|
||||
printf "LightDM has been configured for autologin.\n"
|
||||
printf "%b\n" "LightDM has been configured for autologin."
|
||||
}
|
||||
|
||||
# Function to remove LightDM autologin
|
||||
remove_lightdm_autologin() {
|
||||
printf "Removing LightDM autologin configuration...\n"
|
||||
printf "%b\n" "Removing LightDM autologin configuration..."
|
||||
"$ESCALATION_TOOL" rm -f /etc/lightdm/lightdm.conf.d/50-autologin.conf
|
||||
printf "LightDM autologin configuration has been removed.\n"
|
||||
printf "%b\n" "LightDM autologin configuration has been removed."
|
||||
}
|
||||
|
||||
# Function to configure GDM
|
||||
configure_gdm() {
|
||||
printf "Configuring GDM for autologin...\n"
|
||||
|
||||
printf "Enter username for GDM autologin: "
|
||||
printf "%b\n" "Configuring GDM for autologin..."
|
||||
printf "%b\n" "Enter username for GDM autologin: "
|
||||
read -r user
|
||||
|
||||
"$ESCALATION_TOOL" "printf '[daemon]' > /etc/gdm/custom.conf"
|
||||
"$ESCALATION_TOOL" "printf 'AutomaticLoginEnable = true' >> /etc/gdm/custom.conf"
|
||||
"$ESCALATION_TOOL" "printf 'AutomaticLogin = $user' >> /etc/gdm/custom.conf"
|
||||
|
||||
printf "GDM has been configured for autologin.\n"
|
||||
printf "%b\n" "GDM has been configured for autologin."
|
||||
}
|
||||
|
||||
# Function to remove GDM autologin
|
||||
remove_gdm_autologin() {
|
||||
printf "Removing GDM autologin configuration...\n"
|
||||
printf "%b\n" "Removing GDM autologin configuration..."
|
||||
"$ESCALATION_TOOL" sed -i '/AutomaticLoginEnable/d' /etc/gdm/custom.conf
|
||||
"$ESCALATION_TOOL" sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf
|
||||
printf "GDM autologin configuration has been removed.\n"
|
||||
printf "%b\n" "GDM autologin configuration has been removed."
|
||||
}
|
||||
|
||||
# Function to configure SDDM
|
||||
configure_sddm() {
|
||||
printf "Configuring SDDM for autologin...\n"
|
||||
|
||||
printf "Enter username for SDDM autologin: "
|
||||
printf "%b\n" "Configuring SDDM for autologin..."
|
||||
printf "%b\n" "Enter username for SDDM autologin: "
|
||||
read -r user
|
||||
list_sessions # Show session options
|
||||
|
||||
|
@ -92,53 +89,52 @@ configure_sddm() {
|
|||
"$ESCALATION_TOOL" "printf 'User=$user' >> /etc/sddm.conf"
|
||||
"$ESCALATION_TOOL" "printf 'Session=$session' >> /etc/sddm.conf"
|
||||
|
||||
printf "SDDM has been configured for autologin.\n"
|
||||
printf "%b\n" "SDDM has been configured for autologin."
|
||||
}
|
||||
|
||||
# Function to remove SDDM autologin
|
||||
remove_sddm_autologin() {
|
||||
printf "Removing SDDM autologin configuration...\n"
|
||||
printf "%b\n" "Removing SDDM autologin configuration..."
|
||||
"$ESCALATION_TOOL" sed -i '/\[Autologin\]/,+2d' /etc/sddm.conf
|
||||
printf "SDDM autologin configuration has been removed.\n"
|
||||
printf "%b\n" "SDDM autologin configuration has been removed."
|
||||
}
|
||||
|
||||
# Function to configure LXDM
|
||||
configure_lxdm() {
|
||||
printf "Configuring LXDM for autologin...\n"
|
||||
|
||||
printf "Enter username for LXDM autologin: "
|
||||
printf "%b\n" "Configuring LXDM for autologin..."
|
||||
printf "%b\n" "Enter username for LXDM autologin: "
|
||||
read -r user
|
||||
list_sessions # Show session options
|
||||
|
||||
"$ESCALATION_TOOL" sed -i "s/^#.*autologin=.*$/autologin=${user}/" /etc/lxdm/lxdm.conf
|
||||
"$ESCALATION_TOOL" sed -i "s|^#.*session=.*$|session=/usr/bin/${session}|; s|^session=.*$|session=/usr/bin/${session}|" /etc/lxdm/lxdm.conf
|
||||
|
||||
printf "LXDM has been configured for autologin.\n"
|
||||
printf "%b\n" "LXDM has been configured for autologin."
|
||||
}
|
||||
|
||||
# Function to remove LXDM autologin
|
||||
remove_lxdm_autologin() {
|
||||
printf "Removing LXDM autologin configuration...\n"
|
||||
printf "%b\n" "Removing LXDM autologin configuration..."
|
||||
"$ESCALATION_TOOL" sed -i "s/^autologin=.*$/#autologin=/" /etc/lxdm/lxdm.conf
|
||||
"$ESCALATION_TOOL" sed -i "s/^session=.*$/#session=/" /etc/lxdm/lxdm.conf
|
||||
printf "LXDM autologin configuration has been removed.\n"
|
||||
printf "%b\n" "LXDM autologin configuration has been removed."
|
||||
}
|
||||
|
||||
# Function to configure or remove autologin based on user choice
|
||||
configure_or_remove_autologin() {
|
||||
printf "Do you want to add or remove autologin?\n"
|
||||
printf "1) Add autologin\n"
|
||||
printf "2) Remove autologin\n"
|
||||
printf "Enter your choice [1-2]: "
|
||||
printf "%b\n" "Do you want to add or remove autologin?"
|
||||
printf "%b\n" "1) Add autologin"
|
||||
printf "%b\n" "2) Remove autologin"
|
||||
printf "%b\n" "Enter your choice [1-2]: "
|
||||
read -r action_choice
|
||||
|
||||
if [ "$action_choice" = "1" ]; then
|
||||
printf "Choose the display manager to configure:\n"
|
||||
printf "1) LightDM\n"
|
||||
printf "2) GDM\n"
|
||||
printf "3) SDDM\n"
|
||||
printf "4) LXDM\n"
|
||||
printf "Enter your choice [1-4]: "
|
||||
printf "%b\n" "Choose the display manager to configure:"
|
||||
printf "%b\n" "1) LightDM"
|
||||
printf "%b\n" "2) GDM"
|
||||
printf "%b\n" "3) SDDM"
|
||||
printf "%b\n" "4) LXDM"
|
||||
printf "%b\n" "Enter your choice [1-4]: "
|
||||
read -r choice
|
||||
|
||||
case "$choice" in
|
||||
|
@ -146,15 +142,15 @@ configure_or_remove_autologin() {
|
|||
2) configure_gdm ;;
|
||||
3) configure_sddm ;;
|
||||
4) configure_lxdm ;;
|
||||
*) printf "Invalid option selected.\n" ;;
|
||||
*) printf "%b\n" "Invalid option selected." ;;
|
||||
esac
|
||||
elif [ "$action_choice" = "2" ]; then
|
||||
printf "Choose the display manager to remove autologin:\n"
|
||||
printf "1) LightDM\n"
|
||||
printf "2) GDM\n"
|
||||
printf "3) SDDM\n"
|
||||
printf "4) LXDM\n"
|
||||
printf "Enter your choice [1-4]: "
|
||||
printf "%b\n" "Choose the display manager to remove autologin:"
|
||||
printf "%b\n" "1) LightDM"
|
||||
printf "%b\n" "2) GDM"
|
||||
printf "%b\n" "3) SDDM"
|
||||
printf "%b\n" "4) LXDM"
|
||||
printf "%b\n" "Enter your choice [1-4]: "
|
||||
read -r choice
|
||||
|
||||
case "$choice" in
|
||||
|
@ -162,14 +158,14 @@ configure_or_remove_autologin() {
|
|||
2) remove_gdm_autologin ;;
|
||||
3) remove_sddm_autologin ;;
|
||||
4) remove_lxdm_autologin ;;
|
||||
*) printf "Invalid option selected.\n" ;;
|
||||
*) printf "%b\n" "Invalid option selected." ;;
|
||||
esac
|
||||
else
|
||||
printf "Invalid choice. Exiting...\n"
|
||||
printf "%b\n" "Invalid choice. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "Action completed. Exiting...\n"
|
||||
printf "%b\n" "Action completed. Exiting..."
|
||||
exit 0
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
# Function to display usage instructions
|
||||
usage() {
|
||||
printf "%b\n" "${RED} Usage: $0 ${RC}"
|
||||
printf "No arguments needed. The script will prompt for ISO path and USB device.\n"
|
||||
printf "%b\n" "No arguments needed. The script will prompt for ISO path and USB device."
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -98,9 +98,9 @@ choose_iso_source() {
|
|||
fetch_iso_urls() {
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Available ISOs for download:${RC}"
|
||||
printf "1) Arch Linux (latest)\n"
|
||||
printf "2) Arch Linux (older versions)\n"
|
||||
printf "3) Debian Linux (latest)\n"
|
||||
printf "%b\n" "1) Arch Linux (latest)"
|
||||
printf "%b\n" "2) Arch Linux (older versions)"
|
||||
printf "%b\n" "3) Debian Linux (latest)"
|
||||
printf "\n"
|
||||
printf "Select the ISO you want to download (1-3): "
|
||||
read -r ISO_OPTION
|
|
@ -22,39 +22,39 @@ if ! command_exists openssl; then
|
|||
*)
|
||||
printf "%b\n" "${RED}Your Linux distribution is not supported by this script.${RC}"
|
||||
printf "%b\n" "${YELLOW}You can try installing OpenSSL manually:${RC}"
|
||||
echo "1. Refer to your distribution's documentation."
|
||||
printf "%b\n" "1. Refer to your distribution's documentation."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
show_menu() {
|
||||
echo "========================================================"
|
||||
echo " File/Directory Encryption/Decryption"
|
||||
echo "========================================================"
|
||||
echo "How to use:-"
|
||||
echo "if you encrypt or decrypt a file include new file name for successful operation"
|
||||
echo "if you encrypt or decrypt a folder include new directory name for successful operation"
|
||||
echo "========================================================"
|
||||
echo "1. Encrypt a file or directory"
|
||||
echo "2. Decrypt a file or directory"
|
||||
echo "3. Exit"
|
||||
echo "========================================================"
|
||||
printf "%b\n" "========================================================"
|
||||
printf "%b\n" " File/Directory Encryption/Decryption"
|
||||
printf "%b\n" "========================================================"
|
||||
printf "%b\n" "How to use:-"
|
||||
printf "%b\n" "if you encrypt or decrypt a file include new file name for successful operation"
|
||||
printf "%b\n" "if you encrypt or decrypt a folder include new directory name for successful operation"
|
||||
printf "%b\n" "========================================================"
|
||||
printf "%b\n" "1. Encrypt a file or directory"
|
||||
printf "%b\n" "2. Decrypt a file or directory"
|
||||
printf "%b\n" "3. Exit"
|
||||
printf "%b\n" "========================================================"
|
||||
}
|
||||
|
||||
# Function to encrypt a file
|
||||
encrypt_file() {
|
||||
echo "Enter the path to the file or directory to encrypt:"
|
||||
printf "%b\n" "Enter the path to the file or directory to encrypt:"
|
||||
read -r INPUT_PATH
|
||||
|
||||
if [ ! -e "$INPUT_PATH" ]; then
|
||||
echo "Path does not exist!"
|
||||
printf "%b\n" "Path does not exist!"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Enter the path for the encrypted file or directory:"
|
||||
printf "%b\n" "Enter the path for the encrypted file or directory:"
|
||||
read -r OUTPUT_PATH
|
||||
|
||||
printf "Enter the encryption password: "
|
||||
printf "%b\n" "Enter the encryption password: "
|
||||
read -r PASSWORD
|
||||
|
||||
if [ -d "$INPUT_PATH" ]; then
|
||||
|
@ -65,41 +65,41 @@ encrypt_file() {
|
|||
mkdir -p "$(dirname "$OUTPUT_FILE")"
|
||||
openssl enc -aes-256-cbc -salt -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Encrypted: $OUTPUT_FILE"
|
||||
printf "%b\n" "Encrypted: $OUTPUT_FILE"
|
||||
else
|
||||
echo "Failed to encrypt: $FILE"
|
||||
printf "%b\n" "Failed to encrypt: $FILE"
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Encrypt a single file
|
||||
if [ -d "$OUTPUT_PATH" ]; then
|
||||
echo "Output path must be a file for single file encryption."
|
||||
printf "%b\n" "Output path must be a file for single file encryption."
|
||||
return
|
||||
fi
|
||||
mkdir -p "$(dirname "$OUTPUT_PATH")"
|
||||
openssl enc -aes-256-cbc -salt -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Encrypted: $OUTPUT_PATH"
|
||||
printf "%b\n" "Encrypted: $OUTPUT_PATH"
|
||||
else
|
||||
echo "Failed to encrypt: $INPUT_PATH"
|
||||
printf "%b\n" "Failed to encrypt: $INPUT_PATH"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to decrypt a file
|
||||
decrypt_file() {
|
||||
echo "Enter the path to the file or directory to decrypt:"
|
||||
printf "%b\n" "Enter the path to the file or directory to decrypt:"
|
||||
read -r INPUT_PATH
|
||||
|
||||
if [ ! -e "$INPUT_PATH" ]; then
|
||||
echo "Path does not exist!"
|
||||
printf "%b\n" "Path does not exist!"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Enter the path for the decrypted file or directory:"
|
||||
printf "%b\n" "Enter the path for the decrypted file or directory:"
|
||||
read -r OUTPUT_PATH
|
||||
|
||||
printf "Enter the decryption password: "
|
||||
printf "%b\n" "Enter the decryption password: "
|
||||
read -r PASSWORD
|
||||
|
||||
if [ -d "$INPUT_PATH" ]; then
|
||||
|
@ -110,23 +110,23 @@ decrypt_file() {
|
|||
mkdir -p "$(dirname "$OUTPUT_FILE")"
|
||||
openssl enc -aes-256-cbc -d -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Decrypted: $OUTPUT_FILE"
|
||||
printf "%b\n" "Decrypted: $OUTPUT_FILE"
|
||||
else
|
||||
echo "Failed to decrypt: $FILE"
|
||||
printf "%b\n" "Failed to decrypt: $FILE"
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Decrypt a single file
|
||||
if [ -d "$OUTPUT_PATH" ]; then
|
||||
echo "Output path must be a file for single file decryption."
|
||||
printf "%b\n" "Output path must be a file for single file decryption."
|
||||
return
|
||||
fi
|
||||
mkdir -p "$(dirname "$OUTPUT_PATH")"
|
||||
openssl enc -aes-256-cbc -d -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Decrypted: $OUTPUT_PATH"
|
||||
printf "%b\n" "Decrypted: $OUTPUT_PATH"
|
||||
else
|
||||
echo "Failed to decrypt: $INPUT_PATH"
|
||||
printf "%b\n" "Failed to decrypt: $INPUT_PATH"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -135,17 +135,17 @@ main(){
|
|||
clear
|
||||
while true; do
|
||||
show_menu
|
||||
echo "Enter your choice:"
|
||||
printf "%b\n" "Enter your choice:"
|
||||
read -r CHOICE
|
||||
|
||||
case $CHOICE in
|
||||
1) encrypt_file ;;
|
||||
2) decrypt_file ;;
|
||||
3) echo "Exiting..."; exit 0 ;;
|
||||
*) echo "Invalid choice. Please try again." ;;
|
||||
3) printf "%b\n" "Exiting..."; exit 0 ;;
|
||||
*) printf "%b\n" "Invalid choice. Please try again." ;;
|
||||
esac
|
||||
|
||||
printf "Press [Enter] to continue..."
|
||||
printf "%b\n" "Press [Enter] to continue..."
|
||||
read -r dummy
|
||||
done
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
# Function to adjust brightness for a selected monitor
|
||||
adjust_monitor_brightness() {
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
. ../utility_functions.sh
|
||||
|
||||
. ../../common-script.sh
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
# Create a script to toggle numlock
|
||||
|
||||
create_file() {
|
||||
printf "Creating script...\n"
|
||||
printf "%b\n" "Creating script..."
|
||||
"$ESCALATION_TOOL" tee "/usr/local/bin/numlock" >/dev/null <<'EOF'
|
||||
#!/bin/bash
|
||||
|
||||
|
@ -23,7 +23,7 @@ EOF
|
|||
|
||||
# Create a systemd service to run the script on boot
|
||||
create_service() {
|
||||
printf "Creating service...\n"
|
||||
printf "%b\n" "Creating service..."
|
||||
"$ESCALATION_TOOL" tee "/etc/systemd/system/numlock.service" >/dev/null <<'EOF'
|
||||
[Unit]
|
||||
Description=numlock
|
||||
|
@ -48,14 +48,14 @@ numlockSetup() {
|
|||
create_service
|
||||
fi
|
||||
|
||||
printf "Do you want to enable Numlock on boot? (y/n): "
|
||||
printf "%b\n" "Do you want to enable Numlock on boot? (y/n): "
|
||||
read -r confirm
|
||||
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
|
||||
"$ESCALATION_TOOL" systemctl enable numlock.service --quiet
|
||||
printf "Numlock will be enabled on boot\n"
|
||||
printf "%b\n" "Numlock will be enabled on boot"
|
||||
else
|
||||
"$ESCALATION_TOOL" systemctl disable numlock.service --quiet
|
||||
printf "Numlock will not be enabled on boot\n"
|
||||
printf "%b\n" "Numlock will not be enabled on boot"
|
||||
fi
|
||||
}
|
||||
|
|
@ -28,25 +28,25 @@ show_menu() {
|
|||
|
||||
# Function to view all services
|
||||
view_all_services() {
|
||||
printf "Listing all services...\n"
|
||||
printf "%b\n" "Listing all services..."
|
||||
"$ESCALATION_TOOL" systemctl list-units --type=service --all --no-legend | awk '{print $1}' | sed 's/\.service//' | more
|
||||
}
|
||||
|
||||
# Function to view enabled services
|
||||
view_enabled_services() {
|
||||
printf "Listing enabled services...\n"
|
||||
printf "%b\n" "Listing enabled services..."
|
||||
"$ESCALATION_TOOL" systemctl list-unit-files --type=service --state=enabled --no-legend | awk '{print $1}' | sed 's/\.service//' | more
|
||||
}
|
||||
|
||||
# Function to view disabled services
|
||||
view_disabled_services() {
|
||||
printf "Listing disabled services...\n"
|
||||
printf "%b\n" "Listing disabled services..."
|
||||
"$ESCALATION_TOOL" systemctl list-unit-files --type=service --state=disabled --no-legend | awk '{print $1}' | sed 's/\.service//' | more
|
||||
}
|
||||
|
||||
# Function to view started services
|
||||
view_started_services() {
|
||||
printf "Listing started services:\n"
|
||||
printf "%b\n" "Listing started services: "
|
||||
"$ESCALATION_TOOL" systemctl list-units --type=service --state=running --no-pager | head -n -6 | awk 'NR>1 {print $1}' | more
|
||||
}
|
||||
|
||||
|
@ -86,9 +86,9 @@ add_service() {
|
|||
printf "\n"
|
||||
printf "[Service]\n"
|
||||
printf "ExecStart=$EXEC_START\n"
|
||||
[ -n "$SERVICE_USER" ] && printf "User=$SERVICE_USER\n"
|
||||
[ -n "$WORKING_DIRECTORY" ] && printf "WorkingDirectory=$WORKING_DIRECTORY\n"
|
||||
[ -n "$RESTART_POLICY" ] && printf "Restart=$RESTART_POLICY\n"
|
||||
[ -n "$SERVICE_USER" ] && printf "%b\n" "User=$SERVICE_USER"
|
||||
[ -n "$WORKING_DIRECTORY" ] && printf "%b\n" "WorkingDirectory=$WORKING_DIRECTORY"
|
||||
[ -n "$RESTART_POLICY" ] && printf "%b\n" "Restart=$RESTART_POLICY"
|
||||
printf "\n"
|
||||
printf "[Install]\n"
|
||||
printf "WantedBy=multi-user.target\n"
|
||||
|
@ -97,7 +97,7 @@ add_service() {
|
|||
# Set permissions and reload systemd
|
||||
"$ESCALATION_TOOL" chmod 644 "$SERVICE_FILE"
|
||||
"$ESCALATION_TOOL" systemctl daemon-reload
|
||||
printf "Service $SERVICE_NAME has been created and is ready to be started.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been created and is ready to be started."
|
||||
|
||||
# Optionally, enable and start the service
|
||||
printf "Do you want to start and enable the service now? (y/n)\n"
|
||||
|
@ -106,9 +106,9 @@ add_service() {
|
|||
if [ "$START_ENABLE" = "y" ]; then
|
||||
"$ESCALATION_TOOL" systemctl start "$SERVICE_NAME"
|
||||
"$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME"
|
||||
printf "Service $SERVICE_NAME has been started and enabled.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been started and enabled."
|
||||
else
|
||||
printf "Service $SERVICE_NAME has been created but not started.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been created but not started."
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -120,29 +120,29 @@ remove_service() {
|
|||
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
|
||||
|
||||
if [ -f "$SERVICE_FILE" ]; then
|
||||
printf "Stopping and disabling the service...\n"
|
||||
printf "%b\n" "Stopping and disabling the service..."
|
||||
"$ESCALATION_TOOL" systemctl stop "$SERVICE_NAME"
|
||||
"$ESCALATION_TOOL" systemctl disable "$SERVICE_NAME"
|
||||
|
||||
printf "Removing the service file...\n"
|
||||
printf "%b\n" "Removing the service file...\n"
|
||||
"$ESCALATION_TOOL" rm -f "$SERVICE_FILE"
|
||||
"$ESCALATION_TOOL" systemctl daemon-reload
|
||||
printf "Service $SERVICE_NAME has been removed.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been removed."
|
||||
else
|
||||
printf "Service $SERVICE_NAME does not exist.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME does not exist."
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to start a service
|
||||
start_service() {
|
||||
view_disabled_services
|
||||
printf "Enter the name of the service to start (e.g., my_service):\n"
|
||||
printf "%b\n" "Enter the name of the service to start (e.g., my_service): "
|
||||
read -r SERVICE_NAME
|
||||
|
||||
if "$ESCALATION_TOOL" systemctl start "$SERVICE_NAME"; then
|
||||
printf "Service $SERVICE_NAME has been started.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been started."
|
||||
else
|
||||
printf "Failed to start service: $SERVICE_NAME.\n"
|
||||
printf "%b\n" "Failed to start service: $SERVICE_NAME."
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -153,9 +153,9 @@ stop_service() {
|
|||
read -r SERVICE_NAME
|
||||
|
||||
if "$ESCALATION_TOOL" systemctl stop "$SERVICE_NAME"; then
|
||||
printf "Service $SERVICE_NAME has been stopped.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been stopped."
|
||||
else
|
||||
printf "Failed to stop service: $SERVICE_NAME.\n"
|
||||
printf "%b\n" "Failed to stop service: $SERVICE_NAME."
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -166,9 +166,9 @@ enable_service() {
|
|||
read -r SERVICE_NAME
|
||||
|
||||
if "$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME"; then
|
||||
printf "Service $SERVICE_NAME has been enabled.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been enabled."
|
||||
else
|
||||
printf "Failed to enable service: $SERVICE_NAME.\n"
|
||||
printf "%b\n" "Failed to enable service: $SERVICE_NAME."
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -179,9 +179,9 @@ disable_service() {
|
|||
read -r SERVICE_NAME
|
||||
|
||||
if "$ESCALATION_TOOL" systemctl disable "$SERVICE_NAME"; then
|
||||
printf "Service $SERVICE_NAME has been enabled.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been enabled."
|
||||
else
|
||||
printf "Failed to enable service: $SERVICE_NAME.\n"
|
||||
printf "%b\n" "Failed to enable service: $SERVICE_NAME."
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ create_service_from_external() {
|
|||
SERVICE_FILE="$SCRIPT_DIR/$SERVICE_NAME.service"
|
||||
|
||||
if [ ! -f "$SERVICE_FILE" ]; then
|
||||
printf "Service file $SERVICE_FILE does not exist.\n"
|
||||
printf "%b\n" "Service file $SERVICE_FILE does not exist."
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -230,7 +230,7 @@ create_service_from_external() {
|
|||
# Set permissions and reload systemd
|
||||
"$ESCALATION_TOOL" chmod 644 "$SYSTEMD_SERVICE_FILE"
|
||||
"$ESCALATION_TOOL" systemctl daemon-reload
|
||||
printf "Service $SERVICE_NAME has been created and is ready to be started.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been created and is ready to be started."
|
||||
|
||||
# Optionally, enable and start the service
|
||||
printf "Do you want to start and enable the service now? (y/n)\n"
|
||||
|
@ -239,9 +239,9 @@ create_service_from_external() {
|
|||
if [ "$START_ENABLE" = "y" ]; then
|
||||
"$ESCALATION_TOOL" systemctl start "$SERVICE_NAME"
|
||||
"$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME"
|
||||
printf "Service $SERVICE_NAME has been started and enabled.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been started and enabled."
|
||||
else
|
||||
printf "Service $SERVICE_NAME has been created but not started.\n"
|
||||
printf "%b\n" "Service $SERVICE_NAME has been created but not started."
|
||||
fi
|
||||
}
|
||||
|
|
@ -23,12 +23,14 @@ ask_for_host_details() {
|
|||
read -r host
|
||||
printf "%b\n" "Enter Remote User: "
|
||||
read -r user
|
||||
printf "%b\n" "Host $host_alias" >> ~/.ssh/config
|
||||
printf "%b\n" " HostName $host" >> ~/.ssh/config
|
||||
printf "%b\n" " User $user" >> ~/.ssh/config
|
||||
printf "%b\n" " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
|
||||
printf "%b\n" " StrictHostKeyChecking no" >> ~/.ssh/config
|
||||
printf "%b\n" " UserKnownHostsFile=/dev/null" >> ~/.ssh/config
|
||||
{
|
||||
printf "%b\n" "Host $host_alias"
|
||||
printf "%b\n" " HostName $host"
|
||||
printf "%b\n" " User $user"
|
||||
printf "%b\n" " IdentityFile ~/.ssh/id_rsa"
|
||||
printf "%b\n" " StrictHostKeyChecking no"
|
||||
printf "%b\n" " UserKnownHostsFile=/dev/null"
|
||||
} >> ~/.ssh/config
|
||||
printf "%b\n" "Host $host_alias added successfully."
|
||||
}
|
||||
|
47
core/tabs/utils/user-account-manager/add_to_group.sh
Executable file
47
core/tabs/utils/user-account-manager/add_to_group.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
|
||||
. ../utility_functions.sh
|
||||
|
||||
addToGroup() {
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Add to group${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
printf "%b" "${YELLOW}Enter the username: ${RC}"
|
||||
read -r username
|
||||
user_groups=$(groups "$username" | cut -d: -f2 | sort | tr '\n' ' ')
|
||||
|
||||
printf "%b\n" "${YELLOW}Groups user $username is in:${RC} $user_groups"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
available_groups=$(cut -d: -f1 /etc/group | sort | tr '\n' ' ')
|
||||
|
||||
printf "%b\n" "${YELLOW}Available groups:${RC} $available_groups"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
printf "%b" "${YELLOW}Enter the groups you want to add user $username to (space-separated): ${RC}"
|
||||
read -r groups
|
||||
|
||||
checkEmpty "$groups" || exit 1
|
||||
if ! checkGroups "$groups" "$available_groups"; then
|
||||
printf "%b\n" "${RED}One or more groups are not available.${RC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
groups_to_add=$(echo "$groups" | tr ' ' ',')
|
||||
|
||||
printf "%b" "${YELLOW}Are you sure you want to add user $username to $groups_to_add? [Y/n]: ${RC}"
|
||||
read -r confirm
|
||||
confirmAction || exit 1
|
||||
|
||||
"$ESCALATION_TOOL" usermod -aG "$groups_to_add" "$username"
|
||||
|
||||
printf "%b\n" "${GREEN}User successfully added to the $groups_to_add${RC}"
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
checkGroups
|
||||
addToGroup
|
38
core/tabs/utils/user-account-manager/add_user.sh
Executable file
38
core/tabs/utils/user-account-manager/add_user.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
|
||||
. ../utility_functions.sh
|
||||
|
||||
createUser() {
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Create a new user${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
printf "%b" "${YELLOW}Enter the username: ${RC}"
|
||||
read -r username
|
||||
|
||||
if ! echo "$username" | grep '^[a-zA-Z]*$' > /dev/null; then
|
||||
printf "%b\n" "${RED}Username must only contain letters and cannot contain spaces.${RC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "%b" "${YELLOW}Enter the password: ${RC}"
|
||||
read -r password
|
||||
printf "%b" "${YELLOW}Enter the password again: ${RC}"
|
||||
read -r password_confirmation
|
||||
|
||||
if [ "$password" != "$password_confirmation" ]; then
|
||||
printf "%b\n" "${RED}Passwords do not match${RC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$ESCALATION_TOOL" useradd -m "$username" -g users -s /bin/bash
|
||||
echo "$username:$password" | "$ESCALATION_TOOL" chpasswd
|
||||
|
||||
printf "%b\n" "${GREEN}User $username created successfully${RC}"
|
||||
printf "%b\n" "${GREEN}To add additional groups use Add User To Groups${RC}"
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
createUser
|
33
core/tabs/utils/user-account-manager/change_password.sh
Executable file
33
core/tabs/utils/user-account-manager/change_password.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
|
||||
. ../utility_functions.sh
|
||||
|
||||
changePassword() {
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Change password${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
printf "%b" "${YELLOW}Enter the username: ${RC}"
|
||||
read -r username
|
||||
|
||||
if id "$username" > /dev/null 2>&1; then
|
||||
printf "%b" "${YELLOW}Enter new password: ${RC}"
|
||||
read -r password
|
||||
|
||||
printf "%b" "${YELLOW}Are you sure you want to change password for ""$username""? [Y/n]: ${RC}"
|
||||
read -r confirm
|
||||
confirmAction || exit 1
|
||||
|
||||
echo "$username:$password" | "$ESCALATION_TOOL" chpasswd
|
||||
printf "%b\n" "${GREEN}Password changed successfully${RC}"
|
||||
else
|
||||
printf "%b\n" "${RED}User $username does not exist.${RC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
changePassword
|
30
core/tabs/utils/user-account-manager/delete_user.sh
Executable file
30
core/tabs/utils/user-account-manager/delete_user.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
|
||||
. ../utility_functions.sh
|
||||
|
||||
deleteUser() {
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Delete a user${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
printf "%b" "${YELLOW}Enter the username: ${RC}"
|
||||
read -r username
|
||||
|
||||
if id "$username" > /dev/null 2>&1; then
|
||||
printf "%b" "${YELLOW}Are you sure you want to delete user ""$username""? [Y/n]: ${RC}"
|
||||
read -r confirm
|
||||
confirmAction || exit 1
|
||||
|
||||
$ESCALATION_TOOL userdel --remove "$username" 2>/dev/null
|
||||
printf "%b\n" "${GREEN}User $username deleted successfully${RC}"
|
||||
else
|
||||
printf "%b\n" "${RED}User $username does not exist.${RC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
deleteUser
|
47
core/tabs/utils/user-account-manager/remove_from_group.sh
Executable file
47
core/tabs/utils/user-account-manager/remove_from_group.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
|
||||
. ../utility_functions.sh
|
||||
|
||||
removeFromGroup() {
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Remove from group${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
printf "%b" "${YELLOW}Enter the username: ${RC}"
|
||||
read -r username
|
||||
|
||||
if ! id "$username" > /dev/null 2>&1; then
|
||||
printf "%b\n" "${RED}User $username does not exist.${RC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
user_groups=$(groups "$username" | cut -d: -f2 | sort | tr '\n' ' ')
|
||||
|
||||
printf "%b\n" "${YELLOW}Groups user $username is in:${RC} $user_groups"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
printf "%b" "${YELLOW}Enter the groups you want to remove user $username from (space-separated): ${RC} "
|
||||
read -r groups
|
||||
|
||||
checkEmpty "$groups" || exit 1
|
||||
if ! checkGroups "$groups" "$user_groups"; then
|
||||
printf "%b\n" "${RED}One or more specified groups do not exist.${RC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
groups_to_remove=$(echo "$groups" | tr ' ' ',')
|
||||
|
||||
printf "%b" "${YELLOW}Are you sure you want to remove user $username from $groups_to_remove? [Y/n]: ${RC}"
|
||||
read -r confirm
|
||||
confirmAction || exit 1
|
||||
|
||||
$ESCALATION_TOOL usermod -rG $groups_to_remove "$username"
|
||||
|
||||
printf "%b\n" "${GREEN}User successfully removed from $groups_to_remove${RC}"
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
removeFromGroup
|
|
@ -84,6 +84,31 @@ confirm_action() {
|
|||
fi
|
||||
}
|
||||
|
||||
checkEmpty() {
|
||||
if [ -z "$1" ]; then
|
||||
printf "%b\n" "${RED}Empty value is not allowed${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkGroups() {
|
||||
groups="$1"
|
||||
available_groups="$2"
|
||||
for group in $groups; do
|
||||
if ! echo "$available_groups" | grep -q -w "$group"; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
confirmAction() {
|
||||
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
|
||||
printf "%b\n" "${RED}Cancelled operation...${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
||||
setup_xrandr
|
|
@ -1,37 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
. ./utility_functions.sh
|
||||
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Add to group${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
username=$(promptUsername "" "non-root") || exit 1
|
||||
user_groups=$(groups "$username" | cut -d: -f2 | sort | tr '\n' ' ')
|
||||
|
||||
printf "%b\n" "${YELLOW}Groups user $username is in:${RC} $user_groups"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
available_groups=$(cut -d: -f1 /etc/group | sort | tr '\n' ' ')
|
||||
|
||||
printf "%b\n" "${YELLOW}Available groups:${RC} $available_groups"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
printf "%b\n" "${YELLOW}Enter the groups you want to add user $username to (space-separated):${RC} "
|
||||
read -r groups
|
||||
|
||||
checkEmpty "$groups" || exit 1
|
||||
checkGroupAvailabe "$groups" "$available_groups" || exit 1
|
||||
|
||||
groups_to_add=$(echo "$groups" | tr ' ' ',')
|
||||
|
||||
printf "Are you sure you want to add user $username to $groups_to_add? [Y/N]: "
|
||||
read -r confirm
|
||||
confirmAction || exit 1
|
||||
|
||||
$ESCALATION_TOOL usermod -aG $groups_to_add "$username"
|
||||
|
||||
printf "%b\n" "${GREEN}User successfully added to the $groups_to_add${RC}"
|
||||
|
||||
checkEnv
|
|
@ -1,26 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
. ./utility_functions.sh
|
||||
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Create a new user${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
username=$(promptUsername "add" "non-root") || exit 1
|
||||
|
||||
# Check if username is valid
|
||||
if ! echo "$username" | grep '^[a-z][-a-z0-9_]*$' > /dev/null; then
|
||||
printf "%b\n" "${RED}Username must only contain letters, numbers, hyphens, and underscores. It cannot start with a number or contain spaces.${RC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
password=$(promptPassword) || exit 1
|
||||
|
||||
$ESCALATION_TOOL useradd -m "$username" -g users -s /bin/bash
|
||||
echo "$username:$password" | "$ESCALATION_TOOL" chpasswd
|
||||
|
||||
printf "%b\n" "${GREEN}User $username created successfully${RC}"
|
||||
printf "%b\n" "${GREEN}To add additional groups use Add User To Groups${RC}"
|
||||
|
||||
checkEnv
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
. ./utility_functions.sh
|
||||
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Change password${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
username=$(promptUsername "" "root") || exit 1
|
||||
password=$(promptPassword) || exit 1
|
||||
|
||||
printf "Are you sure you want to change password for $username? [Y/N]: "
|
||||
read -r confirm
|
||||
confirmAction || exit 1
|
||||
|
||||
echo "$username:$password" | "$ESCALATION_TOOL" chpasswd
|
||||
printf "%b\n" "${GREEN}Password changed successfully${RC}"
|
||||
|
||||
checkEnv
|
|
@ -1,27 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
. ./utility_functions.sh
|
||||
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Delete a user${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
username=$(promptUsername "" "non-root") || exit 1
|
||||
|
||||
# Check if current user
|
||||
if [ "$username" = "$USER" ]; then
|
||||
printf "%b\n" "${RED}Cannot delete the current user${RC}"
|
||||
printf "%b\n" "${RED}Press [Enter] to continue...${RC}"
|
||||
read -r dummy
|
||||
return
|
||||
fi
|
||||
|
||||
printf "Are you sure you want to delete user $username? [Y/N]: "
|
||||
read -r confirm
|
||||
confirmAction || exit 1
|
||||
|
||||
$ESCALATION_TOOL userdel --remove "$username" 2>/dev/null
|
||||
printf "%b\n" "${GREEN}User $username deleted successfully${RC}"
|
||||
|
||||
checkEnv
|
|
@ -1,32 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
. ./utility_functions.sh
|
||||
|
||||
clear
|
||||
printf "%b\n" "${YELLOW}Remove from group${RC}"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
username=$(promptUsername "" "non-root") || exit 1
|
||||
user_groups=$(groups "$username" | cut -d: -f2 | sort | tr '\n' ' ')
|
||||
|
||||
printf "%b\n" "${YELLOW}Groups user $username is in:${RC} $user_groups"
|
||||
printf "%b\n" "${YELLOW}=================${RC}"
|
||||
|
||||
printf "%b\n" "${YELLOW}Enter the groups you want to remove user $username from (space-separated):${RC} "
|
||||
read -r groups
|
||||
|
||||
checkEmpty "$groups" || exit 1
|
||||
checkGroupAvailabe "$groups" "$user_groups" || exit 1
|
||||
|
||||
groups_to_remove=$(echo "$groups" | tr ' ' ',')
|
||||
|
||||
printf "Are you sure you want to remove user $username from $groups_to_remove? [Y/N]: "
|
||||
read -r confirm
|
||||
confirmAction || exit 1
|
||||
|
||||
$ESCALATION_TOOL usermod -rG $groups_to_remove "$username"
|
||||
|
||||
printf "%b\n" "${GREEN}User successfully removed from $groups_to_remove${RC}"
|
||||
|
||||
checkEnv
|
|
@ -1,103 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
|
||||
# Prompt for username
|
||||
promptUsername() {
|
||||
printf "Enter the username: "
|
||||
read -r username
|
||||
|
||||
checkEmpty "$username";
|
||||
|
||||
if [ "$1" = "add" ]; then
|
||||
checkUserExistence "$username" "$1"
|
||||
else
|
||||
checkUserExistence "$username" "$1"
|
||||
checkReservedUsername "$username" "$2"
|
||||
fi
|
||||
echo "$username"
|
||||
}
|
||||
|
||||
|
||||
# Prompt for password
|
||||
promptPassword() {
|
||||
stty -echo
|
||||
printf "Enter the password (PASSWORD IS HIDDEN): "
|
||||
read -r password1
|
||||
echo >&2
|
||||
printf "Re-enter the password (PASSWORD IS HIDDEN): "
|
||||
read -r password2
|
||||
echo >&2
|
||||
stty echo
|
||||
|
||||
if ! checkEmpty "$password1"; then
|
||||
promptPassword
|
||||
fi
|
||||
|
||||
if [ "$password1" != "$password2" ]; then
|
||||
printf "%b\n" "${RED}Passwords do not match${RC}" >&2
|
||||
promptPassword
|
||||
else
|
||||
echo $password1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if input is empty
|
||||
checkEmpty() {
|
||||
if [ -z "$1" ]; then
|
||||
printf "%b\n" "${RED}Empty value is not allowed${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if user exists
|
||||
checkUserExistence() {
|
||||
if [ "$2" = "add" ]; then
|
||||
if id "$1" > /dev/null 2>&1; then
|
||||
printf "%b\n" "${RED}User already exists${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if ! id "$1" > /dev/null 2>&1; then
|
||||
printf "%b\n" "${RED}User does not exist${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if user is reserved
|
||||
checkReservedUsername() {
|
||||
uid=$(id -u "$1")
|
||||
if [ "$2" = "root" ]; then
|
||||
if [ "$uid" -le 999 ] && [ "$uid" -ne 0 ]; then
|
||||
printf "%b\n" "${RED}Cannot modify system users${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ "$(id -u "$1")" -le 999 ]; then
|
||||
printf "%b\n" "${RED}Cannot modify system users${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if user is reserved
|
||||
confirmAction() {
|
||||
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
|
||||
printf "%b\n" "${RED}Cancelled operation...${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if group is available
|
||||
checkGroupAvailabe() {
|
||||
for group in $1; do
|
||||
if ! echo "$2" | grep -wq "$group"; then
|
||||
printf "%b\n" "${RED}Group $group not avaiable${RC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
checkEnv
|
||||
checkEscalationTool
|
|
@ -1,8 +1,18 @@
|
|||
[package]
|
||||
name = "linutil_tui"
|
||||
description = "Chris Titus Tech's Linux Toolbox - Linutil is a distro-agnostic toolbox designed to simplify everyday Linux tasks."
|
||||
documentation = "https://christitustech.github.io/linutil"
|
||||
readme = "../README.md"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
license.workspace = true
|
||||
repository = "https://github.com/ChrisTitusTech/linutil/tree/main/tui"
|
||||
version.workspace = true
|
||||
include = [
|
||||
"src/*.rs",
|
||||
"Cargo.toml",
|
||||
"build.rs",
|
||||
]
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.16", features = ["derive"] }
|
||||
|
@ -13,7 +23,7 @@ portable-pty = "0.8.1"
|
|||
ratatui = "0.28.1"
|
||||
tui-term = "0.1.12"
|
||||
unicode-width = "0.1.13"
|
||||
linutil_core = { path = "../core" }
|
||||
linutil_core = { path = "../core", version = "24.9.19" }
|
||||
|
||||
[build-dependencies]
|
||||
chrono = "0.4.33"
|
||||
|
|
Loading…
Reference in New Issue
Block a user