2

I'm writing a small 'install script' and it requires EPEL on CentOS. The command (repo url) differs according to OS bitness, how do I unify this into one command?

References: How to install EPEL

I remember doing this with uname, but am not sure how to incorporate it into the existing command.

Bart De Vos
  • 17,761
  • 6
  • 62
  • 81
Christian
  • 462
  • 5
  • 22

2 Answers2

2

You could do this with uname -i and cat /etc/redhat-release. This would give the following:

[bart@dev ~]$ cat /etc/redhat-release
CentOS release 6.2 (Final)
[bart@dev ~]$ uname -i
x86_64

I would script it like this:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/`uname -i`/epel-release-5-4.noarch.rpm

(didn't test, and you would need to catch some exceptions like 404s)

Bart De Vos
  • 17,761
  • 6
  • 62
  • 81
  • ``rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/`uname -i`/epel-release-5-4.noarch.rpm`` <- is this it? Also, since it will be running on CentOS 5 only, I don't have to handle other versions. Perhaps an add-n in the future, but not needed right now. – Christian Apr 26 '12 at 08:03
  • Updated above :-). – Bart De Vos Apr 26 '12 at 08:14
1

uname -i should output the architecture on many systems (it does on some of my i386 systems but unknown for others). If for some reason you needed to get machine type, uname -m would work.

You'd likely want to store this as a variable include the line arc=$(uname -i) in your script, and use the variable $arc as needed

Journeyman Geek
  • 6,969
  • 3
  • 31
  • 49