diff --git a/package/DEBIAN/control b/package/DEBIAN/control index 18156c14..36786829 100644 --- a/package/DEBIAN/control +++ b/package/DEBIAN/control @@ -2,7 +2,7 @@ Package: hassbian-scripts Version: 0.9.1 Priority: optional Architecture: all -Depends: bash, wget, git, python3, python3-venv, python3-pip, python3-dev, bluetooth, libbluetooth-dev, avahi-daemon, build-essential, libssl-dev, libffi-dev, python-dev, libudev-dev +Depends: bash, wget, git, python3, python3-venv, python3-pip, python3-dev, bluetooth, libbluetooth-dev, avahi-daemon, build-essential, libssl-dev, libffi-dev, python-dev,libudev-dev, zip, nodejs, apt-transport-https, bluez-hcidump, bc, figlet Maintainer: Fredrik Lindqvist Homepage: www.home-assistant.io Description: Hassbian scripts diff --git a/package/etc/update-motd.d/10-display-hostname b/package/etc/update-motd.d/10-display-hostname new file mode 100755 index 00000000..c8260e9b --- /dev/null +++ b/package/etc/update-motd.d/10-display-hostname @@ -0,0 +1,6 @@ +#!/bin/bash + +/usr/bin/figlet "$(hostname)" + + + diff --git a/package/etc/update-motd.d/20-sysinfo b/package/etc/update-motd.d/20-sysinfo new file mode 100755 index 00000000..c5467cfa --- /dev/null +++ b/package/etc/update-motd.d/20-sysinfo @@ -0,0 +1,26 @@ +#!/bin/bash + +# get load averages +IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(/bin/cat /proc/loadavg | awk '{ print $1,$2,$3 }') +# get free memory +IFS=" " read USED FREE TOTAL <<<$(free -htm | grep "Mem" | awk {'print $3,$4,$2'}) +# get processes +PROCESS=`ps -eo user=|sort|uniq -c | awk '{ print $2 " " $1 }'` +PROCESS_ALL=`echo "$PROCESS"| awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'` +PROCESS_ROOT=`echo "$PROCESS"| grep root | awk {'print $2'}` +PROCESS_USER=`echo "$PROCESS"| grep -v root | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'` + +W="\e[0;39m" +G="\e[1;32m" + +echo -e " +${W}system info: +$W Distro......: $W`cat /etc/*release | grep "PRETTY_NAME" | cut -d "=" -f 2- | sed 's/"//g'` +$W Kernel......: $W`uname -sr` + +$W Uptime......: $W`uptime -p` +$W Load........: $G$LOAD1$W (1m), $G$LOAD5$W (5m), $G$LOAD15$W (15m) +$W Processes...:$W $G$PROCESS_ROOT$W (root), $G$PROCESS_USER$W (user) | $G$PROCESS_ALL$W (total) + +$W CPU.........: $W`cat /proc/cpuinfo | grep "model name" | cut -d ' ' -f3- | awk {'print $0'} | head -1` +$W Memory......: $G$USED$W used, $G$FREE$W free, $G$TOTAL$W in total$W" diff --git a/package/etc/update-motd.d/30-services b/package/etc/update-motd.d/30-services new file mode 100755 index 00000000..132358c2 --- /dev/null +++ b/package/etc/update-motd.d/30-services @@ -0,0 +1,34 @@ +#!/bin/bash + +# set column width +COLUMNS=3 +# colors +green="\e[1;32m" +red="\e[1;31m" +undim="\e[0m" + +services=("home-assistant@homeassistant") +# sort services +IFS=$'\n' services=($(sort <<<"${services[*]}")) +unset IFS + +service_status=() +# get status of all services +for service in "${services[@]}"; do + service_status+=($(systemctl is-active "$service")) +done + +out="" +for i in ${!services[@]}; do + # color green if service is active, else red + if [[ "${service_status[$i]}" == "active" ]]; then + out+="${services[$i]}:,${green}${service_status[$i]}${undim}\\n" + else + out+="${services[$i]}:,${red}${service_status[$i]}${undim}\\n" + fi + # insert \n every $COLUMNS column +done +out+="\n" + +printf "\nservices:\n" +printf "$out" | column -ts $',' | sed -e 's/^/ /'