Created
June 30, 2015 21:55
-
-
Save denmojo/a8afb8b5aa6e65c438a4 to your computer and use it in GitHub Desktop.
Useful info for MOTD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| exec("system_profiler SPFirewallDataType SPPowerDataType SPNetworkDataType SPSoftwareDataType 2>/dev/null", $systemvars); | |
| $tree = array(); | |
| foreach($systemvars as $var){ | |
| if(preg_match("`^(\s+)(.*):\s+(.*)$`", $var, $match)){ | |
| $variable = $match[2]; | |
| $value = $match[3]; | |
| ${str_replace(array(" ", "-", ".", "(", ")"), "_", strtoupper( $active_submodule." ".$variable ))} = $value; | |
| } | |
| else if(preg_match("`^(\s+)(.*):$`", $var, $match)){ | |
| if(!empty($match[2])){ | |
| $active_submodule = $match[2]; | |
| } | |
| $tree[$active_module][$active_submodule] = array(); | |
| } | |
| else{ | |
| preg_match("`^(.*)$`", $var, $match); | |
| $tree[$match[1]] = array(); | |
| if(!empty($match[1])){ | |
| $active_module = $match[1]; | |
| } | |
| } | |
| } | |
| $bp = round(($CHARGE_INFORMATION_CHARGE_REMAINING__MAH_/$CHARGE_INFORMATION_FULL_CHARGE_CAPACITY__MAH_)*100, 2); | |
| $content = <<<CONTENTS | |
| #!/bin/bash | |
| NONE="\033[0m" # unsets color to term's fg color | |
| K="\033[0;30m" # black | |
| R="\033[0;31m" # red | |
| G="\033[0;32m" # green | |
| Y="\033[0;33m" # yellow | |
| B="\033[0;34m" # blue | |
| M="\033[0;35m" # magenta | |
| C="\033[0;36m" # cyan | |
| W="\033[0;37m" # white | |
| # emphasized (bolded) colors | |
| EMK="\033[1;30m" | |
| EMR="\033[1;31m" | |
| EMG="\033[1;32m" | |
| EMY="\033[1;33m" | |
| EMB="\033[1;34m" | |
| EMM="\033[1;35m" | |
| EMC="\033[1;36m" | |
| EMW="\033[1;37m" | |
| echo -e "$SYSTEM_SOFTWARE_OVERVIEW_SYSTEM_VERSION " | |
| echo -e "" | |
| echo -e "\${EMW}Network:\${NONE}" | |
| echo -e "\${EMG}Addresses\${W}: \${C}$IPV4_ADDRESSES\${NONE}" | |
| echo -e "\${EMG}Next-Hop\${W}: \${C}$IPV4_ROUTER\${NONE}" | |
| echo -e "\${EMG}DNS Servers\${W}: \${C}$DNS_SERVER_ADDRESSES\${NONE}" | |
| echo -e "\${EMG}$WI_FI_BSD_DEVICE_NAME\${W}: \${C}$WI_FI_IPV4_ADDRESSES\${NONE}" | |
| echo -e "\${EMG}Firewall\${W}: \${C}$FIREWALL_SETTINGS_MODE\${NONE}" | |
| exit | |
| CONTENTS; | |
| //echo -e "\${EMG}Total Memory\${W}: \${C}$(sysctrl -a | awk '/Memory:/ {print $10}')\${NONE}" | |
| echo $content; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment