From 36b3d97bc497b8037f1e0994e22bd01a2d35921c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 1 Jan 2019 06:15:44 -0800 Subject: [PATCH] misc files I had laying around --- 30-armbian-sysinfo | 194 +++++++++++++++++++++++++++++++++++++++++++++ i2c-detect.output | 30 +++++++ orig.lightdm.conf | 175 ++++++++++++++++++++++++++++++++++++++++ reflash-uboot.sh | 3 + 4 files changed, 402 insertions(+) create mode 100755 30-armbian-sysinfo create mode 100644 i2c-detect.output create mode 100644 orig.lightdm.conf create mode 100755 reflash-uboot.sh diff --git a/30-armbian-sysinfo b/30-armbian-sysinfo new file mode 100755 index 0000000..22db3bd --- /dev/null +++ b/30-armbian-sysinfo @@ -0,0 +1,194 @@ +#!/bin/bash +# +# Copyright (c) Authors: http://www.armbian.com/authors +# +# This file is licensed under the terms of the GNU General Public +# License version 2. This program is licensed "as is" without any +# warranty of any kind, whether express or implied. +# + +# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd +# generate system information + +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +THIS_SCRIPT="sysinfo" +MOTD_DISABLE="" +STORAGE=/dev/sda1 +SHOW_IP_PATTERN="^[ewr].*|^br.*|^lt.*|^umts.*" + +[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd + +for f in $MOTD_DISABLE; do + [[ $f == $THIS_SCRIPT ]] && exit 0 +done + +# don't edit below here + +function display() { + # $1=name $2=value $3=red_limit $4=minimal_show_limit $5=unit $6=after $7=acs/desc{ + # battery red color is opposite, lower number + if [[ "$1" == "Battery" ]]; then local great="<"; else local great=">"; fi + if [[ -n "$2" && "$2" > "0" && (( "${2%.*}" -ge "$4" )) ]]; then + printf "%-14s%s" "$1:" + if awk "BEGIN{exit ! ($2 $great $3)}"; then echo -ne "\e[0;91m $2"; else echo -ne "\e[0;92m $2"; fi + printf "%-1s%s\x1B[0m" "$5" + printf "%-11s%s\t" "$6" + return 1 + fi +} # display + +function getboardtemp() { + if [ -f /etc/armbianmonitor/datasources/soctemp ]; then + read raw_temp /dev/null + if [ ! -z $(echo "$raw_temp" | grep -o "^[1-9][0-9]*\.\?[0-9]*$") ] && (( $(echo "${raw_temp} < 200" |bc -l) )); then + # Allwinner legacy kernels output degree C + board_temp=${raw_temp} + else + # Marvell gets special treatment for whatever reasons + grep -qi Marvell /proc/cpuinfo && \ + board_temp=$(( $(awk '{printf("%d",$1/1000)}' <<<${raw_temp}) - 20 )) || \ + board_temp=$(awk '{printf("%d",$1/1000)}' <<<${raw_temp}) + fi + elif [ -f /etc/armbianmonitor/datasources/pmictemp ]; then + # fallback to PMIC temperature + board_temp=$(awk '{printf("%d",$1/1000)}' /dev/null) + case ${amb_temp} in + *"find the USB device"*) + echo "" + ;; + *) + amb_temp=$(awk '{print $NF}' <<<$amb_temp | sed 's/C//g') + echo -n "scale=1;${amb_temp}/1" | grep -oE "\-?[[:digit:]]+\.[[:digit:]]" + esac +} # ambienttemp + +#function get_ip_addresses() { +# # return up to 2 IPv4 address(es) comma separated +# hostname -I | tr " " "\n" | \ +# grep -E "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" | \ +# tail -n2 | sed ':a;N;$!ba;s/\n/,/g' +#} # get_ip_addresses + +function get_ip_addresses() { + local ips=() + for f in /sys/class/net/*; do + local intf=$(basename $f) + # match only interface names starting with e (Ethernet), br (bridge), w (wireless), r (some Ralink drivers use ra format) + if [[ $intf =~ $SHOW_IP_PATTERN ]]; then + local tmp=$(ip -4 addr show dev $intf | awk '/inet/ {print $2}' | cut -d'/' -f1) + # add both name and IP - can be informative but becomes ugly with long persistent/predictable device names + #[[ -n $tmp ]] && ips+=("$intf: $tmp") + # add IP only + [[ -n $tmp ]] && ips+=("$tmp") + fi + done + echo "${ips[@]}" +} # get_ip_addresses + +function storage_info() { + # storage info + RootInfo=$(df -h /) + root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g') + root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo}) + StorageInfo=$(df -h $STORAGE 2>/dev/null | grep $STORAGE) + if [[ -n "${StorageInfo}" && ${RootInfo} != *$STORAGE* ]]; then + storage_usage=$(awk '/\// {print $(NF-1)}' <<<${StorageInfo} | sed 's/%//g') + storage_total=$(awk '/\// {print $(NF-4)}' <<<${StorageInfo}) + fi +} # storage_info + +# query various systems and send some stuff to the background for overall faster execution. +# Works only with ambienttemp and batteryinfo since A20 is slow enough :) +amb_temp=$(ambienttemp &) +ip_address=$(get_ip_addresses &) +batteryinfo +storage_info +getboardtemp +critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 )) + +# get uptime, logged in users and load in one take +UptimeString=$(uptime | tr -d ',') +time=$(awk -F" " '{print $3" "$4}' <<<"${UptimeString}") +load="$(awk -F"average: " '{print $2}'<<<"${UptimeString}")" +users="$(awk -F" user" '{print $1}'<<<"${UptimeString}")" +case ${time} in + 1:*) # 1-2 hours + time=$(awk -F" " '{print $3" hour"}' <<<"${UptimeString}") + ;; + *:*) # 2-24 hours + time=$(awk -F" " '{print $3" hours"}' <<<"${UptimeString}") + ;; +esac + +# memory and swap +mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem") +memory_usage=$(awk '{printf("%.0f",(($2-($4+$6+$7))/$2) * 100)}' <<<${mem_info}) +memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info}) +swap_info=$(LC_ALL=C free -m | grep "^Swap") +swap_usage=$( (awk '/Swap/ { printf("%3.0f", $3/$2*100) }' <<<${swap_info} 2>/dev/null || echo 0) | tr -c -d '[:digit:]') +swap_total=$(awk '{print $(2)}' <<<${swap_info}) + +# display info +display "System load" "${load%% *}" "${critical_load}" "0" "" "${load#* }" +printf "Up time: \x1B[92m%s\x1B[0m\t\t" "$time" +display "Local users" "${users##* }" "3" "2" "" +echo "" # fixed newline +display "Memory usage" "$memory_usage" "70" "0" " %" " of ${memory_total}MB" +display "Zram usage" "$swap_usage" "75" "0" " %" " of $swap_total""Mb" +printf "IP: " +printf "\x1B[92m%s\x1B[0m" "$ip_address" +echo "" # fixed newline +a=0;b=0;c=0 +display "CPU temp" "$board_temp" "45" "0" "°C" "" ; a=$? +display "Ambient temp" "$amb_temp" "40" "0" "°C" "" ; b=$? +(( ($a+$b) >0 )) && echo "" # new line only if some value is displayed +display "Usage of /" "$root_usage" "90" "1" "%" " of $root_total" +display "storage/" "$storage_usage" "90" "1" "%" " of $storage_total" +display "Battery" "$battery_percent" "20" "1" "%" "$status_battery_text" +echo "" +echo "" diff --git a/i2c-detect.output b/i2c-detect.output new file mode 100644 index 0000000..7d4bdb5 --- /dev/null +++ b/i2c-detect.output @@ -0,0 +1,30 @@ +root@witbook:~# i2cdetect 1 +WARNING! This program can confuse your I2C bus, cause data loss and worse! +I will probe file /dev/i2c-1. +I will probe address range 0x03-0x77. +Continue? [Y/n] y + 0 1 2 3 4 5 6 7 8 9 a b c d e f +00: -- -- -- -- -- -- -- -- -- -- -- -- -- +10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +30: 30 31 32 33 34 35 36 37 -- -- -- -- -- -- -- -- +40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f +60: 60 61 62 63 64 65 66 67 -- -- -- -- -- -- -- -- +70: -- -- -- -- -- -- -- -- +root@witbook:~# i2cdetect 0 +WARNING! This program can confuse your I2C bus, cause data loss and worse! +I will probe file /dev/i2c-0. +I will probe address range 0x03-0x77. +Continue? [Y/n] y + 0 1 2 3 4 5 6 7 8 9 a b c d e f +00: -- -- -- -- -- -- -- -- -- -- -- -- -- +10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +30: -- -- -- -- -- -- -- -- UU UU -- -- -- 3d -- -- +40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +70: -- -- -- -- -- -- -- -- +root@witbook:~# + diff --git a/orig.lightdm.conf b/orig.lightdm.conf new file mode 100644 index 0000000..edb6c0f --- /dev/null +++ b/orig.lightdm.conf @@ -0,0 +1,175 @@ +# +# General configuration +# +# start-default-seat = True to always start one seat if none are defined in the configuration +# greeter-user = User to run greeter as +# minimum-display-number = Minimum display number to use for X servers +# minimum-vt = First VT to run displays on +# lock-memory = True to prevent memory from being paged to disk +# user-authority-in-system-dir = True if session authority should be in the system location +# guest-account-script = Script to be run to setup guest account +# logind-check-graphical = True to on start seats that are marked as graphical by logind +# log-directory = Directory to log information to +# run-directory = Directory to put running state in +# cache-directory = Directory to cache to +# sessions-directory = Directory to find sessions +# remote-sessions-directory = Directory to find remote sessions +# greeters-directory = Directory to find greeters +# backup-logs = True to move add a .old suffix to old log files when opening new ones +# dbus-service = True if LightDM provides a D-Bus service to control it +# +[LightDM] + +[SeatDefaults] +autologin-user=jcarr +autologin-user-timeout=0 +user-session=default + +#start-default-seat=true +#greeter-user=lightdm +#minimum-display-number=0 +#minimum-vt=7 +#lock-memory=true +#user-authority-in-system-dir=false +#guest-account-script=guest-account +#logind-check-graphical=false +#log-directory=/var/log/lightdm +#run-directory=/var/run/lightdm +#cache-directory=/var/cache/lightdm +#sessions-directory=/usr/share/lightdm/sessions:/usr/share/xsessions:/usr/share/wayland-sessions +#remote-sessions-directory=/usr/share/lightdm/remote-sessions +#greeters-directory=$XDG_DATA_DIRS/lightdm/greeters:$XDG_DATA_DIRS/xgreeters +#backup-logs=true +#dbus-service=true + +# +# Seat configuration +# +# Seat configuration is matched against the seat name glob in the section, for example: +# [Seat:*] matches all seats and is applied first. +# [Seat:seat0] matches the seat named "seat0". +# [Seat:seat-thin-client*] matches all seats that have names that start with "seat-thin-client". +# +# type = Seat type (local, xremote, unity) +# pam-service = PAM service to use for login +# pam-autologin-service = PAM service to use for autologin +# pam-greeter-service = PAM service to use for greeters +# xserver-backend = X backend to use (mir) +# xserver-command = X server command to run (can also contain arguments e.g. X -special-option) +# xmir-command = Xmir server command to run (can also contain arguments e.g. Xmir -special-option) +# xserver-config = Config file to pass to X server +# xserver-layout = Layout to pass to X server +# xserver-allow-tcp = True if TCP/IP connections are allowed to this X server +# xserver-share = True if the X server is shared for both greeter and session +# xserver-hostname = Hostname of X server (only for type=xremote) +# xserver-display-number = Display number of X server (only for type=xremote) +# xdmcp-manager = XDMCP manager to connect to (implies xserver-allow-tcp=true) +# xdmcp-port = XDMCP UDP/IP port to communicate on +# xdmcp-key = Authentication key to use for XDM-AUTHENTICATION-1 (stored in keys.conf) +# unity-compositor-command = Unity compositor command to run (can also contain arguments e.g. unity-system-compositor -special-option) +# unity-compositor-timeout = Number of seconds to wait for compositor to start +# greeter-session = Session to load for greeter +# greeter-hide-users = True to hide the user list +# greeter-allow-guest = True if the greeter should show a guest login option +# greeter-show-manual-login = True if the greeter should offer a manual login option +# greeter-show-remote-login = True if the greeter should offer a remote login option +# user-session = Session to load for users +# allow-user-switching = True if allowed to switch users +# allow-guest = True if guest login is allowed +# guest-session = Session to load for guests (overrides user-session) +# session-wrapper = Wrapper script to run session with +# greeter-wrapper = Wrapper script to run greeter with +# guest-wrapper = Wrapper script to run guest sessions with +# display-setup-script = Script to run when starting a greeter session (runs as root) +# display-stopped-script = Script to run after stopping the display server (runs as root) +# greeter-setup-script = Script to run when starting a greeter (runs as root) +# session-setup-script = Script to run when starting a user session (runs as root) +# session-cleanup-script = Script to run when quitting a user session (runs as root) +# autologin-guest = True to log in as guest by default +# autologin-user = User to log in with by default (overrides autologin-guest) +# autologin-user-timeout = Number of seconds to wait before loading default user +# autologin-session = Session to load for automatic login (overrides user-session) +# autologin-in-background = True if autologin session should not be immediately activated +# exit-on-failure = True if the daemon should exit if this seat fails +# +[Seat:*] +#type=local +#pam-service=lightdm +#pam-autologin-service=lightdm-autologin +#pam-greeter-service=lightdm-greeter +#xserver-backend= +#xserver-command=X +#xmir-command=Xmir +#xserver-config= +#xserver-layout= +#xserver-allow-tcp=false +#xserver-share=true +#xserver-hostname= +#xserver-display-number= +#xdmcp-manager= +#xdmcp-port=177 +#xdmcp-key= +#unity-compositor-command=unity-system-compositor +#unity-compositor-timeout=60 +#greeter-session=example-gtk-gnome +#greeter-hide-users=false +#greeter-allow-guest=true +#greeter-show-manual-login=false +#greeter-show-remote-login=true +#user-session=default +#allow-user-switching=true +#allow-guest=true +#guest-session= +#session-wrapper=lightdm-session +#greeter-wrapper= +#guest-wrapper= +#display-setup-script= +#display-stopped-script= +#greeter-setup-script= +#session-setup-script= +#session-cleanup-script= +#autologin-guest=false +#autologin-user= +#autologin-user-timeout=0 +#autologin-in-background=false +#autologin-session= +#exit-on-failure=false + +# +# XDMCP Server configuration +# +# enabled = True if XDMCP connections should be allowed +# port = UDP/IP port to listen for connections on +# listen-address = Host/address to listen for XDMCP connections (use all addresses if not present) +# key = Authentication key to use for XDM-AUTHENTICATION-1 or blank to not use authentication (stored in keys.conf) +# hostname = Hostname to report to XDMCP clients (defaults to system hostname if unset) +# +# The authentication key is a 56 bit DES key specified in hex as 0xnnnnnnnnnnnnnn. Alternatively +# it can be a word and the first 7 characters are used as the key. +# +[XDMCPServer] +#enabled=false +#port=177 +#listen-address= +#key= +#hostname= + +# +# VNC Server configuration +# +# enabled = True if VNC connections should be allowed +# command = Command to run Xvnc server with +# port = TCP/IP port to listen for connections on +# listen-address = Host/address to listen for VNC connections (use all addresses if not present) +# width = Width of display to use +# height = Height of display to use +# depth = Color depth of display to use +# +[VNCServer] +#enabled=false +#command=Xvnc +#port=5900 +#listen-address= +#width=1024 +#height=768 +#depth=8 diff --git a/reflash-uboot.sh b/reflash-uboot.sh new file mode 100755 index 0000000..095223e --- /dev/null +++ b/reflash-uboot.sh @@ -0,0 +1,3 @@ +#!/bin/bash -x + +dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1K seek=8