.bashrc.d/01detect_system: Use os-release to detect Arch
[dotfiles-public.git] / src / .bashrc.d / 01detect_system
1 # Detect the type of system we're running on
2 #
3 # This makes it easy to adjust script locations and so forth to match
4 # your system's file placement and other quirks.
5
6 if [ -z "${OS}" ]; then
7         export OS='UNKNOWN'
8         if [ -f '/etc/make.conf' ] || [ -f '/etc/portage/make.conf' ]; then
9                 export OS='Gentoo'
10         elif [ "${SHELL#*gentoo}" != "${SHELL}" ]; then  # assumes 'gentoo' in prefix
11                 export OS='Gentoo Prefix'
12         elif grep -i '^ID=.*arch' /etc/os-release > /dev/null 2>&1; then
13                 export OS='Arch'
14         elif grep -i debian /etc/issue > /dev/null 2>&1; then
15                 export OS='Debian'
16         elif grep -i ubuntu /etc/issue > /dev/null 2>&1; then
17                 export OS='Ubuntu'
18         elif grep -i fedora /etc/issue > /dev/null 2>&1; then
19                 export OS='Fedora'
20         elif grep -i sunos /etc/motd > /dev/null 2>&1; then
21                 export OS='SunOS'
22         else
23                 echo "unknown system.  Adjust .bashrc.d/01detect_system or set OS by hand" >&2
24         fi
25 fi