Is there any reliable way to judge that the current linux system is Openwrt?

Hi folks!!!
Is there any reliable way to judge that the current linux system is Openwrt?

I am writing a commandline program with rust and target with x86_64-unknown-linux-musl. it runs on Debian、CentOS、openwrt etc. Debian use systemd as service manager, but openwrt not.

For sure, if you downloaded it from the openwrt firmware selector then it is openwrt

If it came from anywhere else then it’s not

2 Likes

Define what you mean by "is OpenWrt?"

What is your purpose? Installing packages?
Tweaking a generic startup script in case the system is OpenWrt?

Many OEM firmwares are based on OpenWrt and some OEMs even leave the underlying OpenWrt branding and ID files there. So looking for a file like /etc/openwrt_release might tell that the system is based on OpenWrt but might not be conclusive on the system really being "normal" OpenWrt.

One common thing for OpenWrt based systems might be the "procd" process manager. If process with PID 1 is "/sbin/procd", the system is almost certainly OpenWrt based (but might still be an OEM variant).

1 Like

@hnyman @jdwl1o1 Thanks!

I am writing a commandline program with rust and target with x86_64-unknown-linux-musl. it runs on Debian、CentOS、openwrt etc. Debian use systemd as service manager, but openwrt not.

no need to C&P the 1st post again, the people you're communicating with haven't got (that) bad memory.

try answering the questions instead.

Can't (lsb) /etc/*release be referenced? This is what I use, before that it was a bunch of switch/esac statements based on various things like uname, as hnyman mentions.

# cat /etc/os-release 
NAME="OpenWrt"
VERSION="22.03-SNAPSHOT"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt 22.03-SNAPSHOT"
OPENWRT_RELEASE="OpenWrt 22.03-SNAPSHOT r19985-bc64ca15d4"
<snip>
$ cat /etc/os-release 
NAME="Fedora Linux"
VERSION="37 (Workstation Edition)"
ID=fedora
VERSION_ID=37
VERSION_CODENAME=""
PLATFORM_ID="platform:f37"
PRETTY_NAME="Fedora Linux 37 (Workstation Edition)"
<snip>
1 Like