HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //proc/self/root/usr/sbin/laptop-detect
#!/bin/sh -e

usage () {
    echo "Usage: $0 [-h|--help|-v|--verbose]"
    echo ""
    echo "  -h | --help      print this help"
    echo "  -v | --verbose   be verbose (messages go to STDOUT)"
    echo "  -V | --version   print version information"
    echo ""
    echo " Possible return values:"
    echo "  0  most likely running on a laptop"
    echo "  1  most likely NOT running on a laptop"
    echo "  2  called with unknown option, -h, --help, -V or --version"
}

PRINTIT="/bin/true" # /bin/true accepts any option but never prints anything

# Check wether we were asked to be verbose

if [ "$1" != "" ]; then
    case "$1" in
        "-v"|"--verbose")
            PRINTIT="echo"
            ;;
        "-V"|"--version")
            echo "Version: 0.13.8"
            exit 2
            ;;
        "-h"|"--help")
            usage
            exit 2
            ;;
        *)
            echo "UNKNOWN OPTION: $1"
            usage
            exit 2
            ;;
    esac
fi

# Are we a mac?
if test -d /proc/pmu; then
        batteries=$(grep Battery /proc/pmu/info | cut -f2 -d:)
        if test "$batteries" -ne 0; then
            $PRINTIT "We're a laptop (Mac: batteries found)" >&2;
            exit 0
        fi
        exit 1
fi

if [ -r /dev/mem -a -x /usr/sbin/dmidecode ]; then
        # dmidecode to grab the Chassis type
        dmitype=$(dmidecode --string chassis-type)

        if test "$dmitype" = "Notebook" || test "$dmitype" = "Portable"; then
            $PRINTIT "We're a laptop (dmidecode returned $dmitype)" >&2
            exit 0
        fi

        # turn back on for debugging
        #echo "$dmitype"
fi

# check for any ACPI batteries
/sbin/modprobe battery 2> /dev/null || true
if [ -d /sys/class/power_supply ]; then
	if grep -q Battery /sys/class/power_supply/*/type 2>/dev/null; then
            $PRINTIT "We're a laptop (ACPI batteries found)" >&2
            exit 0
	fi
fi
# old interface:
if [ -d /proc/acpi/battery ]; then
        results=`find /proc/acpi/battery -mindepth 1 -type d`
        if [ ! -z "$results" ]; then
            $PRINTIT "We're a laptop (ACPI batteries found)" >&2
            exit 0
        fi
fi


# check for APM batteries. This sucks, because we'll only get a valid response
# if the laptop has a battery fitted at the time
if [ -f /proc/apm ]; then
    battery=`awk '{print $6}' </proc/apm`
    if [ "$battery" != "0xff" ] && [ "$battery" != "0x80" ]; then
        $PRINTIT "We're a laptop (APM batteries found)" >&2
        exit 0
    fi
fi

$PRINTIT "We're not on a laptop (no relevant hint found)" >&2
exit 1