Merge pull request #708 from dylanaraps/irix

OS:  Add initial support for IRIX
This commit is contained in:
Herdiansyah 2017-06-20 21:10:20 +07:00 committed by GitHub
commit 7118516541
2 changed files with 73 additions and 16 deletions

19
ascii/distro/irix Normal file
View file

@ -0,0 +1,19 @@
${c1} ./ohmNd/ +dNmho/-
`:+ydNMMMMMMMM.-MMMMMMMMMdyo:.
`hMMMMMMNhs/sMMM-:MMM+/shNMMMMMMh`
-NMMMMMmo-` /MMM-/MMM- `-omMMMMMN.
`.`-+hNMMMMMNhyMMM-/MMMshmMMMMMmy+...`
+mMNds:-:sdNMMMMMMMyyMMMMMMMNdo:.:sdMMm+
dMMMMMMmy+.-/ymNMMMMMMMMNmy/-.+hmMMMMMMd
oMMMMmMMMMNds:.+MMMmmMMN/.-odNMMMMmMMMM+
.MMMM-/ymMMMMMmNMMy..hMMNmMMMMMmy/-MMMM.
hMMM/ `/dMMMMMMMN////NMMMMMMMd/. /MMMh
/MMMdhmMMMmyyMMMMMMMMMMMMhymMMMmhdMMM:
`mMMMMNho//sdMMMMM//NMMMMms//ohNMMMMd
`/so/:+ymMMMNMMMM` mMMMMMMMmh+::+o/`
`yNMMNho-yMMMM` NMMMm.+hNMMNh`
-MMMMd: oMMMM. NMMMh :hMMMM-
-yNMMMmooMMMM- NMMMyomMMMNy-
.omMMMMMMMM-`NMMMMMMMmo.
`:hMMMMMM. NMMMMMh/`
.odNm+ /dNms.

View file

@ -20,8 +20,8 @@ old_ifs="$IFS"
export LC_ALL=C
export LANG=C
# Add /usr/xpg4/bin, /usr/sbin, and /sbin to PATH.
export PATH="/usr/xpg4/bin:/usr/sbin:/sbin:${PATH}"
# Add /usr/xpg4/bin, /usr/sbin, /sbin, and /usr/etc to PATH.
export PATH="/usr/xpg4/bin:/usr/sbin:/sbin:/usr/etc:${PATH}"
# Set no case match.
shopt -s nocasematch
@ -43,6 +43,7 @@ get_os() {
"Haiku") os="Haiku" ;;
"MINIX") os="MINIX" ;;
"AIX") os="AIX" ;;
"IRIX64") os="IRIX" ;;
*)
printf "%s\n" "Unknown OS detected: '$kernel_name', aborting..." >&2
printf "%s\n" "Open an issue on GitHub to add support for your OS." >&2
@ -211,6 +212,10 @@ get_distro() {
"AIX")
distro="AIX $(oslevel)"
;;
"IRIX")
distro="IRIX ${kernel_version}"
;;
esac
[[ -z "$distro" ]] && distro="$os (Unknown)"
@ -218,7 +223,7 @@ get_distro() {
# Get OS architecture.
if [[ "$os_arch" == "on" ]]; then
case "$os" in
"Solaris" | "AIX" | "BSD" | "Haiku") machine_arch="$(uname -p)" ;;
"Solaris" | "AIX" | "BSD" | "Haiku" | "IRIX") machine_arch="$(uname -p)" ;;
*) machine_arch="$(uname -m)" ;;
esac
@ -336,8 +341,8 @@ get_title() {
}
get_kernel() {
# Since AIX is an integrated system, it's better to skip this function altogether
[[ "$os" == "AIX" ]] && return
# Since these OS are integrated systems, it's better to skip this function altogether
[[ "$os" =~ (AIX|IRIX) ]] && return
case "$kernel_shorthand" in
"on") kernel="$kernel_version" ;;
@ -385,7 +390,7 @@ get_uptime() {
seconds="${seconds/.*}"
;;
"AIX")
"AIX" | "IRIX")
t="$(LC_ALL=POSIX ps -o etime= -p 1)"
d="0" h="0"
case "$t" in *"-"*) d="${t%%-*}"; t="${t#*-}";; esac
@ -554,6 +559,10 @@ get_packages() {
packages="$(lslpp -J -l -q | grep -cv '^#')"
packages="$((packages+=$(rpm -qa | wc -l)))"
;;
"IRIX")
packages="$(($(versions -b | wc -l)-3))"
;;
esac
((packages == 0)) && unset packages
@ -994,6 +1003,17 @@ get_cpu() {
"physical") cores="$(lparstat -i | awk -F':' '/Active Physical CPUs/ {printf $2}')"
esac
;;
"IRIX")
# Get CPU name.
cpu="$(hinv -c processor | awk -F':' '/CPU:/ {printf $2}')"
# Get CPU speed.
speed="$(hinv -c processor | awk '/MHZ/ {printf $2}')"
# Get CPU cores.
cores="$(sysconf NPROC_ONLN)"
;;
esac
if [[ "$speed" ]]; then
@ -1026,6 +1046,7 @@ get_cpu() {
cpu="${cpu//with Radeon * Graphics}"
cpu="${cpu//, altivec supported}"
cpu="${cpu//FPU*}"
cpu="${cpu//Chip Revision*}"
# Trim spaces from core output
cores="${cores//[[:space:]]}"
@ -1072,6 +1093,7 @@ get_cpu_usage() {
"Haiku") cores="$(sysinfo -cpu | grep -c -F 'CPU #')" ;;
"iPhone OS") cores="${cpu/*\(}"; cores="${cores/\)*}" ;;
"AIX") cores="$(lparstat -i | awk -F':' '/Online Virtual CPUs/ {printf $2}')" ;;
"IRIX") cores="$(sysconf NPROC_ONLN)"
esac
fi
@ -1304,6 +1326,13 @@ get_memory() {
mem_used="$((mem_total - mem_free))"
mem_label="MB"
;;
"IRIX")
mem_stat=($(pmem | head -1))
mem_total="$((mem_stat[3] / 1024))"
mem_free="$((mem_stat[5] / 1024))"
mem_used="$((mem_total - mem_free))"
;;
esac
memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB}"
@ -1846,12 +1875,13 @@ get_disk() {
type -p df >/dev/null 2>&1 || \
{ err "Disk requires 'df' to function. Install 'df' to get disk info."; return; }
# Get "df" flags.
case "$os" in
"Haiku") err "Disk doesn't work on Haiku due to the non-standard 'df'"; return ;;
"Mac OS X") df_flags=(-P -h) ;;
"AIX") df_flags=(-P -g) ;;
*) df_flags=(-h) ;;
# Get "df" version.
df_version="$(df --version 2>&1)"
case "$df_version" in
*"blocks"*) err "Your version of df cannot be used due to the non-standard flags" ; return ;; # Haiku
*"IMitv"*) df_flags=(-P -g) ;; # AIX
*"befhikm"*) df_flags=(-P -k) ;; # IRIX
*) df_flags=(-P -h) ;;
esac
# Create an array called 'disks' where each element is a separate line from
@ -1870,7 +1900,10 @@ get_disk() {
disk_info=($disk)
disk_perc="${disk_info[4]/'%'}"
disk="${disk_info[2]/i} / ${disk_info[1]/i} (${disk_perc}%)"
case "$df_version" in
*"befhikm"*) disk="$((disk_info[2]/1024/1024))G / $((disk_info[1]/1024/1024))G (${disk_perc}%)" ;;
*) disk="${disk_info[2]/i} / ${disk_info[1]/i} (${disk_perc}%)" ;;
esac
# Subtitle.
case "$disk_subtitle" in
@ -1979,7 +2012,7 @@ get_battery() {
get_local_ip() {
case "$os" in
"Linux" | "BSD" | "Solaris" | "AIX")
"Linux" | "BSD" | "Solaris" | "AIX" | "IRIX")
local_ip="$(ip route get 1 | awk -F'src' '{print $2; exit}')"
local_ip="${local_ip/uid*}"
[[ -z "$local_ip" ]] && local_ip="$(ifconfig -a | awk '/broadcast/ {print $2; exit}')"
@ -2038,7 +2071,7 @@ get_install_date() {
esac
;;
"Haiku") install_file="/boot" ;;
"BSD" | "MINIX")
"BSD" | "MINIX" | "IRIX")
case "$kernel_name" in
"FreeBSD") install_file="/etc/hostid" ;;
"NetBSD" | "DragonFly"*) install_file="/etc/defaults/rc.conf" ;;
@ -2054,7 +2087,7 @@ get_install_date() {
*"crtime"*) install_date="$(ls -tdcE "$install_file" | awk '{printf $6 " " $7}')" ;; # xpg4 (Solaris)
*"ACFHLRSZ"*) install_date="$(ls -dl "$install_file" | awk '{printf $6 " " $7}')" ;; # Toybox
*"GNU coreutils"*) install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')" ;;
*"ACFHLNRS"*) err "Install Date doesn't work because your 'ls' does not support showing full date and time."; return ;; # AIX ls
*"ACFHLNRS"* | *"RadC1xmnlog"*) err "Install Date doesn't work because your 'ls' does not support showing full date and time."; return ;; # AIX ls / IRIX ls
*) install_date="$(ls -dlctT "$install_file" | awk '{printf $9 " " $6 " "$7 " " $8}')" ;;
esac
@ -3460,6 +3493,11 @@ get_distro_colors() {
set_colors 3 7
ascii_file="solaris"
;;
"IRIX"*)
set_colors 4 7
ascii_file="irix"
;;
esac
;;
esac