Jump to content

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


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...