This repository has been archived by the owner on Oct 30, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 97
Add MOTD to the Hassbian image #201
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
574f56c
Add MOTD base on the work of @yboetz
Landrash c494af6
Correct dependency
Landrash 7e4b03e
Update package/etc/update-motd.d/30-services
ludeeus b683789
Update package/etc/update-motd.d/30-services
ludeeus 36900b5
Update package/etc/update-motd.d/30-services
ludeeus 30e5ac9
Update package/etc/update-motd.d/30-services
ludeeus 4f01262
Update package/etc/update-motd.d/30-services
ludeeus 3b2500c
revert version change
Landrash 988478d
Merge branch 'motd' of github.com:home-assistant/hassbian-scripts int…
Landrash 274ee4a
Update package/etc/update-motd.d/30-services
ludeeus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
/usr/bin/figlet "$(hostname)" | ||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# set column width | ||
COLUMNS=3 | ||
# colors | ||
green="\e[1;32m" | ||
red="\e[1;31m" | ||
undim="\e[0m" | ||
|
||
services=("appdaemon@homeassistant" "home-assistant@homeassistant" "mosquitto") | ||
Landrash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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}," | ||
Landrash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
out+="${services[$i]}:,${red}${service_status[$i]}${undim}," | ||
Landrash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fi | ||
# insert \n every $COLUMNS column | ||
if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then | ||
Landrash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
out+="\n" | ||
Landrash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fi | ||
Landrash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
done | ||
out+="\n" | ||
|
||
printf "\nservices:\n" | ||
printf "$out" | column -ts $',' | sed -e 's/^/ /' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this change intentional?