Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System About Functions #18

Open
andrewwoods opened this issue Aug 12, 2023 · 3 comments
Open

System About Functions #18

andrewwoods opened this issue Aug 12, 2023 · 3 comments
Labels
Epic A group of related features
Milestone

Comments

@andrewwoods
Copy link
Owner

Description

Bash is used on multiiple operating systems. There isn't a good univeral way to identify the type of operating system, or the name and version of operating system in a predicatble way. Knowing which system a script is running on, can be useful in changing the way a script works, or change where to look for resources.

Expected Outcome

There should be function specific to each type of system about_mac(), about_ubuntu(), etc. Upon install, we could create an alias to the name system or about, which maps to the correct function. This way, a user could be instructed to copy the output of system into a message, when debugging. There must be no user identifialbe infomration about the person that owns the system. These functions are about identifying the type of system.

Additionally, there need to be functions that can query the system in a predicatble way. Sometimes you just want to know the type of OS (mac vs linux). You may also want to know the OS Name, becuase 2 linux distros (e.g. Pop_OS! vs Ubuntu) may do something differently, and it would be good if your script could handle that.

OS Type: mac
OS Name: macOS
OS Version: 13.0.1
Company: Apple
Kernel Version:  Darwin 22.1.0

OS Type: linux
OS Name: Ubuntu 
OS Version: 22.04
Company: Canonical
Kernel Version: Linux 6.1.2 2023-01-01

Describe alternatives you've considered

The uname command is available, but its output needs some sanitization. There may be additional system commands that can help provide useful information. Research is required.

@andrewwoods andrewwoods added the Epic A group of related features label Aug 12, 2023
@andrewwoods andrewwoods added this to the Version 3 milestone Aug 12, 2023
@andrewwoods
Copy link
Owner Author

andrewwoods commented Aug 24, 2023

So I found a visual family tree of Linux Distros online, to figure out which are the major distros. My thinking is that upstream distros will probably have the same CLI commands available as its base distro. Some distros, like Ubuntu, are the base distro for whole new tree of distros. So if I can write an "about function" for each base distro, that should provide enough coverage to meet most people's needs.

  • Debian
    • Ubuntu
    • Knoppix
  • Slackware
  • RedHat
    • Fedora
    • CentOS
  • FreeBSD
  • OpenBSD
  • Mandriva
  • OpenSuse
  • Arch
  • Gentoo
  • Solaris

@andrewwoods
Copy link
Owner Author

To check for Pop_OS! - check if the file /etc/pop-os/os-release exists. The uname -a is, which says GNU/Linux, is useless. In this file, you can read

NAME="Pop!_OS"
VERSION="22.04 LTS"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 22.04 LTS"
VERSION_ID="22.04"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=jammy
UBUNTU_CODENAME=jammy
LOGO=distributor-logo-pop-os

andrewwoods added a commit that referenced this issue Sep 13, 2023
Informs the user about the high-level system information. It checks for
neofetch, so if the user has already installed it, it wll use neofetch.
Otherwise it makes use of it already installed. Becuase these fallback
functions vary in their output, it's impossible to guarantee uniformity.
After all, that's what neofetch is doing.

Issue: #18
@andrewwoods
Copy link
Owner Author

The OSTYPE variable is not always useful. on Pop_OS, it just says "GNU/Linux" when what I really want, is for it to tell me that it's "Pop_OS!". So I'll need to create a better detection method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic A group of related features
Projects
None yet
Development

No branches or pull requests

1 participant