Last active
July 16, 2019 02:06
-
-
Save mrnohr/1d0094187d4b34f99193182b549dadcf to your computer and use it in GitHub Desktop.
Raspberry Pi Message of the Day mod
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
#!/bin/sh | |
# | |
# 00-header - create the header of the MOTD | |
# Copyright (c) 2013 Nick Charlton | |
# Copyright (c) 2009-2010 Canonical Ltd. | |
# | |
# Authors: Nick Charlton <[email protected]> | |
# Dustin Kirkland <[email protected]> | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License along | |
# with this program; if not, write to the Free Software Foundation, Inc., | |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
[ -r /etc/lsb-release ] && . /etc/lsb-release | |
if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then | |
# Fall back to using the very slow lsb_release utility | |
DISTRIB_DESCRIPTION=$(lsb_release -s -d) | |
fi | |
figlet -c -w 50 $(hostname) | |
printf "\n" | |
printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)" | |
printf "\n" |
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
#!/bin/bash | |
# | |
# 10-sysinfo - generate the system information | |
# Copyright (c) 2013 Nick Charlton | |
# | |
# Authors: Nick Charlton <[email protected]> | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License along | |
# with this program; if not, write to the Free Software Foundation, Inc., | |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
date=`date` | |
load=`cat /proc/loadavg | awk '{print $1}'` | |
root_usage=`df -h / | awk '/\// {print $(NF-1)}'` | |
memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'` | |
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", "exit !$2;$3/$2*100") }'` | |
users=`users | wc -w` | |
time=`uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{ printf $2" "$3 }'` | |
processes=`ps aux | wc -l` | |
ip=`ifconfig $(route | grep default | awk '{ print $8 }') | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'` | |
totalMemory=`df -h | grep "/dev/root" | awk {'print $2'}` | |
usedMemory=`df -h | grep "/dev/root" | awk {'print $3'}` | |
COL='\033[1;34m' # Color | |
NC='\033[0m' # No Color | |
printf "System load:\t${COL}%s${NC}\tIP Address:\t${COL}%s${NC}\n" $load $ip | |
printf "Memory usage:\t${COL}%s${NC}\tSystem uptime:\t${COL}%s${NC}\n" $memory_usage "$time" | |
printf "Memory Usage:\t${COL}%s${NC}\tSwap usage:\t${COL}%s${NC}\n" $root_usage $swap_usage | |
printf "Total Memory:\t${COL}%s${NC}\tUsed Memory:\t${COL}%s${NC}\n" $totalMemory $usedMemory | |
printf "Local Users:\t${COL}%s${NC}\tProcesses:\t${COL}%s${NC}\n" $users $processes | |
echo | |
# /usr/lib/update-notifier/apt-check --human-readable | |
# /usr/lib/update-notifier/update-motd-reboot-required | |
# echo |
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
#!/bin/bash | |
# | |
# 20-pihole - generate information about PiHole | |
# Copyright (c) 2017 Matt Nohr | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License along | |
# with this program; if not, write to the Free Software Foundation, Inc., | |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
stats=$(curl -s localhost/admin/api.php) | |
domains_blocked=$(echo "$stats" | jq .domains_being_blocked) | |
percent_blocked=$(echo "$stats" | jq .ads_percentage_today) | |
queries_today=$(echo "$stats" | jq .dns_queries_today) | |
blocked_today=$(echo "$stats" | jq .ads_blocked_today) | |
COL='\033[0;36m' # Color | |
NC='\033[0m' # No Color | |
printf "PiHole Status:\n\n" | |
pihole status | cut -c5- | |
printf "Blocked:\t${COL}%s%%${NC}\tTotal Domains:\t${COL}%s${NC}\n" $percent_blocked $domains_blocked | |
printf "Queries Today:\t${COL}%s${NC}\tBlocked Today:\t${COL}%s${NC}\n" $queries_today $blocked_today | |
echo |
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
# install lsb-release | |
sudo apt-get install lsb-release | |
# install figlet to enable ASCII art | |
sudo apt-get install figlet | |
# create directory | |
mkdir /etc/update-motd.d/ | |
# change to new directory | |
cd /etc/update-motd.d/ | |
# create dynamic files | |
touch 00-header && touch 10-sysinfo && touch 90-footer | |
# make files executable | |
chmod +x /etc/update-motd.d/* | |
# remove MOTD file | |
rm /etc/motd | |
# symlink dynamic MOTD file | |
ln -s /var/run/motd /etc/motd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment