Refacere repo
This commit is contained in:
27
Bash_scripting/updates.sh
Executable file
27
Bash_scripting/updates.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
release_file=/etc/os-release
|
||||
logfile=/var/log/updater.log
|
||||
errorlog=/var/log/updater_errors.log
|
||||
|
||||
check_exit_status() {
|
||||
local status=$1
|
||||
local command_name=$2
|
||||
if [ $status -ne 0 ]
|
||||
then
|
||||
echo "An error occurred during $command_name, please check the $errorlog file."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if grep -q "Ubuntu" $release_file || grep -q "Debian" $release_file
|
||||
then
|
||||
# The host is Debian or Ubuntu
|
||||
# Run the apt version of the command
|
||||
sudo apt update 1>>$logfile 2>>$errorlog
|
||||
check_exit_status $? "apt update"
|
||||
|
||||
sudo apt dist-upgrade -y 1>>$logfile 2>>$errorlog
|
||||
check_exit_status $? "apt dist-upgrade"
|
||||
|
||||
echo "Update completed successfully!"
|
||||
fi
|
||||
Reference in New Issue
Block a user