You are not logged in.

#1 2010-07-22 01:49:51

FathisAeril
Member
Registered: 2010-07-02
Posts: 82

[Bash] System wide upgrade across multiple distros

Alright, I've got a script I used to use back on ubuntu called sysupdate (See below) Basically it combined

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get auto-remove && sudo apt-get autoclean

down to

sudo sysupdate

Saved time, saved headaches, was just better to use since I knew what it did. And that was great, for Apt.

What I was wonder, is if there was a way for me to distinguish between Arch and ubuntu from Bash, so that I could just copy this script around to all my machines (since some do run non-arch) without having to change it, and then directing the commands as needed.

The script as of right now

#!/bin/bash
# System Wide Update, using apt-get

ROOT_UID=0     # Only users with $UID 0 have root privileges.
E_NOTROOT=87   # Non-root exit error.



# Run as root, of course.
if [ "$UID" -ne "$ROOT_UID" ]
then
  echo "Must be root (sudo/su) to run this script."
  exit $E_NOTROOT
fi  

# Update commands
apt-get update && apt-get dist-upgrade

# Cleans up after itself after update. 
apt-get autoremove
apt-get autoclean

It doesn't matter how much training you have. A broken rib is still a broken rib.

Offline

#2 2010-07-22 02:06:43

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,109
Website

Re: [Bash] System wide upgrade across multiple distros

Conditional based on the package manager existing...

if type -P pacman; then
  pacman -Syu
elif type -P apt-get; then
  # apt stuff
elif type -P yum; then
....
...

Offline

#3 2010-07-22 03:37:57

FathisAeril
Member
Registered: 2010-07-02
Posts: 82

Re: [Bash] System wide upgrade across multiple distros

Falcon.... that is beautiful. I seriously was expecting something A LOT more complex o.0

Thank you!

Edit: Looking back, thats partially what I was after. I was looking for something closer to lsb_release


for example, uname -r tells me the kernel (which in default Arch is actually useful since the kernel ends in "-ARCH") meanwhile Ubuntu implements "lsb_release" so that if a user types in  " lsb_release -i -r -s " it will say Ubuntu*9.10 or Ubuntu*10.04   or "lsb_release -cs" will print out the adjective for that release "karmic" for "karmic koala" "lucid" for "lucid lynx" etc etc etc.

I didn't know if there was a universal command across Distros for determining what a user was running

Last edited by FathisAeril (2010-07-22 04:00:47)


It doesn't matter how much training you have. A broken rib is still a broken rib.

Offline

#4 2010-07-22 08:47:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Bash] System wide upgrade across multiple distros

> I didn't know if there was a universal command across Distros for determining what a user was running
http://distrowatch.com/dwres.php?resour … management ?

Offline

#5 2010-07-22 09:10:29

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [Bash] System wide upgrade across multiple distros

FathisAeril wrote:

is if there was a way for me to distinguish between Arch and ubuntu from Bash.

Ubuntu has /etc/debian_version and Arch has /etc/arch-release .


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#6 2010-07-22 21:36:44

FathisAeril
Member
Registered: 2010-07-02
Posts: 82

Re: [Bash] System wide upgrade across multiple distros

I know I'm hijacking my own, but  I didnt want to make a new thread just for thissimple yes / no question.

Does

pacman -Syy
pacman -Qs


still report what packages are available to upgrade? kept meaning to check before doing an upgrade, but it kept slipping my mind.

Im asking because I was working on adding an update notifier to Conky, and I noticed a lot of the posts were from a few years back, meanwhile I know that pacman has changed how it works with Qs


It doesn't matter how much training you have. A broken rib is still a broken rib.

Offline

#7 2010-07-22 21:39:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Bash] System wide upgrade across multiple distros

'pacman -Qs'??
Maybe you mean '-Qu'?

Last edited by karol (2010-07-22 21:43:45)

Offline

#8 2010-07-22 22:48:16

FathisAeril
Member
Registered: 2010-07-02
Posts: 82

Re: [Bash] System wide upgrade across multiple distros

lol yeah meant Qu


It doesn't matter how much training you have. A broken rib is still a broken rib.

Offline

#9 2010-07-22 22:53:26

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Bash] System wide upgrade across multiple distros

FathisAeril wrote:

lol yeah meant Qu

Yes, it does report.

Offline

Board footer

Powered by FluxBB