Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

Raspberry Pi SSH


#!/bin/bash
# Filename: motd.sh
# Version : 23072017
# Author  : robz
# Raspberry Pi landing page SSH login script.
# Place this file in /etc/profile.d/ and set the executable bit.
# Interactive message of the day to display on secure shell login.
# It provides commands for control of "new-pvr.sh" PVR script.
# Add an alias to your .bashrc to call "motd.sh" info and menu.
# alias 1='/etc/profile.d/motd.sh'
# Then execute ". ~/.bashrc"

sudo killall -qg countLED.sh >/dev/null 2>&1

printf "\033c"
re="$(tput setaf 1)"; gr="$(tput setaf 2)"; ye="$(tput setaf 3)"
bl="$(tput setaf 4)"; mg="$(tput setaf 5)"; cy="$(tput setaf 6)"
gy="$(tput setaf 7)"; wh="$(tput setaf 9)"
myip="$(ifconfig eth0 | awk '/inet/{print $2}' | cut -d: -f2)"
boot="$(date -d "@"$(awk '/btime/{print $2}' /proc/stat) +"%d/%m/%y at %H:%M")"
last="$(last -i $(whoami) | awk 'NR==2 {print $1,$3,$4,$5,$6,$7}')"
uptm="$(awk '{print int($1/86400)" days, "int($1%86400/3600)" hours, "int($1%3600/60)" minutes"}' /proc/uptime)"
memo="$(free -m | awk 'NR==2 {print "Total: "$2"MB, Used: "$3"MB, Free: "$4"MB"}')"
free="$(df -h ~ | awk 'NR==2 {print "Total: "$2"B, Used: "$3"B, Free: "$4"B"}')"
stor="$(df -h /dev/sda1 | awk 'NR==2 {print "Total: "$2"B, Used: "$3"B, Free: "$4"B"}')"
temp="$(/opt/vc/bin/vcgencmd measure_temp | cut -c "6-9")ÂșC"
sess="$(cat /home/pi/Downloads/log/motd.txt)"
tput bold
printf "$bl""%`tput cols`s" | tr ' ' '_'
echo "$gr
    .~~.   .~~.
   '. \ ' ' / .'  $re
    .~ .~~~..~.   $re     Raspberry Pi$wh Torrent Box$re
   : .~.'~'.~. :  $wh     a.k.a. pi@$myip$re
  ~ (   ) (   ) ~ $wh     on robz home network.$re
 ( : '~'.~.'~' : )$wh     Welcome back! login: $(whoami)$re
  ~ .~ (   ) ~. ~ $wh     $(date +"%A %d %b %Y %H:%M")$re
   (  : '~' :  )  $wh     $(echo Kernel $(uname -ro))$re
    '~ .~~~. ~'
        '~'
$ye Last Login....:$bl $last
$ye Last boot.....:$bl $boot
$ye Uptime........:$bl $uptm
$ye Memory........:$bl $memo
$ye Home space....:$bl $free
$ye USB storage...:$bl $stor
$ye Temperature...:$bl $temp
"
tput sgr0
echo "$wh$sess"
echo
echo -e " User PVR commands, the \"#\" or \"Enter\" for a shell prompt.\n\
 1) - Display this \"motd\" message. \
 2) - Nano edit add-magnet.txt.\n\
 3) - View today's session log.    \
 4) - Nano edit followed-shows.txt.\n\
 5) - List recently downloaded.    \
 6) - List the \"Watch\" directory.\n\
 7) - View rss-today.txt file.     \
 8) - Run \"TED Talks\" downloader."

tput bold
printf "$bl""%`tput cols`s" | tr ' ' '_'
read -n1 n
printf "\033c"
case $n in
    1) /etc/profile.d/motd.sh;;
    2) nano ~/Downloads/scripts/add-magnet.txt;;
    3) cat ~/Downloads/log/"$(date +%a-%-d%b)"*runlog.txt; read -n1;;
    4) nano ~/Downloads/scripts/followed-shows.txt;;
    5) echo -e "\nRecently Downloaded\n"
    tac ~/Downloads/log/rec.txt; read -n1;;
    6) echo -e "\nTrackers in \"Watch\" directory\n"
    ls Downloads/Watch; read -n1;;
    7) cat ~/Downloads/log/rss-today.txt; read -n1;;
    8) /home/pi/Downloads/scripts/ted-talks.sh; read -n1;;
   "") killall motd.sh;;
esac
/etc/profile.d/motd.sh

# Add this alias to your .bashrc to call "motd.sh" info and menu.
# alias 1='/etc/profile.d/motd.sh'
# Then execute ". ~/.bashrc"


No comments: