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.

0

2 Answers 2

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)

2
  • 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, 2012 at 8:03
  • Updated above :-). Apr 26, 2012 at 8: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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .