mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-24 14:11:55 +00:00
Compare commits
1 Commits
7a6a5a3099
...
77fbb66d0c
Author | SHA1 | Date | |
---|---|---|---|
|
77fbb66d0c |
72
Cargo.lock
generated
72
Cargo.lock
generated
|
@ -242,15 +242,6 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deranged"
|
|
||||||
version = "0.3.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
|
|
||||||
dependencies = [
|
|
||||||
"powerfmt",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "downcast-rs"
|
name = "downcast-rs"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
|
@ -421,9 +412,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.161"
|
version = "0.2.158"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
|
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linutil_core"
|
name = "linutil_core"
|
||||||
|
@ -451,7 +442,6 @@ dependencies = [
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"temp-dir",
|
"temp-dir",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
"time",
|
|
||||||
"tree-sitter-bash",
|
"tree-sitter-bash",
|
||||||
"tree-sitter-highlight",
|
"tree-sitter-highlight",
|
||||||
"tui-term",
|
"tui-term",
|
||||||
|
@ -548,21 +538,6 @@ dependencies = [
|
||||||
"minimal-lexical",
|
"minimal-lexical",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-conv"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num_threads"
|
|
||||||
version = "0.1.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.19.0"
|
version = "1.19.0"
|
||||||
|
@ -631,12 +606,6 @@ dependencies = [
|
||||||
"winreg",
|
"winreg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "powerfmt"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.20"
|
version = "0.2.20"
|
||||||
|
@ -755,9 +724,9 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.38.38"
|
version = "0.38.37"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a"
|
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"errno",
|
"errno",
|
||||||
|
@ -1022,39 +991,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time"
|
|
||||||
version = "0.3.36"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
|
|
||||||
dependencies = [
|
|
||||||
"deranged",
|
|
||||||
"itoa",
|
|
||||||
"libc",
|
|
||||||
"num-conv",
|
|
||||||
"num_threads",
|
|
||||||
"powerfmt",
|
|
||||||
"serde",
|
|
||||||
"time-core",
|
|
||||||
"time-macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time-core"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time-macros"
|
|
||||||
version = "0.2.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf"
|
|
||||||
dependencies = [
|
|
||||||
"num-conv",
|
|
||||||
"time-core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.8.19"
|
version = "0.8.19"
|
||||||
|
|
|
@ -5,8 +5,3 @@ name = "Firewall Baselines (CTT)"
|
||||||
description = "Developed to ease iptables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall. This command installs UFW and configures UFW based on CTT's recommended rules. For more information visit: https://christitus.com/linux-security-mistakes"
|
description = "Developed to ease iptables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall. This command installs UFW and configures UFW based on CTT's recommended rules. For more information visit: https://christitus.com/linux-security-mistakes"
|
||||||
script = "firewall-baselines.sh"
|
script = "firewall-baselines.sh"
|
||||||
task_list = "I SS"
|
task_list = "I SS"
|
||||||
|
|
||||||
[[data.preconditions]]
|
|
||||||
matches = false
|
|
||||||
data = "command_exists"
|
|
||||||
values = [ "firewalld" ]
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ multimedia() {
|
||||||
if [ -e /etc/yum.repos.d/rpmfusion-free.repo ] && [ -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then
|
if [ -e /etc/yum.repos.d/rpmfusion-free.repo ] && [ -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then
|
||||||
printf "%b\n" "${YELLOW}Installing Multimedia Codecs...${RC}"
|
printf "%b\n" "${YELLOW}Installing Multimedia Codecs...${RC}"
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" swap ffmpeg-free ffmpeg --allowerasing -y
|
"$ESCALATION_TOOL" "$PACKAGER" swap ffmpeg-free ffmpeg --allowerasing -y
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" update @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin -y
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" update @sound-and-video -y
|
||||||
printf "%b\n" "${GREEN}Multimedia Codecs Installed...${RC}"
|
printf "%b\n" "${GREEN}Multimedia Codecs Installed...${RC}"
|
||||||
else
|
else
|
||||||
printf "%b\n" "${RED}RPM Fusion repositories not found. Please set up RPM Fusion first!${RC}"
|
printf "%b\n" "${RED}RPM Fusion repositories not found. Please set up RPM Fusion first!${RC}"
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../common-script.sh
|
||||||
|
|
||||||
installDepend() {
|
installDepend() {
|
||||||
DEPENDENCIES='wine dbus git'
|
# Check for dependencies
|
||||||
|
DEPENDENCIES='wine dbus'
|
||||||
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
|
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
pacman)
|
pacman)
|
||||||
|
@ -29,13 +28,10 @@ installDepend() {
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
DISTRO_DEPS="libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386 wine64 wine32"
|
DISTRO_DEPS="libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386 wine64 wine32"
|
||||||
|
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
"$ESCALATION_TOOL" dpkg --add-architecture i386
|
"$ESCALATION_TOOL" dpkg --add-architecture i386
|
||||||
|
|
||||||
if [ "$DTYPE" != "pop" ]; then
|
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y software-properties-common
|
"$ESCALATION_TOOL" "$PACKAGER" install -y software-properties-common
|
||||||
"$ESCALATION_TOOL" apt-add-repository contrib -y
|
"$ESCALATION_TOOL" apt-add-repository contrib -y
|
||||||
fi
|
|
||||||
|
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS
|
||||||
;;
|
;;
|
||||||
|
@ -76,7 +72,7 @@ installAdditionalDepend() {
|
||||||
curl -sSLo "lutris_${version_no_v}_all.deb" "https://github.com/lutris/lutris/releases/download/${version}/lutris_${version_no_v}_all.deb"
|
curl -sSLo "lutris_${version_no_v}_all.deb" "https://github.com/lutris/lutris/releases/download/${version}/lutris_${version_no_v}_all.deb"
|
||||||
|
|
||||||
printf "%b\n" "${YELLOW}Installing Lutris...${RC}"
|
printf "%b\n" "${YELLOW}Installing Lutris...${RC}"
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y ./lutris_"${version_no_v}"_all.deb
|
"$ESCALATION_TOOL" "$PACKAGER" install ./lutris_"${version_no_v}"_all.deb
|
||||||
|
|
||||||
rm lutris_"${version_no_v}"_all.deb
|
rm lutris_"${version_no_v}"_all.deb
|
||||||
|
|
||||||
|
@ -95,6 +91,7 @@ installAdditionalDepend() {
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y $DISTRO_DEPS
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DISTRO_DEPS
|
||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
|
# Flatpak
|
||||||
DISTRO_DEPS='lutris'
|
DISTRO_DEPS='lutris'
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -n install $DISTRO_DEPS
|
"$ESCALATION_TOOL" "$PACKAGER" -n install $DISTRO_DEPS
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -22,7 +22,7 @@ cleanup_system() {
|
||||||
;;
|
;;
|
||||||
pacman)
|
pacman)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
|
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null || true
|
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1
|
||||||
;;
|
;;
|
||||||
apk)
|
apk)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" cache clean
|
"$ESCALATION_TOOL" "$PACKAGER" cache clean
|
||||||
|
|
|
@ -5,85 +5,83 @@
|
||||||
fastUpdate() {
|
fastUpdate() {
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
pacman)
|
pacman)
|
||||||
"$AUR_HELPER" -S --needed --noconfirm rate-mirrors-bin
|
|
||||||
|
$AUR_HELPER -S --needed --noconfirm rate-mirrors-bin
|
||||||
|
|
||||||
printf "%b\n" "${YELLOW}Generating a new list of mirrors using rate-mirrors. This process may take a few seconds...${RC}"
|
printf "%b\n" "${YELLOW}Generating a new list of mirrors using rate-mirrors. This process may take a few seconds...${RC}"
|
||||||
|
|
||||||
if [ -s "/etc/pacman.d/mirrorlist" ]; then
|
if [ -s /etc/pacman.d/mirrorlist ]; then
|
||||||
"$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
|
"$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail
|
# If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail
|
||||||
dtype_local="$DTYPE"
|
dtype_local=${DTYPE}
|
||||||
if [ "$dtype_local" = "unknown" ]; then
|
if [ "${DTYPE}" = "unknown" ]; then
|
||||||
dtype_local="arch"
|
dtype_local="arch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! "$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root "$dtype_local" > /dev/null || [ ! -s "/etc/pacman.d/mirrorlist" ]; then
|
"$ESCALATION_TOOL" rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local}
|
||||||
|
if [ $? -ne 0 ] || [ ! -s /etc/pacman.d/mirrorlist ]; then
|
||||||
printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}"
|
printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}"
|
||||||
"$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist
|
"$ESCALATION_TOOL" cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
if [ "$PACKAGER" = "apt-get" ]; then
|
"$ESCALATION_TOOL" apt-get update
|
||||||
printf "%b\n" "${YELLOW}Installing nala for faster updates.${RC}"
|
if ! command_exists nala; then
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
"$ESCALATION_TOOL" apt-get install -y nala || { printf "%b\n" "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; }
|
||||||
if "$ESCALATION_TOOL" "$PACKAGER" install -y nala; then
|
|
||||||
PACKAGER="nala";
|
|
||||||
printf "%b\n" "${CYAN}Using $PACKAGER as package manager${RC}"
|
|
||||||
else
|
|
||||||
printf "%b\n" "${RED}Nala installation failed.${RC}"
|
|
||||||
printf "%b\n" "${YELLOW}Falling back to apt-get.${RC}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PACKAGER" = "nala" ]; then
|
if [ "$PACKAGER" = "nala" ]; then
|
||||||
if [ -f "/etc/apt/sources.list.d/nala-sources.list" ]; then
|
"$ESCALATION_TOOL" cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||||
"$ESCALATION_TOOL" cp /etc/apt/sources.list.d/nala-sources.list /etc/apt/sources.list.d/nala-sources.list.bak
|
"$ESCALATION_TOOL" nala update
|
||||||
fi
|
PACKAGER="nala"
|
||||||
if ! "$ESCALATION_TOOL" nala fetch --auto -y || [ ! -s "/etc/apt/sources.list.d/nala-sources.list" ]; then
|
|
||||||
printf "%b\n" "${RED}Nala fetch failed, restoring backup.${RC}"
|
|
||||||
"$ESCALATION_TOOL" cp /etc/apt/sources.list.d/nala-sources.list.bak /etc/apt/sources.list.d/nala-sources.list
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" upgrade -y
|
||||||
;;
|
;;
|
||||||
dnf)
|
dnf)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update -y
|
"$ESCALATION_TOOL" "$PACKAGER" update -y
|
||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" ref
|
"$ESCALATION_TOOL" "$PACKAGER" ref
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup
|
||||||
;;
|
;;
|
||||||
apk)
|
apk)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
|
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSystem() {
|
updateSystem() {
|
||||||
printf "%b\n" "${YELLOW}Updating system packages.${RC}"
|
printf "%b\n" "${GREEN}Updating system${RC}"
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" upgrade -y
|
"$ESCALATION_TOOL" "$PACKAGER" upgrade -y
|
||||||
;;
|
;;
|
||||||
dnf)
|
dnf)
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" update -y
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" upgrade -y
|
"$ESCALATION_TOOL" "$PACKAGER" upgrade -y
|
||||||
;;
|
;;
|
||||||
pacman)
|
pacman)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -Sy --noconfirm --needed archlinux-keyring
|
"$ESCALATION_TOOL" "$PACKAGER" -Sy --noconfirm --needed archlinux-keyring
|
||||||
"$AUR_HELPER" -Su --noconfirm
|
"$ESCALATION_TOOL" "$PACKAGER" -Su --noconfirm
|
||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" ref
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup
|
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive dup
|
||||||
;;
|
;;
|
||||||
apk)
|
apk)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" upgrade
|
"$ESCALATION_TOOL" "$PACKAGER" upgrade
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
|
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -91,8 +89,18 @@ updateSystem() {
|
||||||
|
|
||||||
updateFlatpaks() {
|
updateFlatpaks() {
|
||||||
if command_exists flatpak; then
|
if command_exists flatpak; then
|
||||||
printf "%b\n" "${YELLOW}Updating flatpak packages.${RC}"
|
printf "%b\n" "${YELLOW}Updating installed Flathub apps...${RC}"
|
||||||
flatpak update -y
|
installed_apps=$(flatpak list --app --columns=application)
|
||||||
|
|
||||||
|
if [ -z "$installed_apps" ]; then
|
||||||
|
printf "%b\n" "${RED}No Flathub apps are installed.${RC}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
for app in $installed_apps; do
|
||||||
|
printf "%b\n" "${YELLOW}Updating $app...${RC}"
|
||||||
|
flatpak update -y "$app"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ configureAutoCpufreq() {
|
||||||
|
|
||||||
if command_exists auto-cpufreq; then
|
if command_exists auto-cpufreq; then
|
||||||
# Check if the system has a battery to determine if it's a laptop
|
# Check if the system has a battery to determine if it's a laptop
|
||||||
if ls /sys/class/power_supply/BAT* >/dev/null 2>&1; then
|
if [ -d /sys/class/power_supply/BAT0 ]; then
|
||||||
printf "%b\n" "${GREEN}System detected as laptop. Updating auto-cpufreq for laptop...${RC}"
|
printf "%b\n" "${GREEN}System detected as laptop. Updating auto-cpufreq for laptop...${RC}"
|
||||||
"$ESCALATION_TOOL" auto-cpufreq --force powersave
|
"$ESCALATION_TOOL" auto-cpufreq --force powersave
|
||||||
else
|
else
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
### Q4 2024
|
### Q4 2024
|
||||||
- [x] Finish the foundation of the project's CLI
|
- [x] Finish the foundation of the project's CLI
|
||||||
- [x] Implement CLI arguments and configuration support
|
- [x] Implement CLI arguments and configuration support
|
||||||
- [x] Add an option for logging script executions
|
- [ ] Add an option for logging script executions
|
||||||
|
|
||||||
### Q1 2025
|
### Q1 2025
|
||||||
- [ ] GUI Brainstorming and Planning
|
- [ ] GUI Brainstorming and Planning
|
||||||
|
|
|
@ -20,7 +20,6 @@ portable-pty = "0.8.1"
|
||||||
ratatui = "0.29.0"
|
ratatui = "0.29.0"
|
||||||
tui-term = "0.2.0"
|
tui-term = "0.2.0"
|
||||||
temp-dir = "0.1.14"
|
temp-dir = "0.1.14"
|
||||||
time = { version = "0.3.36", features = ["local-offset", "macros", "formatting"] }
|
|
||||||
unicode-width = "0.2.0"
|
unicode-width = "0.2.0"
|
||||||
rand = { version = "0.8.5", optional = true }
|
rand = { version = "0.8.5", optional = true }
|
||||||
linutil_core = { path = "../core", version = "24.9.28" }
|
linutil_core = { path = "../core", version = "24.9.28" }
|
||||||
|
|
|
@ -17,11 +17,11 @@ use std::{
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
thread::JoinHandle,
|
thread::JoinHandle,
|
||||||
};
|
};
|
||||||
use time::{macros::format_description, OffsetDateTime};
|
|
||||||
use tui_term::{
|
use tui_term::{
|
||||||
vt100::{self, Screen},
|
vt100::{self, Screen},
|
||||||
widget::PseudoTerminal,
|
widget::PseudoTerminal,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct RunningCommand {
|
pub struct RunningCommand {
|
||||||
/// A buffer to save all the command output (accumulates, until the command exits)
|
/// A buffer to save all the command output (accumulates, until the command exits)
|
||||||
buffer: Arc<Mutex<Vec<u8>>>,
|
buffer: Arc<Mutex<Vec<u8>>>,
|
||||||
|
@ -37,7 +37,6 @@ pub struct RunningCommand {
|
||||||
writer: Box<dyn Write + Send>,
|
writer: Box<dyn Write + Send>,
|
||||||
/// Only set after the process has ended
|
/// Only set after the process has ended
|
||||||
status: Option<ExitStatus>,
|
status: Option<ExitStatus>,
|
||||||
log_path: Option<String>,
|
|
||||||
scroll_offset: usize,
|
scroll_offset: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,20 +79,10 @@ impl FloatContent for RunningCommand {
|
||||||
.style(Style::default()),
|
.style(Style::default()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut block = Block::default()
|
Block::default()
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_set(ratatui::symbols::border::ROUNDED)
|
.border_set(ratatui::symbols::border::ROUNDED)
|
||||||
.title_top(title_line.centered());
|
.title_top(title_line.centered())
|
||||||
|
|
||||||
if let Some(log_path) = &self.log_path {
|
|
||||||
block =
|
|
||||||
block.title_bottom(Line::from(format!(" Log saved: {} ", log_path)).centered());
|
|
||||||
} else {
|
|
||||||
block =
|
|
||||||
block.title_bottom(Line::from(" Press 'l' to save command log ").centered());
|
|
||||||
}
|
|
||||||
|
|
||||||
block
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process the buffer and create the pseudo-terminal widget
|
// Process the buffer and create the pseudo-terminal widget
|
||||||
|
@ -122,11 +111,6 @@ impl FloatContent for RunningCommand {
|
||||||
KeyCode::PageDown => {
|
KeyCode::PageDown => {
|
||||||
self.scroll_offset = self.scroll_offset.saturating_sub(10);
|
self.scroll_offset = self.scroll_offset.saturating_sub(10);
|
||||||
}
|
}
|
||||||
KeyCode::Char('l') if self.is_finished() => {
|
|
||||||
if let Ok(log_path) = self.save_log() {
|
|
||||||
self.log_path = Some(log_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Pass other key events to the terminal
|
// Pass other key events to the terminal
|
||||||
_ => self.handle_passthrough_key_event(key),
|
_ => self.handle_passthrough_key_event(key),
|
||||||
}
|
}
|
||||||
|
@ -150,7 +134,6 @@ impl FloatContent for RunningCommand {
|
||||||
Shortcut::new("Close window", ["Enter", "q"]),
|
Shortcut::new("Close window", ["Enter", "q"]),
|
||||||
Shortcut::new("Scroll up", ["Page up"]),
|
Shortcut::new("Scroll up", ["Page up"]),
|
||||||
Shortcut::new("Scroll down", ["Page down"]),
|
Shortcut::new("Scroll down", ["Page down"]),
|
||||||
Shortcut::new("Save log", ["l"]),
|
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -254,7 +237,6 @@ impl RunningCommand {
|
||||||
pty_master: pair.master,
|
pty_master: pair.master,
|
||||||
writer,
|
writer,
|
||||||
status: None,
|
status: None,
|
||||||
log_path: None,
|
|
||||||
scroll_offset: 0,
|
scroll_offset: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,24 +284,6 @@ impl RunningCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_log(&self) -> std::io::Result<String> {
|
|
||||||
let mut log_path = std::env::temp_dir();
|
|
||||||
let date_format = format_description!("[year]-[month]-[day]-[hour]-[minute]-[second]");
|
|
||||||
log_path.push(format!(
|
|
||||||
"linutil_log_{}.log",
|
|
||||||
OffsetDateTime::now_local()
|
|
||||||
.unwrap_or(OffsetDateTime::now_utc())
|
|
||||||
.format(&date_format)
|
|
||||||
.unwrap()
|
|
||||||
));
|
|
||||||
|
|
||||||
let mut file = std::fs::File::create(&log_path)?;
|
|
||||||
let buffer = self.buffer.lock().unwrap();
|
|
||||||
file.write_all(&buffer)?;
|
|
||||||
|
|
||||||
Ok(log_path.to_string_lossy().into_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert the KeyEvent to pty key codes, and send them to the virtual terminal
|
/// Convert the KeyEvent to pty key codes, and send them to the virtual terminal
|
||||||
fn handle_passthrough_key_event(&mut self, key: &KeyEvent) {
|
fn handle_passthrough_key_event(&mut self, key: &KeyEvent) {
|
||||||
let input_bytes = match key.code {
|
let input_bytes = match key.code {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user