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