Most recent distributions have lsb_release, or at least /etc/lsb-release, which you can use to get OS and VER.
I think uname to get ARCH is still the best way.
e.g.
OS=$(lsb_release -si)
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VER=$(lsb_release -sr)
or
. /etc/lsb-release
OS=$DISTRIB_ID
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VER=$DISTRIB_RELEASE
If you have to be compatible with older distributions, there is no single file you can rely on. Either fall back to the output from uname, e.g.
OS=$(uname -s)
ARCH=$(uname -m)
VER=$(uname -r)
or handle each distribution separately:
if [ -f /etc/debian_version ]; then
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/redhat-release ]; then
# TODO add code for Red Hat and CentOS here
It's probably best to combine all this:
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/redhat-release ]; then
# TODO add code for Red Hat and CentOS here
...
else
OS=$(uname -s)
VER=$(uname -r)
fi
Finally, your ARCH obviously only handles Intel systems. I'd either call it BITS like this:
case $(uname -m) in
x86_64)
BITS=64
;;
i*86)
BITS=32
;;
*)
BITS=?
;;
esac
Or change ARCH to be the more common, yet unambiguous versions: x86 and x64 or similar:
case $(uname -m) in
x86_64)
ARCH=x64 # or AMD64 or Intel64 or whatever
;;
i*86)
ARCH=x86 # or IA32 or Intel32 or whatever
;;
*)
# leave ARCH as-is
;;
esac
but of course that's up to you.