Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Platform detection

    Scheduled Pinned Locked Moved Development
    3 Posts 2 Posters 2.8k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MrMoo
      last edited by

      Currently pfSense detects which platform it is on using the file /etc/platform:

      
      # Set our operating platform
      PLATFORM=`cat /etc/platform`
      
      HOME=/
      PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
      export HOME PATH
      
      # Set our current version
      version=`cat /etc/version`
      
      echo
      cat /etc/ascii-art/pfsense-logo-small.txt
      echo
      echo
      echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
      echo
      
      if [ "$PLATFORM" = "cdrom" ]; then
      	/etc/rc.cdrom
      fi
      
      if [ "$PLATFORM" = "embedded" ]; then
      	/etc/rc.embedded
      fi
      
      

      However this requires a separate images to be generated for each version, an alternative is to just generate different kernels and then use the kernel ident to define the platform.  i.e.

      
      ident=`uname -i`
      
      # detect platform
      case "$ident" in
      *-embedded*)    platform=embedded ;;
      *)              platform=cdrom ;;
      esac
      
      # detect developer status
      case "$ident" in
      *DEV)           developer=true ;;
      esac
      
      echo "platform: $platform"
      echo "developer: $developer"
      
      
      1 Reply Last reply Reply Quote 0
      • S
        sullrich
        last edited by

        This is a interesting idea but will not work for all cases.

        Case in point, a lot of people like to run a full installation on a WRAP + Microdrive.  Using this method would not allow the user to override the settings.

        1 Reply Last reply Reply Quote 0
        • M
          MrMoo
          last edited by

          I think this problem is similar to how to deal with JavaScript in web pages.  The preferred method should not be to detect the platform but to detect the features.  For instance ask what are the real reasons for requiring a platform tag?  The main ones are for the kernel and for system upgrades.  Both of these are available with the kernel ident.  For other situations where the platform tag is used they can be replaced by feature detection.  For example /dev/ttyv0 does not exist on embedded platforms, and /dev/ttyd0 will not exist on strange platforms without a serial port.  CD-ROM based environments can be detected because the root file system is a cd9660 mount point, NFS debug environments can be detected similarly, and HDD/CF installs will have a /dev/ufs GEOM label root fs.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.