Refactor scripts to be POSIX compliant
This commit is contained in:
26
debian.sh
26
debian.sh
@@ -1,51 +1,51 @@
|
||||
#! /bin/bash
|
||||
#! /bin/sh
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
PURPLE='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
trap "echo -e '${RED}debian.sh interrupted.${NC}'; exit 1" SIGINT SIGTERM
|
||||
trap 'printf "${RED}debian.sh interrupted.${NC}"; exit 1' INT TERM
|
||||
|
||||
PS3="Debian Sources: "
|
||||
options=("Stable" "Testing")
|
||||
echo "Debian Sources:"
|
||||
echo "1) Stable"
|
||||
echo "2) Testing"
|
||||
printf "Enter your choice: "
|
||||
|
||||
select opt in "${options[@]}"; do
|
||||
while read -r REPLY; do
|
||||
case $REPLY in
|
||||
1)
|
||||
echo -e "${CYAN}Using Stable sources.${NC}"
|
||||
echo "${CYAN}Using Stable sources.${NC}"
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bckp
|
||||
sudo cp stable-sources.list /etc/apt/sources.list
|
||||
break
|
||||
;;
|
||||
2)
|
||||
echo -e "${CYAN}Using Testing sources.${NC}"
|
||||
echo "${CYAN}Using Testing sources.${NC}"
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bckp
|
||||
sudo cp testing-sources.list /etc/apt/sources.list
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option."
|
||||
printf "Enter your choice: "
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
./scripts/update
|
||||
|
||||
echo -e "${YELLOW}Installing GNOME...${NC}"
|
||||
echo "${YELLOW}Installing GNOME...${NC}"
|
||||
sudo apt install gnome-core flatpak gnome-software-plugin-flatpak
|
||||
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
# Enable Network Manager
|
||||
echo -e "${YELLOW}Enabling Network Manager...${NC}"
|
||||
echo "${YELLOW}Enabling Network Manager...${NC}"
|
||||
sudo mv /etc/network/interfaces /etc/network/interfaces.bckp
|
||||
sudo systemctl restart networking
|
||||
sudo service NetworkManager restart
|
||||
|
||||
# Remove Firefox (Epiphany installed instead)
|
||||
echo -e "${YELLOW}Removing Firefox...${NC}"
|
||||
echo "${YELLOW}Removing Firefox...${NC}"
|
||||
sudo apt purge firefox-esr
|
||||
|
||||
95
install.sh
95
install.sh
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#! /bin/sh
|
||||
|
||||
# -r : Only reload configurations
|
||||
|
||||
@@ -6,37 +6,36 @@
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
PURPLE='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
trap "echo -e '${RED}install.sh interrupted.${NC}'; exit 1" SIGINT SIGTERM
|
||||
trap 'printf "${RED}install.sh interrupted.${NC}"; exit 1' INT TERM
|
||||
|
||||
install_gnome_extension() {
|
||||
local uuid="$1"
|
||||
uuid="$1"
|
||||
|
||||
if [ -z "$uuid" ]; then
|
||||
printf "${RED}Usage: install_gnome_extension <extension-uuid>${NC}\n"
|
||||
echo "${RED}Usage: install_gnome_extension <extension-uuid>${NC}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! gnome-extensions list | grep -qw "$uuid"; then
|
||||
printf "${GREEN}Sent install request for %s.${NC}\n" "$uuid"
|
||||
echo "${GREEN}Sent install request for $uuid.${NC}"
|
||||
gdbus call --session --dest org.gnome.Shell.Extensions \
|
||||
--object-path /org/gnome/Shell/Extensions \
|
||||
--method org.gnome.Shell.Extensions.InstallRemoteExtension \
|
||||
"$uuid" >/dev/null 2>&1
|
||||
return 0
|
||||
elif gnome-extensions list --updates | grep -qw "$uuid"; then
|
||||
printf "${GREEN}Sent update request for %s.${NC}\n" "$uuid"
|
||||
echo "${GREEN}Sent update request for $uuid.${NC}"
|
||||
gdbus call --session --dest org.gnome.Shell.Extensions \
|
||||
--object-path /org/gnome/Shell/Extensions \
|
||||
--method org.gnome.Shell.Extensions.InstallRemoteExtension \
|
||||
"$uuid" >/dev/null 2>&1
|
||||
return 0
|
||||
else
|
||||
printf "${GREEN}GNOME Extension %s is already installed.${NC}\n" "$uuid"
|
||||
echo "${GREEN}GNOME Extension $uuid is already installed.${NC}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
@@ -51,37 +50,34 @@ for arg in "$@"; do
|
||||
done
|
||||
|
||||
# Clone Dotfiles if not already present
|
||||
cd "$HOME/dotfiles"
|
||||
cd "$HOME/dotfiles" || exit
|
||||
if [ "$(pwd)" != "$HOME/dotfiles" ]; then
|
||||
printf "${YELLOW}Cloning dotfiles repository...${NC}\n"
|
||||
echo "${YELLOW}Cloning dotfiles repository...${NC}"
|
||||
sudo apt update
|
||||
sudo apt install -y git
|
||||
git clone https://github.com/TrudeEH/dotfiles --depth 1
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Error cloning dotfiles repository. Exiting...${NC}\n"
|
||||
if ! git clone https://github.com/TrudeEH/dotfiles --depth 1; then
|
||||
echo "${RED}Error cloning dotfiles repository. Exiting...${NC}"
|
||||
exit 2
|
||||
fi
|
||||
cd dotfiles || exit
|
||||
printf "${GREEN}dotfiles repository cloned successfully.${NC}\n"
|
||||
echo "${GREEN}dotfiles repository cloned successfully.${NC}"
|
||||
else
|
||||
printf "${YELLOW}Updating dotfiles repository...${NC}\n"
|
||||
echo "${YELLOW}Updating dotfiles repository...${NC}"
|
||||
pull_output=$(git pull)
|
||||
printf "%s\n" "$pull_output"
|
||||
echo "%s" "$pull_output"
|
||||
if ! echo "$pull_output" | grep -q "Already up to date."; then
|
||||
printf "${YELLOW}Changes detected. Re-running script...${NC}\n"
|
||||
echo "${YELLOW}Changes detected. Re-running script...${NC}"
|
||||
exec "$0" "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$HOME/dotfiles/logs"
|
||||
|
||||
printf "${CYAN}\n"
|
||||
printf "####################\n"
|
||||
printf "#"
|
||||
printf "${PURPLE} Trude's Dotfiles${CYAN} #\n"
|
||||
printf "####################\n"
|
||||
echo "${CYAN}####################"
|
||||
echo "#${PURPLE} Trude's Dotfiles${CYAN} #"
|
||||
echo "####################"
|
||||
fetch
|
||||
printf "\n"
|
||||
echo
|
||||
|
||||
# Install Programs
|
||||
if [ "$reload" = false ]; then
|
||||
@@ -89,27 +85,27 @@ if [ "$reload" = false ]; then
|
||||
fi
|
||||
|
||||
# Copy files
|
||||
printf "${YELLOW}Installing Dotfiles...${NC}\n"
|
||||
echo "${YELLOW}Installing Dotfiles...${NC}"
|
||||
cp -r "$HOME/dotfiles/home/." "$HOME"
|
||||
|
||||
# Copy scripts
|
||||
printf "${YELLOW}Installing Scripts...${NC}\n"
|
||||
echo "${YELLOW}Installing Scripts...${NC}"
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
cp -r "$HOME/dotfiles/scripts/." "$HOME/.local/bin/"
|
||||
|
||||
# Install fonts
|
||||
printf "${YELLOW}Installing fonts...${NC}\n"
|
||||
echo "${YELLOW}Installing fonts...${NC}"
|
||||
mkdir -p "$HOME/.local/share/fonts"
|
||||
cp -rf "$HOME/dotfiles/fonts/"* "$HOME/.local/share/fonts/"
|
||||
fc-cache -fv "$HOME/.local/share/fonts" >"$HOME/dotfiles/logs/font_install.log"
|
||||
|
||||
# UFW Firewall
|
||||
if [ "$reload" = false ]; then
|
||||
printf "${YELLOW}Setting up UFW...${NC}\n"
|
||||
echo "${YELLOW}Setting up UFW...${NC}"
|
||||
sudo ufw default deny incoming
|
||||
sudo ufw default allow outgoing
|
||||
if systemctl is-active --quiet sshd; then
|
||||
printf "${YELLOW}SSH Server detected; Enabling SSH rule...${NC}\n"
|
||||
echo "${YELLOW}SSH Server detected; Enabling SSH rule...${NC}"
|
||||
sudo ufw limit 22/tcp
|
||||
fi
|
||||
sudo ufw enable
|
||||
@@ -129,50 +125,47 @@ if [ "$USER" = "trude" ]; then
|
||||
|
||||
# Clone password-store
|
||||
if [ ! -f "$HOME/.ssh/id_ed25519" ] || [ ! -f "$HOME/.ssh/id_ed25519.pub" ]; then
|
||||
printf "${RED}ED25519 key not found in ${CYAN}$HOME/.ssh/id_ed25519. ${RED}Please add your ED25519 key pair for password-store.${NC}\n"
|
||||
echo "${RED}ED25519 key not found in ${CYAN}$HOME/.ssh/id_ed25519. ${RED}Please add your ED25519 key pair for password-store.${NC}"
|
||||
elif ! gpg --list-keys "ehtrude@gmail.com" >/dev/null 2>&1; then
|
||||
printf "${RED}GPG key for ehtrude@gmail.com not found. Please import the key for password-store.${NC}\n"
|
||||
echo "${RED}GPG key for ehtrude@gmail.com not found. Please import the key for password-store.${NC}"
|
||||
else
|
||||
if [ ! -d "$HOME/.password-store" ]; then
|
||||
printf "${YELLOW}Cloning password-store...${NC}\n"
|
||||
echo "${YELLOW}Cloning password-store...${NC}"
|
||||
chmod 700 ~/.ssh
|
||||
chmod 600 ~/.ssh/*
|
||||
git clone git@github.com:TrudeEH/password-store.git "$HOME/.password-store"
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Error cloning password-store.${NC}\n"
|
||||
if ! git clone git@github.com:TrudeEH/password-store.git "$HOME/.password-store"; then
|
||||
echo "${RED}Error cloning password-store.${NC}"
|
||||
else
|
||||
printf "${GREEN}Password-store cloned successfully.${NC}\n"
|
||||
echo "${GREEN}Password-store cloned successfully.${NC}"
|
||||
fi
|
||||
else
|
||||
printf "${CYAN}Password-store already present.${NC}\n"
|
||||
echo "${CYAN}Password-store already present.${NC}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Security Scan
|
||||
if [ "$reload" = false ] && [ ! -f "$HOME/dotfiles/logs/lynis_scan.log" ]; then
|
||||
printf "${YELLOW}Running Lynis Security Scan...${NC}\n"
|
||||
sudo lynis audit system | tee "$HOME/dotfiles/logs/lynis_scan.log"
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Error running Lynis.${NC}\n"
|
||||
echo "${YELLOW}Running Lynis Security Scan...${NC}"
|
||||
if ! sudo lynis audit system | tee "$HOME/dotfiles/logs/lynis_scan.log"; then
|
||||
echo "${RED}Error running Lynis.${NC}"
|
||||
else
|
||||
printf "${GREEN}Lynis scan completed.${NC}\n"
|
||||
echo "${GREEN}Lynis scan completed.${NC}"
|
||||
fi
|
||||
else
|
||||
printf "${CYAN}Previous Lynis scan detected, read the log @ $HOME/dotfiles/logs/lynis_scan.log.${NC}\n"
|
||||
echo "${CYAN}Previous Lynis scan detected, read the log @ $HOME/dotfiles/logs/lynis_scan.log.${NC}"
|
||||
fi
|
||||
|
||||
# Set up GNOME Desktop
|
||||
if [[ "$XDG_CURRENT_DESKTOP" == *"GNOME"* ]]; then
|
||||
printf "${YELLOW}Installing GNOME Extensions...${NC}\n"
|
||||
case "$XDG_CURRENT_DESKTOP" in
|
||||
*GNOME*)
|
||||
echo "${YELLOW}Installing GNOME Extensions...${NC}"
|
||||
install_gnome_extension "appindicatorsupport@rgcjonas.gmail.com"
|
||||
install_gnome_extension "caffeine@patapon.info"
|
||||
|
||||
printf "${YELLOW}Loading Dconf settings...${NC}\n"
|
||||
dconf load / <"$HOME/dotfiles/dconf-settings.ini"
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Error loading Dconf settings.${NC}\n"
|
||||
else
|
||||
printf "${GREEN}Dconf settings loaded successfully.${NC}\n"
|
||||
fi
|
||||
echo "${YELLOW}Loading Dconf settings...${NC}"
|
||||
if ! dconf load / <"$HOME/dotfiles/dconf-settings.ini"; then
|
||||
echo "${RED}Error loading Dconf settings.${NC}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /bin/bash
|
||||
#! /bin/sh
|
||||
|
||||
RED="\e[31m"
|
||||
GREEN="\e[32m"
|
||||
@@ -8,13 +8,13 @@ CYAN="\e[36m"
|
||||
BOLD="\e[1m"
|
||||
NC="\e[0m"
|
||||
|
||||
BATTERY_INFO=$(upower -i $(upower -e | grep 'BAT'))
|
||||
BATTERY_INFO=$(upower -i "$(upower -e | grep 'BAT')")
|
||||
BATTERY_PERCENT=$(echo "$BATTERY_INFO" | grep -oP 'percentage:\s+\K\d+')
|
||||
BATTERY_STATUS=$(echo "$BATTERY_INFO" | grep -oP 'state:\s+\K\w+')
|
||||
CHARGE_CYCLES=$(echo "$BATTERY_INFO" | grep -oP 'cycle-count:\s+\K\d+')
|
||||
WARNING_LEVEL=$(echo "$BATTERY_INFO" | grep -oP 'warning-level:\s+\K\w+')
|
||||
|
||||
if [ "$BATTERY_STATUS" == "charging" ] || [ "$BATTERY_STATUS" == "pending" ]; then
|
||||
if [ "$BATTERY_STATUS" = "charging" ] || [ "$BATTERY_STATUS" = "pending" ]; then
|
||||
COLOR=$CYAN
|
||||
elif [ "$BATTERY_PERCENT" -ge 80 ]; then
|
||||
COLOR=$GREEN
|
||||
@@ -24,10 +24,10 @@ else
|
||||
COLOR=$RED
|
||||
fi
|
||||
|
||||
echo -e "${BOLD}Battery: ${COLOR}$BATTERY_PERCENT% ($BATTERY_STATUS)${NC}"
|
||||
echo "${BOLD}Battery: ${COLOR}$BATTERY_PERCENT% ($BATTERY_STATUS)${NC}"
|
||||
if [ -n "$CHARGE_CYCLES" ]; then
|
||||
echo -e "${BOLD}Charge Cycles: ${MAGENTA}$CHARGE_CYCLES${NC}"
|
||||
echo "${BOLD}Charge Cycles: ${MAGENTA}$CHARGE_CYCLES${NC}"
|
||||
fi
|
||||
if [ "$WARNING_LEVEL" != "none" ]; then
|
||||
echo -e "${BOLD}Warning Level: ${RED}$WARNING_LEVEL${NC}"
|
||||
echo "${BOLD}Warning Level: ${RED}$WARNING_LEVEL${NC}"
|
||||
fi
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
#! /bin/bash
|
||||
#! /bin/sh
|
||||
|
||||
YELLOW="\e[33m"
|
||||
NC="\e[0m"
|
||||
|
||||
echo -e "\n${YELLOW}Downloading APT dependencies...${NC}\n"
|
||||
echo "\n${YELLOW}Downloading APT dependencies...${NC}\n"
|
||||
sudo apt install build-essential git -y
|
||||
sudo apt build-dep linux -y
|
||||
|
||||
echo -e "\n${YELLOW}Downloading kernel source...${NC}\n"
|
||||
mkdir linux-parent && cd linux-parent
|
||||
echo "\n${YELLOW}Downloading kernel source...${NC}\n"
|
||||
mkdir linux-parent && cd linux-parent || exit 1
|
||||
git clone --depth 1 https://github.com/torvalds/linux
|
||||
cd linux
|
||||
cd linux || exit 1
|
||||
|
||||
cp /boot/config-$(uname -r) .config # Copy current kernel config
|
||||
cp /boot/config-"$(uname -r)" .config # Copy current kernel config
|
||||
make nconfig # Edit the current kernel configuration
|
||||
diff /boot/config-$(uname -r) .config # Check your changes
|
||||
diff /boot/config-"$(uname -r)" .config # Check your changes
|
||||
|
||||
# Do not include debugging symbols. Alternatively, use `strip` to remove them. (these configs are working as of 6.14)
|
||||
scripts/config --undefine GDB_SCRIPTS
|
||||
@@ -26,14 +26,14 @@ scripts/config --set-val DEBUG_INFO_NONE y
|
||||
scripts/config --set-val DEBUG_INFO_DWARF5 n
|
||||
scripts/config --disable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
|
||||
|
||||
echo -e "\n${YELLOW}Compiling the kernel...${NC}\n"
|
||||
make -j$(nproc) deb-pkg LOCALVERSION=-custom
|
||||
echo "\n${YELLOW}Compiling the kernel...${NC}\n"
|
||||
make -j"$(nproc)" deb-pkg LOCALVERSION=-custom
|
||||
|
||||
echo -e "\n${YELLOW}Installing the generated dpkg packages...${NC}\n"
|
||||
echo "\n${YELLOW}Installing the generated dpkg packages...${NC}\n"
|
||||
sudo dpkg -i ../linux-headers*-custom*.deb
|
||||
sudo dpkg -i ../linux-image*-custom*.deb
|
||||
|
||||
echo -e "\n${YELLOW}Cleaning up...${NC}\n"
|
||||
echo "\n${YELLOW}Cleaning up...${NC}\n"
|
||||
cd ../..
|
||||
rm -rf linux-parent
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#! /bin/bash
|
||||
|
||||
for i in {0..255}; do
|
||||
printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
|
||||
if ((i == 15)) || ((i > 15)) && (((i - 15) % 6 == 0)); then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /bin/bash
|
||||
#! /bin/sh
|
||||
|
||||
extract() {
|
||||
if [ -f "$1" ]; then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# Basic System Information Script
|
||||
|
||||
RED="\e[31m"
|
||||
@@ -10,50 +10,52 @@ BOLD="\e[1m"
|
||||
NC="\e[0m"
|
||||
|
||||
# User and host info
|
||||
echo -e "${BOLD}${MAGENTA}${USER}@$(hostname)${NC}"
|
||||
echo "${BOLD}${MAGENTA}${USER}@$(hostname)${NC}"
|
||||
echo "---------"
|
||||
|
||||
# OS and architecture
|
||||
OS=$(grep '^PRETTY_NAME=' /etc/os-release | cut -d= -f2 | tr -d '"')
|
||||
ARCH=$(uname -m)
|
||||
echo -e "${CYAN}OS:${NC} $OS $ARCH"
|
||||
echo "${CYAN}OS:${NC} $OS $ARCH"
|
||||
|
||||
# Host Model
|
||||
HOST_MODEL=$(cat /sys/class/dmi/id/product_name 2>/dev/null)
|
||||
HOST_VERSION=$(cat /sys/class/dmi/id/product_version 2>/dev/null)
|
||||
echo -e "${CYAN}Host:${NC} ${HOST_VERSION} (${HOST_MODEL})"
|
||||
echo "${CYAN}Host:${NC} ${HOST_VERSION} (${HOST_MODEL})"
|
||||
|
||||
# Kernel version
|
||||
echo -e "${CYAN}Kernel:${NC} Linux $(uname -r)"
|
||||
echo "${CYAN}Kernel:${NC} Linux $(uname -r)"
|
||||
|
||||
# Uptime
|
||||
UPTIME=$(uptime -p | sed 's/up //')
|
||||
echo -e "${CYAN}Uptime:${NC} $UPTIME"
|
||||
echo "${CYAN}Uptime:${NC} $UPTIME"
|
||||
|
||||
# Package counts: dpkg and flatpak
|
||||
PKG_COUNT=$(dpkg-query -f '${binary:Package}\n' -W 2>/dev/null | wc -l)
|
||||
FLAT_COUNT=$(flatpak list 2>/dev/null | wc -l)
|
||||
echo -e "${CYAN}Packages:${NC} ${PKG_COUNT} (dpkg), ${FLAT_COUNT} (flatpak)"
|
||||
echo "${CYAN}Packages:${NC} ${PKG_COUNT} (dpkg), ${FLAT_COUNT} (flatpak)"
|
||||
|
||||
# Shell and version
|
||||
BASH_VER=$(bash --version | head -n1 | awk '{print $4}' | cut -d'(' -f1)
|
||||
echo -e "${CYAN}Shell:${NC} bash ${BASH_VER}"
|
||||
echo "${CYAN}Shell:${NC} bash ${BASH_VER}"
|
||||
|
||||
# Desktop Environment
|
||||
DE=${XDG_CURRENT_DESKTOP:-"Unknown"}
|
||||
echo -e "${CYAN}DE:${NC} $DE"
|
||||
echo "${CYAN}DE:${NC} $DE"
|
||||
|
||||
# CPU model from /proc/cpuinfo
|
||||
CPU=$(awk -F: '/model name/ {print $2; exit}' /proc/cpuinfo | sed 's/^[ \t]*//')
|
||||
echo -e "${CYAN}CPU:${NC} $CPU"
|
||||
echo "${CYAN}CPU:${NC} $CPU"
|
||||
|
||||
# GPU info
|
||||
GPU=$(lspci | grep -i 'vga\|3d' | head -n1 | cut -d: -f3 | sed 's/^[ \t]*//')
|
||||
echo -e "${CYAN}GPU:${NC} $GPU"
|
||||
echo "${CYAN}GPU:${NC} $GPU"
|
||||
|
||||
# Memory usage
|
||||
mem_info=$(free | awk '/Mem:/ {print $2, $3}')
|
||||
read total used <<<"$mem_info"
|
||||
set -- $mem_info
|
||||
total=$1
|
||||
used=$2
|
||||
percent=$(awk "BEGIN {printf \"%.0f\", ($used/$total)*100}")
|
||||
|
||||
if [ "$percent" -le 60 ]; then
|
||||
@@ -66,7 +68,7 @@ fi
|
||||
|
||||
mem_total=$(free -h | awk '/Mem:/ {print $2}')
|
||||
mem_used=$(free -h | awk '/Mem:/ {print $3}')
|
||||
echo -e "${CYAN}Memory:${NC} ${mem_used} / ${mem_total} (${percent_color}${percent}%${NC})"
|
||||
echo "${CYAN}Memory:${NC} ${mem_used} / ${mem_total} (${percent_color}${percent}%${NC})"
|
||||
|
||||
# Swap usage
|
||||
swap_used=$(free -h | awk '/Swap/ {print $3}')
|
||||
@@ -81,13 +83,13 @@ else
|
||||
swap_perc_color=$RED
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}Swap:${NC} ${swap_used} / ${swap_total} (${swap_perc_color}${swap_perc}%${NC})"
|
||||
echo "${CYAN}Swap:${NC} ${swap_used} / ${swap_total} (${swap_perc_color}${swap_perc}%${NC})"
|
||||
|
||||
# Root disk usage
|
||||
root_line=$(df -h / | awk 'NR==2')
|
||||
root_used=$(echo $root_line | awk '{print $3}')
|
||||
root_total=$(echo $root_line | awk '{print $2}')
|
||||
root_percent=$(echo $root_line | awk '{gsub("%","",$5); print $5}')
|
||||
root_used=$(echo "$root_line" | awk '{print $3}')
|
||||
root_total=$(echo "$root_line" | awk '{print $2}')
|
||||
root_percent=$(echo "$root_line" | awk '{gsub("%","",$5); print $5}')
|
||||
if [ "$root_percent" -le 60 ]; then
|
||||
root_color=$GREEN
|
||||
elif [ "$root_percent" -le 80 ]; then
|
||||
@@ -95,14 +97,14 @@ elif [ "$root_percent" -le 80 ]; then
|
||||
else
|
||||
root_color=$RED
|
||||
fi
|
||||
echo -e "${CYAN}Disk (/):${NC} ${root_used} / ${root_total} (${root_color}${root_percent}%${NC})"
|
||||
echo "${CYAN}Disk (/):${NC} ${root_used} / ${root_total} (${root_color}${root_percent}%${NC})"
|
||||
|
||||
# /home disk usage
|
||||
home_line=$(df -h /home 2>/dev/null | awk 'NR==2')
|
||||
if [ -n "$home_line" ]; then
|
||||
home_used=$(echo $home_line | awk '{print $3}')
|
||||
home_total=$(echo $home_line | awk '{print $2}')
|
||||
home_percent=$(echo $home_line | awk '{gsub("%","",$5); print $5}')
|
||||
home_used=$(echo "$home_line" | awk '{print $3}')
|
||||
home_total=$(echo "$home_line" | awk '{print $2}')
|
||||
home_percent=$(echo "$home_line" | awk '{gsub("%","",$5); print $5}')
|
||||
if [ "$home_percent" -le 60 ]; then
|
||||
home_color=$GREEN
|
||||
elif [ "$home_percent" -le 80 ]; then
|
||||
@@ -110,7 +112,7 @@ if [ -n "$home_line" ]; then
|
||||
else
|
||||
home_color=$RED
|
||||
fi
|
||||
echo -e "${CYAN}Disk (/home):${NC} ${home_used} / ${home_total} (${home_color}${home_percent}%${NC})"
|
||||
echo "${CYAN}Disk (/home):${NC} ${home_used} / ${home_total} (${home_color}${home_percent}%${NC})"
|
||||
fi
|
||||
|
||||
# Determine the primary network interface used for internet access
|
||||
@@ -118,11 +120,11 @@ PRIMARY_IFACE=$(ip route get 8.8.8.8 2>/dev/null | awk '{print $5; exit}')
|
||||
|
||||
if [ -n "$PRIMARY_IFACE" ]; then
|
||||
LOCAL_IP=$(ip addr show "$PRIMARY_IFACE" | awk '/inet / {print $2}' | cut -d'/' -f1)
|
||||
echo -e "${CYAN}Local IP ($PRIMARY_IFACE):${NC} ${LOCAL_IP}"
|
||||
echo "${CYAN}Local IP ($PRIMARY_IFACE):${NC} ${LOCAL_IP}"
|
||||
else
|
||||
echo -e "${RED}Local IP:${NC} Unable to determine primary network interface."
|
||||
echo "${RED}Local IP:${NC} Unable to determine primary network interface."
|
||||
fi
|
||||
|
||||
# Current locale setting
|
||||
LOCALE=$(locale | awk -F= '/^LANG=/{print $2; exit}')
|
||||
echo -e "${CYAN}Locale:${NC} $LOCALE"
|
||||
echo "${CYAN}Locale:${NC} $LOCALE"
|
||||
|
||||
10
scripts/mem
10
scripts/mem
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
RED="\e[31m"
|
||||
GREEN="\e[32m"
|
||||
@@ -6,12 +6,14 @@ YELLOW="\e[33m"
|
||||
NC="\e[0m"
|
||||
|
||||
mem_info=$(free | awk '/Mem:/ {print $2, $3}')
|
||||
read total used <<<"$mem_info"
|
||||
set -- $mem_info
|
||||
total=$1
|
||||
used=$2
|
||||
percent=$(awk "BEGIN {printf \"%.0f\", ($used/$total)*100}")
|
||||
|
||||
mem_total=$(free -h | awk '/Mem:/ {print $2}')
|
||||
mem_used=$(free -h | awk '/Mem:/ {print $3}')
|
||||
if [[ -t 1 ]]; then
|
||||
if [ -t 1 ]; then
|
||||
if [ "$percent" -le 60 ]; then
|
||||
percent_color=$GREEN
|
||||
elif [ "$percent" -le 80 ]; then
|
||||
@@ -19,7 +21,7 @@ if [[ -t 1 ]]; then
|
||||
else
|
||||
percent_color=$RED
|
||||
fi
|
||||
echo -e " ${mem_used} / ${mem_total} (${percent_color}${percent}%${NC})"
|
||||
echo " ${mem_used} / ${mem_total} (${percent_color}${percent}%${NC})"
|
||||
else
|
||||
echo "${mem_used} ${mem_total} ${percent}"
|
||||
fi
|
||||
|
||||
22
scripts/mon
22
scripts/mon
@@ -1,4 +1,4 @@
|
||||
#! /bin/bash
|
||||
#! /bin/sh
|
||||
|
||||
RED="\e[31m"
|
||||
GREEN="\e[32m"
|
||||
@@ -6,11 +6,11 @@ YELLOW="\e[33m"
|
||||
CYAN="\e[36m"
|
||||
NC="\e[0m"
|
||||
|
||||
trap "echo -e '${CYAN}System Monitor interrupted.${NC}'; exit 1" SIGINT SIGTERM
|
||||
trap "echo '${CYAN}System Monitor interrupted.${NC}'; exit 1" INT TERM
|
||||
|
||||
for i in {0..3}; do
|
||||
echo
|
||||
done
|
||||
echo
|
||||
echo
|
||||
|
||||
# Cache in tmpfs to improve speed and reduce SSD load
|
||||
cache=/tmp/cpu-script-cache
|
||||
@@ -48,7 +48,9 @@ while true; do
|
||||
|
||||
# MEMORY
|
||||
mem_info=$(free | awk '/Mem:/ {print $2, $3}')
|
||||
read total used <<<"$mem_info"
|
||||
set -- $mem_info
|
||||
total=$1
|
||||
used=$2
|
||||
percent=$(awk "BEGIN {printf \"%.0f\", ($used/$total)*100}")
|
||||
|
||||
mem_total=$(free -h | awk '/Mem:/ {print $2}')
|
||||
@@ -62,11 +64,11 @@ while true; do
|
||||
mem_color=$RED
|
||||
fi
|
||||
|
||||
echo -ne "\033[4A"
|
||||
echo -e "============================="
|
||||
echo -e " ${cpu_color}${usage}%${NC} "
|
||||
echo -e " ${mem_used} / ${mem_total} (${mem_color}${percent}%${NC}) "
|
||||
echo -e "============================="
|
||||
printf "\033[4A"
|
||||
echo "============================="
|
||||
echo " ${cpu_color}${usage}%${NC} "
|
||||
echo " ${mem_used} / ${mem_total} (${mem_color}${percent}%${NC}) "
|
||||
echo "============================="
|
||||
|
||||
echo "$cpu_stats" >"$cache"
|
||||
sleep 2
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
oneline() {
|
||||
# Print a command's output as a single line only.
|
||||
# Example usage: for f in 'first line' 'second line' '3rd line'; do echo "$f"; sleep 1; done | oneline
|
||||
local ws
|
||||
while IFS= read -r line; do
|
||||
if ((${#line} >= $COLUMNS)); then
|
||||
# Moving cursor back to the front of the line so user input doesn't force wrapping
|
||||
printf '\r%s\r' "${line:0:$COLUMNS}"
|
||||
else
|
||||
ws=$(($COLUMNS - ${#line}))
|
||||
# by writing each line twice, we move the cursor back to position
|
||||
# thus: LF, content, whitespace, LF, content
|
||||
printf '\r%s%*s\r%s' "$line" "$ws" " " "$line"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/'
|
||||
paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) |
|
||||
column -s "$(printf '\t')" -t |
|
||||
sed 's/\(.\)..$/.\1°C/'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /bin/bash
|
||||
#! /bin/sh
|
||||
|
||||
YELLOW="\e[33m"
|
||||
NC="\e[0m"
|
||||
|
||||
@@ -18,7 +18,7 @@ split() {
|
||||
|
||||
vol="$(printf "%.0f" "$(split "$vol" ".")")"
|
||||
|
||||
case 1 in
|
||||
case $1 in
|
||||
$((vol >= 70))) icon=" " ;;
|
||||
$((vol >= 30))) icon=" " ;;
|
||||
$((vol >= 1))) icon=" " ;;
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
# Debian Testing
|
||||
deb http://deb.debian.org/debian/ trixie main non-free contrib
|
||||
deb-src http://deb.debian.org/debian/ trixie main non-free contrib
|
||||
deb http://security.debian.org/debian-security trixie-security main
|
||||
deb http://deb.debian.org/debian/ trixie main contrib non-free non-free-firmware
|
||||
deb-src http://deb.debian.org/debian/ trixie main contrib non-free non-free-firmware
|
||||
|
||||
deb http://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
|
||||
deb-src http://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
|
||||
|
||||
deb https://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
|
||||
deb-src https://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
|
||||
|
||||
Reference in New Issue
Block a user