Update init.old, motd.sh, and check.sh
This commit is contained in:
parent
fb1b27d06e
commit
55dd5264df
|
@ -0,0 +1,113 @@
|
|||
# Variables
|
||||
|
||||
# Repo that contains all relevant scripts
|
||||
REPO="https://raw.githubusercontent.com/aamnah/raspberrypi/master/"
|
||||
|
||||
# Location to save scripts to
|
||||
SCRIPTS_PATH="/usr/local/bin/"
|
||||
|
||||
# Temporary Directory
|
||||
TMP="/var/tmp/"
|
||||
|
||||
# Bash Profile
|
||||
##############
|
||||
# copy the bash profile from Github and overwrite the existing one
|
||||
|
||||
bashrc() {
|
||||
curl -s ${REPO}.bashrc > ~/.bashrc
|
||||
}
|
||||
|
||||
# HOSTNAME
|
||||
##########
|
||||
# Your current hostname is:
|
||||
# hostname
|
||||
# Would you like to update it? (y/n)
|
||||
# if y
|
||||
# take NEW_HOSTNAME
|
||||
# sudo hostname NEW_HOSTNAME
|
||||
|
||||
|
||||
# MOTD
|
||||
######
|
||||
motd() {
|
||||
read -p "Set up MOTD? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
# download and save motd file
|
||||
sudo wget ${REPO}motd.sh -O /etc/profile.d/motd.sh
|
||||
# owner
|
||||
sudo chown root:root /etc/profile.d/motd.sh
|
||||
# permissions
|
||||
sudo chmod +x /etc/profile.d/motd.sh
|
||||
# delete default motd
|
||||
sudo rm /etc/motd
|
||||
|
||||
elif [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# GPIO
|
||||
#######
|
||||
gpio() {
|
||||
read -p "Set up GPIO shortcuts? (y/n) " -n 1 -r
|
||||
echo # (optional) move to a new line
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
sudo wget ${REPO}gpio.py -O ${SCRIPTS_PATH}gpio.py
|
||||
sudo chmod +x ${SCRIPTS_PATH}gpio.py
|
||||
elif [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Imgact
|
||||
########
|
||||
imgcat() {
|
||||
read -p "Set up imgcat for previewing images in Terminal? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
sudo wget https://raw.githubusercontent.com/gnachman/iTerm2/master/tests/imgcat -O ${SCRIPTS_PATH}imgcat.sh
|
||||
sudo chmod +x ${SCRIPTS_PATH}imgcat.sh
|
||||
elif [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Bash Aliases
|
||||
aliases() {
|
||||
echo "
|
||||
# GPIO
|
||||
alias gpio='gpio.py'
|
||||
# imgcat
|
||||
alias imgcat='imgcat.sh'
|
||||
" >> ~/.bashrc
|
||||
}
|
||||
# Reload settings / files
|
||||
#########################
|
||||
reload() {
|
||||
source ~/.bashrc
|
||||
sudo service ssh restart
|
||||
# Empty Temp dir?
|
||||
}
|
||||
|
||||
|
||||
# apache
|
||||
|
||||
|
||||
|
||||
bashrc
|
||||
motd
|
||||
gpio
|
||||
imgcat
|
||||
aliases
|
||||
|
||||
echo "Reloadig.. "
|
||||
reload
|
||||
|
||||
echo "All done. Enjoy!"
|
|
@ -1,31 +1,34 @@
|
|||
# Message Of The Day
|
||||
# IP Address
|
||||
# IP=`ifconfig wlan0 | grep "inet addr" | cut -d ":" -f 2 | cut -d " " -f 1`
|
||||
clear
|
||||
echo "$(tput bold)$(tput setaf 2)"
|
||||
echo " .~~. .~~. "
|
||||
echo " '. \ ' ' / .' "
|
||||
echo "$(tput setaf 1)"
|
||||
echo " .~ .~~~..~. "
|
||||
echo " : .~.'~'.~. : "
|
||||
echo " ~ ( ) ( ) ~ "
|
||||
echo " ( : '~'.~.'~' : )"
|
||||
echo " ~ .~ ( ) ~. ~ "
|
||||
echo " ( : '~' : ) "
|
||||
echo " '~ .~~~. ~' "
|
||||
echo " '~' "
|
||||
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
|
||||
let secs=$((${upSeconds}%60))
|
||||
let mins=$((${upSeconds}/60%60))
|
||||
let hours=$((${upSeconds}/3600%24))
|
||||
let days=$((${upSeconds}/86400))
|
||||
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
|
||||
|
||||
IP=`hostname -I`;
|
||||
EXT_IP=`wget -q -O - http://icanhazip.com/ | tail`;
|
||||
RASPI_MODEL=`dmesg | grep "Machine model:" | cut -d ":" -f 2`;
|
||||
# get the load averages
|
||||
read one five fifteen rest < /proc/loadavg
|
||||
|
||||
welcome() {
|
||||
echo "Bonjour!";
|
||||
}
|
||||
echo "$(tput setaf 2)
|
||||
`date +"%A, %e %B %Y, %r"`
|
||||
`uname -srmo`
|
||||
|
||||
# Identify Pi version
|
||||
# http://elinux.org/RPi_HardwareHistory
|
||||
|
||||
version() {
|
||||
echo "This is a" ${RASPI_MODEL};
|
||||
}
|
||||
|
||||
# Show internal and external IP address
|
||||
|
||||
ip() {
|
||||
echo ${IP};
|
||||
echo ${EXT_IP};
|
||||
}
|
||||
|
||||
# Execute
|
||||
welcome
|
||||
version
|
||||
ip
|
||||
$(tput sgr0)- Uptime.............: ${UPTIME}
|
||||
$(tput sgr0)- Memory.............: `free | grep Mem | awk '{print $3/1024}'` MB (Used) / `cat /proc/meminfo | grep MemTotal | awk {'print $2/1024'}` MB (Total)
|
||||
$(tput sgr0)- Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
|
||||
$(tput sgr0)- Running Processes..: `ps ax | wc -l | tr -d " "`
|
||||
$(tput sgr0)- IP Addresses.......: `hostname -I | /usr/bin/cut -d " " -f 1` and `wget -q -O - https://checkip.amazonaws.com/ | tail`
|
||||
|
||||
$(tput sgr0)"
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
export TERM=xterm-256color
|
||||
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
|
||||
let secs=$((${upSeconds}%60))
|
||||
let mins=$((${upSeconds}/60%60))
|
||||
let hours=$((${upSeconds}/3600%24))
|
||||
let days=$((${upSeconds}/86400))
|
||||
UPTIME=`printf "%d days, %02dh %02dm %02ds" "$days" "$hours" "$mins" "$secs"`
|
||||
|
||||
# get the load averages read one five fifteen
|
||||
rest < /proc/loadavg
|
||||
|
||||
echo "$(tput setaf 2)
|
||||
.~~. .~~. $(tput sgr0)`date +"%A, %e %B %Y, %r"`$(tput setaf 2)
|
||||
'. \ ' ' / .' $(tput sgr0)`uname -snrmo`$(tput setaf 1)
|
||||
.~ .~~~..~.
|
||||
: .~.'~'.~. : $(tput sgr0)Uptime.............: ${UPTIME}$(tput setaf 1)
|
||||
~ ( ) ( ) ~ $(tput sgr0)Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)$(tput setaf 1)
|
||||
( : '~'.~.'~' : ) $(tput sgr0)Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)$(tput setaf 1)
|
||||
~ .~ ( ) ~. ~ $(tput sgr0)Running Processes..: `ps ax | wc -l | tr -d " "`$(tput setaf 1)
|
||||
( : '~' : ) $(tput sgr0)Free Disk Space....: `df -Pk | grep -E '^/dev/root' | awk '{ print $4 }'`k (`df -Pk | grep -E '^/dev/root' | awk '{ print $5 }'` used) on /dev/root$(tput setaf 1)
|
||||
'~ .~~~. ~' $(tput sgr0)IP Addresses.......: LAN: `/sbin/ifconfig eth0 | /bin/grep "inet " | awk '{ print $2 }'` WAN: `wget -q -O - http://icanhazip.com/ | tail`$(tput setaf 1)
|
||||
'~' $(tput sgr0)Victoria weather...: `curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EN|CA|VICTORIA" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'`
|
||||
|
||||
|
Loading…
Reference in New Issue