Jump to content

Built-in Script Raspberry Pi Rasperrian [ Check and Install Updates ]


GoalTV
 Share

Recommended Posts

Hey,

 

I noticed by deafult the build-in script don't support update check for Rasperrian I have updated the script simply create new script for linux call it update or how you want it.

 

#!/bin/bash

detect_os() {
  grep -qis "$*" /etc/issue || grep -qis "$*" /etc/centos-release
}

do_update() {
  echo "Detecting OS ... "

  detect_os "Raspbian GNU/Linux" && echo "Found Raspbian" && dpkg_update && return
  detect_os "Debian GNU/Linux" && echo "Found Debian" && dpkg_update && return
  detect_os "Ubuntu" && echo "Found Ubuntu" && dpkg_update && return
  detect_os "CentOS" && echo "Found CenOS" && yum_update && return
  detect_os "Red Hat" && echo "Found RedHat" && yum_update && return
  detect_os "Fedora" && echo "Found Fedora" && yum_update && return
  detect_os "SUSE" && echo "Found SuSE" && zypper_update && return
}

dpkg_update() {
 if [ -x "/usr/bin/apt-get" ];
 then
   echo "Starting update ..."
   apt-get clean && apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
 else
   echo "'apt-get' package manager not found"
 fi
}

yum_update() {
 if [ -x "/usr/bin/yum" ];
 then
   echo "Starting update ..."
   yum update -y && yum upgrade -y
 else
   echo "'yum' package manager not found"
 fi
}

zypper_update() {
 if [ -x "/usr/bin/zypper" ];
 then
   echo "Starting update ..."
   zypper --non-interactive update
 else
   echo "'zypper' package manager not found"
 fi
}

do_update

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...