44 Commits

Author SHA1 Message Date
Jordan 5739796801 Update README.md v2.0.2 2023-11-13 19:16:40 +01:00
Jordan e6d63a99c9 Update pvekclean.sh v2.0.2 2023-11-13 19:03:13 +01:00
Jordan e7853e3741 Update pvekclean.sh v2.0.2 2023-11-13 13:29:42 +01:00
Jordan 0a4fcb889d Update README.md v2.0.2 2023-11-13 13:18:22 +01:00
Jordan d7a2c688b0 Example v2.0.2 2023-11-13 13:16:48 +01:00
Jordan 3f817fc7d2 Update README.md v2.0.2 2023-11-13 04:09:25 +01:00
Jordan cc58a1b77f Update version.txt v2.0.2 2023-11-13 03:30:07 +01:00
Jordan 9e413967ce Update pvekclean.sh v2.0.2 2023-11-13 03:28:48 +01:00
Jordan ea19f62165 Update pvekclean.sh v2.0.1 2023-11-13 03:09:05 +01:00
Jordan 6401ccd2ba Update pvekclean.sh v2.0.1 2023-11-13 02:19:39 +01:00
Jordan 6ce2bb2f3e Update version.txt 2023-11-13 01:53:30 +01:00
Jordan bd991921dc Update pvekclean.sh v2.0.1 2023-11-13 01:52:56 +01:00
Jordan a6f37f50a3 Update pvekclean.sh 2023-11-13 01:43:40 +01:00
Jordan 8b7b7ce603 Update README.md 2023-11-12 23:34:49 +01:00
Jordan c910d0a40d Update README.md 2023-11-12 23:16:43 +01:00
Jordan d7da5f57e3 Example of v2.0 2023-11-12 23:15:03 +01:00
Jordan 5c432a0002 Banner of PVE Kernel Cleaner 2023-11-12 23:14:37 +01:00
Jordan d0dc6e5933 Example of v1.2 2023-11-12 23:14:10 +01:00
Jordan 7550785c9d Delete assets/example1.jpg 2023-11-12 23:13:51 +01:00
Jordan eca4370c60 Delete assets/example.jpg 2023-11-12 23:13:40 +01:00
Jordan a27b1f84fa Example of PVE Kernel Cleaner 2023-11-12 23:12:05 +01:00
Jordan e5ec7b37a3 Example of PVE Kernel Cleaner 2023-11-12 23:10:15 +01:00
Jordan 5dc03d7c67 Delete assets/example.jpg 2023-11-12 23:09:53 +01:00
Jordan 9de178bbd9 Example of PVE Kernel Cleaner 2023-11-12 23:07:37 +01:00
Jordan ecedcad905 Delete assets/example.jpg 2023-11-12 23:07:15 +01:00
Jordan 292add9b07 Example use of PVE Kernel Cleaner 2023-11-12 23:02:32 +01:00
Jordan a12ab207ee Create README.md 2023-11-12 23:01:53 +01:00
Jordan 65c6bc2641 Update README.md 2023-11-12 22:48:57 +01:00
Jordan 8f5af65eba Update README.md 2023-11-12 22:47:51 +01:00
Jordan ebbe8b3fa4 Update README.md 2023-11-12 22:41:11 +01:00
Jordan 207547b3ab Update README.md 2023-11-12 20:54:24 +01:00
Jordan 3110d396be Update README.md 2023-11-12 20:03:49 +01:00
Jordan c60c8bae59 Update pvekclean.sh 2023-11-12 20:00:54 +01:00
Jordan efa86a4734 Update pvekclean.sh 2023-11-12 19:47:31 +01:00
Jordan 695bb3c4cf Update pvekclean.sh 2023-11-12 19:37:38 +01:00
Jordan ea222ba5ad Update version.txt 2023-11-12 17:14:39 +01:00
Jordan 3b91a45492 Update README.md 2023-11-12 17:14:11 +01:00
Jordan f1174b1381 Update pvekclean.sh v2.0 2023-11-12 17:10:22 +01:00
Jordan 9c0d9ea980 Update pvekclean.sh 2023-11-12 17:07:25 +01:00
Jordan 386dcbe95a Update pvekclean.sh 2023-11-12 15:34:24 +01:00
Jordan 6513d748f8 Update pvekclean.sh 2023-11-12 15:31:25 +01:00
Jordan 911bb07097 Update version.txt 2023-11-12 14:53:53 +01:00
Jordan ef8dd187dd Update README.md 2023-11-12 14:40:26 +01:00
Jordan a9c74c22f4 Update README.md 2023-11-12 14:38:28 +01:00
8 changed files with 172 additions and 75 deletions
+55 -16
View File
@@ -1,10 +1,11 @@
![PVEKCLEAN Logo](https://jordanhillis.com/images/github/pvekclean/pvekclean_banner.png) ![PVEKCLEAN Logo](assets/banner.png)
Easily remove old/unused PVE kernels on your Proxmox VE system Easily remove old/unused PVE kernels on your Proxmox VE system
[![Version](https://img.shields.io/badge/Version-v1.0-brightgreen)](https://github.com/jordanhillis/pvekclean) [![Version](https://img.shields.io/badge/Version-v2.0.2-brightgreen)](https://github.com/jordanhillis/pvekclean)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
![Updated](https://img.shields.io/github/last-commit/jordanhillis/pvekclean) ![Updated](https://img.shields.io/github/last-commit/jordanhillis/pvekclean)
![Proxmox](https://img.shields.io/badge/-Proxmox-orange)
![Debian](https://img.shields.io/badge/-Debian-red) ![Debian](https://img.shields.io/badge/-Debian-red)
### What is PVE Kernel Cleaner? ### What is PVE Kernel Cleaner?
@@ -13,7 +14,7 @@ PVE Kernel Cleaner is a program to compliment Proxmox Virtual Environment which
## Example Usage ## Example Usage
![PVEKCLEAN Example](https://jordanhillis.com/images/github/pvekclean/pvekclean_example3.png) ![PVEKCLEAN Example](assets/example-2.0.2.png)
## Features ## Features
@@ -28,36 +29,54 @@ PVE Kernel Cleaner is a program to compliment Proxmox Virtual Environment which
## Latest Version ## Latest Version
* v1.3 * v2.0.2
## Prerequisites ## Prerequisites
Before using this program you will need to have the following packages installed. Before using this program you will need to have the following packages installed.
* cron * cron
* curl
* git
To install all required packages enter the following command. To install all required packages enter the following command.
##### Debian: ##### Debian:
``` ```
sudo apt-get install cron sudo apt-get install cron curl git
``` ```
## Installing ## Installing
To install PVE Kernel Cleaner please enter the following commands You can install PVE Kernel Cleaner using either Git or Curl. Choose the method that suits you best:
``` ### Installation via Git
1. Open your terminal.
2. Enter the following commands one by one to install PVE Kernel Cleaner:
```bash
git clone https://github.com/jordanhillis/pvekclean.git git clone https://github.com/jordanhillis/pvekclean.git
cd pvekclean cd pvekclean
chmod +x pvekclean.sh chmod +x pvekclean.sh
./pvekclean.sh ./pvekclean.sh
``` ```
### Installation via Curl
1. Open your terminal.
2. Use the following command to install PVE Kernel Cleaner:
```bash
curl -o pvekclean.sh https://raw.githubusercontent.com/jordanhillis/pvekclean/master/pvekclean.sh
chmod +x pvekclean.sh
./pvekclean.sh
```
## Updating ## Updating
To update PVE Kernel Cleaner please run the same commands as described in the "Installing" section. PVE Kernel Cleaner checks for updates automatically when you run it. If an update is available, you'll be notified within the program. Simply follow the on-screen instructions to install the update, and you're all set with the latest version!
## Usage ## Usage
@@ -70,31 +89,51 @@ Example of usage:
-f, --force Force the removal of old PVE kernels without confirm prompts -f, --force Force the removal of old PVE kernels without confirm prompts
-rn, --remove-newer Remove kernels that are newer than the currently running kernel -rn, --remove-newer Remove kernels that are newer than the currently running kernel
-s, --scheduler Have old PVE kernels removed on a scheduled basis -s, --scheduler Have old PVE kernels removed on a scheduled basis
-v, --version Shows current version of $program_name -v, --version Shows current version of pvekclean
-r, --remove Uninstall $program_name from the system -r, --remove Uninstall pvekclean from the system
-d, --debug Run the program in debug mode for testing without making system changes -i, --install Install pvekclean to the system
-d, --dry-run Run the program in dry run mode for testing without making system changes
``` ```
## Usage Examples: ## Usage Examples:
Here are some common ways to use PVE Kernel Cleaner: Here are some common ways to use PVE Kernel Cleaner:
**Remove Old Kernels Non-Interactively:** * **Remove Old Kernels Non-Interactively:**
```bash ```bash
pvekclean -f pvekclean -f
``` ```
**Set Number of Kernels to Keep:** <sub> This command removes old PVE kernels without requiring user confirmation.</sub>
* **Set Number of Kernels to Keep:**
```bash ```bash
pvekclean -k 3 pvekclean -k 3
``` ```
**Force Remove Old Kernels While Keeping a Certain Number:** <sub>This command specifies the number of most recent PVE kernels to keep on the system.</sub>
* **Force Remove Old Kernels While Keeping a Certain Number:**
```bash ```bash
pvekclean -f -k 3 pvekclean -f -k 3
``` ```
**Remove Newer Kernels and Keep a Specific Number:** <sub>This command forces the removal of old PVE kernels while retaining a specific number of the most recent ones.</sub>
* **Remove Newer Kernels and Keep a Specific Number:**
```bash ```bash
pvekclean -rn -k 2 pvekclean -rn -k 2
``` ```
<sub>This command removes newer PVE kernels and keeps a specified number of the most recent ones.</sub>
* **Schedule Regular Kernel Removal:**
```bash
pvekclean -s
```
<sub>This command sets up PVE Kernel Cleaner to remove old PVE kernels on a scheduled basis. You can configure the schedule according to your needs.</sub>
* **Perform a Dry Run without Making Changes:**
```bash
pvekclean -d
```
<sub>This command runs PVE Kernel Cleaner in dry run mode, simulating actions without actually removing any kernels or making changes to your system. It's useful for testing and understanding what the script would do.</sub>
## Developers ## Developers
+1
View File
@@ -0,0 +1 @@
Asset files here only. Not intended for program use.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

+86 -29
View File
@@ -36,8 +36,8 @@ boot_critical_percent="80"
# To check for updates or not # To check for updates or not
check_for_updates=true check_for_updates=true
# Debug mode is for testing without actually removing anything # Dry run mode is for testing without actually removing anything
debug=false dry_run=false
# Current kernel # Current kernel
current_kernel=$(uname -r) current_kernel=$(uname -r)
@@ -46,7 +46,7 @@ current_kernel=$(uname -r)
program_name="pvekclean" program_name="pvekclean"
# Version # Version
version="1.3" version="2.0.2"
# Text Colors # Text Colors
black="\e[38;2;0;0;0m" black="\e[38;2;0;0;0m"
@@ -110,8 +110,26 @@ echo -e " ${bg_black}${orange} ${re
${bg_orange}${black} ${bold}By Jordan Hillis [jordan@hillis.email] ${reset} ${bg_orange}${black} ${bold}By Jordan Hillis [jordan@hillis.email] ${reset}
___________________________________________ ___________________________________________
" "
if [ "$debug" == "true" ]; then if [ "$dry_run" == "true" ]; then
printf " ${bg_black}${orange}${bold} DEBUG MODE IS ${green}ON ${reset}\n\n" printf " ${bg_yellow}${black}${bold} DRY RUN MODE IS: ${red}ON ${reset}\n"
printf "${bg_green}${bold}${black} This is what the script would do in regular mode ${reset}\n${bg_green}${bold}${black} (but without making actual changes) ${reset}\n\n"
fi
}
# Function to get drive status based on usage percentage
get_drive_status() {
local usage=$1
# Check if the input is a number
if ! [[ $usage =~ ^[0-9]+$ ]]; then
echo "${bold}N/A${reset}"
else
if (( usage <= 50 )); then
echo "${bold}${green}Healthy${reset}"
elif (( usage > 50 && usage <= 75 )); then
echo "${bold}${orange}Moderate Capacity${reset}"
else
echo "${bold}${red}Critically Full${reset}"
fi
fi fi
} }
@@ -119,6 +137,7 @@ fi
kernel_info() { kernel_info() {
# Lastest kernel installed # Lastest kernel installed
latest_kernel=$(dpkg --list | awk '/proxmox-kernel-.*-pve/{print $2}' | sed -n 's/proxmox-kernel-//p' | sort -V | tail -n 1 | tr -d '[:space:]') latest_kernel=$(dpkg --list | awk '/proxmox-kernel-.*-pve/{print $2}' | sed -n 's/proxmox-kernel-//p' | sort -V | tail -n 1 | tr -d '[:space:]')
[ -z "$latest_kernel" ] && latest_kernel="N/A"
# Show operating system used # Show operating system used
printf " ${bold}OS:${reset} $(cat /etc/os-release | grep "PRETTY_NAME" | sed 's/PRETTY_NAME=//g' | sed 's/["]//g' | awk '{print $0}')\n" printf " ${bold}OS:${reset} $(cat /etc/os-release | grep "PRETTY_NAME" | sed 's/PRETTY_NAME=//g' | sed 's/["]//g' | awk '{print $0}')\n"
# Get information about the /boot folder # Get information about the /boot folder
@@ -131,7 +150,7 @@ kernel_info() {
if [[ "$current_kernel" == *"pve"* ]]; then if [[ "$current_kernel" == *"pve"* ]]; then
# Check if we are running the latest kernel, if not warn # Check if we are running the latest kernel, if not warn
if [[ "$latest_kernel" != *"$current_kernel"* ]]; then if [[ "$latest_kernel" != *"$current_kernel"* ]]; then
printf " ${bold}Latest Kernel:${reset} $latest_kernel\n" printf " ${bold}Latest Kernel:${reset} ${latest_kernel}\n"
fi fi
# Warn them that they aren't on a PVE kernel # Warn them that they aren't on a PVE kernel
else else
@@ -165,7 +184,8 @@ show_usage() {
printf " -s, --scheduler Have old PVE kernels removed on a scheduled basis\n" printf " -s, --scheduler Have old PVE kernels removed on a scheduled basis\n"
printf " -v, --version Shows current version of $program_name\n" printf " -v, --version Shows current version of $program_name\n"
printf " -r, --remove Uninstall $program_name from the system\n" printf " -r, --remove Uninstall $program_name from the system\n"
printf " -d, --debug Run the program in debug mode for testing without making system changes\n" printf " -i, --install Install $program_name to the system\n"
printf " -d, --dry-run Run the program in dry run mode for testing without making system changes\n"
printf "___________________________________________\n\n" printf "___________________________________________\n\n"
fi fi
} }
@@ -239,6 +259,9 @@ scheduler() {
# Installs PVE Kernel Cleaner for easier access # Installs PVE Kernel Cleaner for easier access
install_program() { install_program() {
force_pvekclean_update=false force_pvekclean_update=false
local tmp_file="/tmp/.pvekclean_install_lock"
local install=false
local ask_interval=3600 # 1 hour in seconds
# If pvekclean exists on the system # If pvekclean exists on the system
if [ -e /usr/local/sbin/$program_name ]; then if [ -e /usr/local/sbin/$program_name ]; then
# Get current version of pvekclean # Get current version of pvekclean
@@ -250,12 +273,16 @@ install_program() {
force_pvekclean_update=true force_pvekclean_update=true
fi fi
fi fi
# Check if the file doesn't exist or it's been over an hour since the last ask
if [ ! -e "$tmp_file" ] || [ ! -f "$tmp_file" ] || [ $(( $(date +%s) - $(cat "$tmp_file") )) -gt $ask_interval ] || [ $force_pvekclean_update == true ] || [ -n "$force_pvekclean_install" ]; then
# If pvekclean does not exist on the system or force_purge is enabled # If pvekclean does not exist on the system or force_purge is enabled
if [ ! -f /usr/local/sbin/$program_name ] || [ $force_pvekclean_update == true ]; then if [ ! -f /usr/local/sbin/$program_name ] || [ $force_pvekclean_update == true ] || [ -n "$force_pvekclean_install" ]; then
# Ask user if we can install it to their system # Ask user if we can install it to their system
if [ $force_purge == true ]; then if [ $force_purge == true ]; then
REPLY="n" REPLY="n"
else else
# Update the timestamp in the file to record the time of the last ask
echo $(date +%s) > "$tmp_file"
# Ask if we can install it # Ask if we can install it
printf "${bold}[-]${reset} Can we install PVE Kernel Cleaner to your /usr/local/sbin for easier access [y/N] " printf "${bold}[-]${reset} Can we install PVE Kernel Cleaner to your /usr/local/sbin for easier access [y/N] "
read -n 1 -r read -n 1 -r
@@ -273,6 +300,10 @@ install_program() {
exit 0 exit 0
fi fi
fi fi
fi
if [ -n "$force_pvekclean_install" ]; then
exit 0
fi
} }
# Uninstall pvekclean from the system # Uninstall pvekclean from the system
@@ -302,28 +333,27 @@ uninstall_program() {
# PVE Kernel Clean main function # PVE Kernel Clean main function
pve_kernel_clean() { pve_kernel_clean() {
# Find all the PVE kernels on the system # Find all the PVE kernels on the system
kernels=$(dpkg --list | grep -E '(pve-kernel|proxmox-kernel)-.*-pve' | awk '{print $2}' | sed -n 's/\(pve\|proxmox\)-kernel-\(.*\)/\2/p' | sort -V) kernels=$(dpkg --list | grep -E "(pve-kernel|proxmox-kernel)-[0-9].*" | grep -E "Kernel Image" | grep -vE "${latest_kernel%-pve}|series|transitional" | awk '{print $2}' | sed -n 's/\(pve\|proxmox\)-kernel-\(.*\)/\2/p' | sort -V)
# List of kernels that will be removed (adds them as the script goes on) # List of kernels that will be removed (adds them as the script goes on)
kernels_to_remove=() kernels_to_remove=()
# Check the /boot used # Boot drive status
printf "${bold}[*]${reset} Boot disk space used is " boot_drive_status=$(get_drive_status ${boot_info[4]})
# Warn user when the /boot is critically full # Show space used, status and free space available
if [[ "${boot_info[4]}" -ge "$boot_critical_percent" ]]; then printf "${bold}[*]${reset} Boot disk space used is ${bold}${boot_drive_status}${reset} at ${boot_info[4]}%% capacity (${boot_info[3]} free)\n"
printf "${bold}${orange}critically full${reset} "
# Tell them if it is at an acceptable percentage
else
printf "${bold}${green}healthy${reset} "
fi
# Display percentage used and available space left
printf "at ${boot_info[4]}%% capacity (${boot_info[3]} free)\n"
# For each kernel that was found via dpkg # For each kernel that was found via dpkg
current_kernel_passed=false
for kernel in $kernels for kernel in $kernels
do do
# Check if the kernel is already in the array
if [[ " ${kernels_to_remove[@]} " =~ " $kernel " ]]; then
continue # Skip adding it again
fi
# Only if not removing newer kernels and kernel matches the current kernel # Only if not removing newer kernels and kernel matches the current kernel
if [ "$(echo $kernel | grep "$current_kernel")" ]; then if [ "$(echo $kernel | grep "$current_kernel")" ]; then
if [ "$remove_newer" == "false" ]; then if [ "$remove_newer" == "false" ]; then
break break
else else
current_kernel_passed=true
continue continue
fi fi
# Add kernel to the list of removal since it is old # Add kernel to the list of removal since it is old
@@ -331,6 +361,10 @@ pve_kernel_clean() {
kernels_to_remove+=("$kernel") # Add the kernel to the array kernels_to_remove+=("$kernel") # Add the kernel to the array
fi fi
done done
# If remove_newer is set keep the last kernel installed as its newest
# if [ "$remove_newer" == "true" ] && [ "$current_kernel_passed" == "true" ] && [ ${#kernels_to_remove[@]} -gt 0 ]; then
# unset kernels_to_remove[-1]
# fi
# If keep_kernels is set we remove this number from the array to remove # If keep_kernels is set we remove this number from the array to remove
if [[ -n "$keep_kernels" ]] && [[ "$keep_kernels" =~ ^[0-9]+$ ]]; then if [[ -n "$keep_kernels" ]] && [[ "$keep_kernels" =~ ^[0-9]+$ ]]; then
if [ $keep_kernels -gt 0 ]; then if [ $keep_kernels -gt 0 ]; then
@@ -378,21 +412,27 @@ pve_kernel_clean() {
do do
printf "${bold}[-]${reset} Removing kernel: $kernel..." printf "${bold}[-]${reset} Removing kernel: $kernel..."
# Purge the old kernels via apt and suppress output # Purge the old kernels via apt and suppress output
if [ "$debug" != "true" ]; then if [ "$dry_run" != "true" ]; then
/usr/bin/apt purge -y pve-kernel-$kernel > /dev/null 2>&1 /usr/bin/apt purge -y pve-kernel-$kernel > /dev/null 2>&1
/usr/bin/apt purge -y proxmox-kernel-$kernel > /dev/null 2>&1 /usr/bin/apt purge -y proxmox-kernel-$kernel > /dev/null 2>&1
/usr/bin/apt purge -y pve-kernel-${kernel%-pve} > /dev/null 2>&1 /usr/bin/apt purge -y pve-kernel-${kernel%-pve} > /dev/null 2>&1
/usr/bin/apt purge -y proxmox-kernel-${kernel%-pve} > /dev/null 2>&1 /usr/bin/apt purge -y proxmox-kernel-${kernel%-pve} > /dev/null 2>&1
/usr/bin/apt purge -y pve-headers-${kernel%-pve} > /dev/null 2>&1
/usr/bin/apt purge -y proxmox-headers-${kernel%-pve} > /dev/null 2>&1
fi fi
sleep 1 sleep 1
printf "DONE!\n" printf "${bold}${green}DONE!${reset}\n"
done done
printf "${bold}[*]${reset} Updating GRUB..." printf "${bold}[*]${reset} Updating GRUB..."
# Update grub after kernels are removed, suppress output # Update grub after kernels are removed, suppress output
if [ "$debug" != "true" ]; then if [ "$dry_run" != "true" ]; then
/usr/sbin/update-grub > /dev/null 2>&1 /usr/sbin/update-grub > /dev/null 2>&1
fi fi
printf "DONE!\n" printf "${bold}${green}DONE!${reset}\n"
# Get information about the /boot folder
boot_info=($(echo $(df -Ph | grep /boot | tail -1) | sed 's/%//g'))
# Show information about the /boot
printf "${bold}[-]${reset} ${bold}Boot Disk:${reset} ${boot_info[4]}%% full [${boot_info[2]}/${boot_info[1]} used, ${boot_info[3]} free] \n"
# Script finished successfully # Script finished successfully
printf "${bold}[-]${reset} Have a nice $(timeGreeting) ⎦˚◡˚⎣\n" printf "${bold}[-]${reset} Have a nice $(timeGreeting) ⎦˚◡˚⎣\n"
# User wishes to not remove the kernels above, exit # User wishes to not remove the kernels above, exit
@@ -407,14 +447,26 @@ pve_kernel_clean() {
# Function to check for updates # Function to check for updates
check_for_update() { check_for_update() {
if [ "$check_for_updates" == "true" ] && [ "$force_purge" == "false" ]; then if [ "$check_for_updates" == "true" ] && [ "$force_purge" == "false" ]; then
local remote_version=$(curl -s https://raw.githubusercontent.com/jordanhillis/pvekclean/master/version.txt) # Get latest version number
local remote_version=$(curl -s -m 10 https://raw.githubusercontent.com/jordanhillis/pvekclean/master/version.txt | tr -d '\n' || echo "")
# Unable to fetch remote version, so just skip the update check
if [ -z "$remote_version" ]; then
printf "${bold}[*]${reset} Failed to check for updates. Skipping update check.\n"
return
fi
# Validate the remote_version format using a regex
if [[ ! "$remote_version" =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
printf "${bold}[*]${reset} Invalid remote version format: ${bold}${orange}$remote_version${reset}. Skipping update check.\n"
return
fi
# If version isn't the same
if [ "$remote_version" != "$version" ]; then if [ "$remote_version" != "$version" ]; then
printf "*** A new version $remote_version is available! ***\n" printf "*** A new version $remote_version is available! ***\n"
printf "${bold}[*]${reset} Do you want to update? [y/N] " printf "${bold}[*]${reset} Do you want to update? [y/N] "
read -n 1 -r read -n 1 -r
printf "\n" printf "\n"
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
local updated_script=$(curl -s https://raw.githubusercontent.com/jordanhillis/pvekclean/master/pvekclean.sh) local updated_script=$(curl -s -m 10 https://raw.githubusercontent.com/jordanhillis/pvekclean/master/pvekclean.sh)
# Check if the updated script contains the shebang line # Check if the updated script contains the shebang line
if [[ "$updated_script" == "#!/bin/bash"* ]]; then if [[ "$updated_script" == "#!/bin/bash"* ]]; then
echo "$updated_script" > "$0" # Overwrite the current script echo "$updated_script" > "$0" # Overwrite the current script
@@ -430,7 +482,7 @@ check_for_update() {
} }
timeGreeting() { timeGreeting() {
h=$(date +%H) h=$(date +%k) # Use %k to get the hour as a decimal number (no leading zero)
((h >= 5 && h < 12)) && echo "morning" && return ((h >= 5 && h < 12)) && echo "morning" && return
((h >= 12 && h < 17)) && echo "afternoon" && return ((h >= 12 && h < 17)) && echo "afternoon" && return
((h >= 17 && h < 21)) && echo "evening" && return ((h >= 17 && h < 21)) && echo "evening" && return
@@ -454,6 +506,11 @@ main() {
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
-i|--install )
force_pvekclean_install=true
main
install_program
;;
-r|--remove ) -r|--remove )
main main
uninstall_program uninstall_program
@@ -489,8 +546,8 @@ while [[ $# -gt 0 ]]; do
shift shift
continue continue
;; ;;
-d|--debug) -d|--dry-run)
debug=true dry_run=true
shift shift
continue continue
;; ;;
+1 -1
View File
@@ -1 +1 @@
1.3 2.0.2