-
Notifications
You must be signed in to change notification settings - Fork 0
/
hiveos_maintenance.sh
60 lines (48 loc) · 1.68 KB
/
hiveos_maintenance.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Function to print a step message and execute a command
print_step() {
echo -e "\e[32mSTEP $1: $2 ($3)\e[0m"
}
# Function to print a warning message
print_warning() {
echo -e "\e[33mWarning: executing command: $1\e[0m"
}
# Function to print an error message
print_error() {
echo -e "\e[91mError: executing command: $1\e[0m"
}
run_command() {
print_step "$1" "$2" "$3"
output=$($3 2>&1)
exit_status=$?
if [ $exit_status -eq 0 ]; then
echo "$output"
else
if [ $1 -eq 1 ]; then
if [[ "$output" != *"no miner screen found"* ]]; then
print_warning "$2"
fi
elif [ $1 -eq 3 ]; then
if [[ "$output" != *"this version is already installed"* ]]; then
print_warning "$2"
fi
else
print_error "$2"
echo "$output"
fi
fi
}
# Execute commands one by one
run_command 1 "Waiting for the miner to stop" "miner stop"
run_command 2 "Cleaning all installed miner versions" "hpkg purge"
run_command 3 "Updating Nvidia drivers to the latest version, if available" "nvidia-driver-update"
run_command 4 "Removing all old Nvidia driver installation packages" "nvidia-driver-update --remove"
run_command 6 "Reinstall nvidia-settings only" "nvidia-driver-update --nvs"
run_command 7 "Remove unused drivers at /hive-driver-pack" "rm /hive-drivers-pack/NV*"
run_command 8 "Checking disk space..." "df -h"
# If all commands executed successfully, prompt the user to press a key to restart
echo "All commands executed successfully. Press any key to restart."
read -n 1 -s -r -p "Press any key to continue"
echo ""
# Restarting the system
reboot