#!/bin/sh -e # # release: grab the os/distro release # Copyright (C) 2008 Canonical Ltd. # # Authors: Dustin Kirkland # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . PKG="byobu" color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then cat /etc/issue exit 0 fi if [ -n "$DISTRO" ]; then # skip down to the bottom true elif which lsb_release >/dev/null 2>&1; then if [ "$1" = "--detail" ]; then lsb_release -a 2>/dev/null exit 0 fi # If lsb_release is available, use it r=$(lsb_release -s -d) if echo "$r" | grep -qs "^Ubuntu .*\..*\..*$"; then # Use the -d if an Ubuntu LTS DISTRO="$r" else # But for other distros the description # is too long, so build from -i and -r i=$(lsb_release -s -i) r=$(lsb_release -s -r) DISTRO="$i $r" fi elif [ -r "/etc/palm-build-info" ]; then # Palm Pre hack DISTRO=$(grep "^PRODUCT_VERSION_STRING=Palm " /etc/palm-build-info | sed "s/^.*=Palm //") elif [ -r "/etc/issue" ]; then # Otherwise, grab part of /etc/issue, ideally the distro and version DISTRO=$(grep -m1 "^[A-Za-z]" /etc/issue | sed "s/ [^0-9]* / /" | awk '{print $1 " " $2}') else DISTRO="Byobu" fi printf "$(color bold2)%s$(color -) " "$DISTRO"