Changing colors configuration to more general, little bit more informational usage help

master
Mateusz Chochół 7 years ago
parent f2456e5281
commit c065a23e30
  1. 42
      bmotd.sh

@ -1,14 +1,15 @@
#!/bin/bash #!/bin/bash
#
#
#
# Config # Config
MOTD="/etc/motd2" MOTD="/etc/motd2"
INSTPATH="/etc/bmotd.sh" INSTPATH="/etc/bmotd.sh"
CACHEPATH="/var/cache/bmotd" CACHEPATH="/var/cache/bmotd"
# Check if root
# The different colours as variables
C1="\033[01;35m" # Purple
C2="\033[00;92m" # Green
C3="\033[01;97m" # White
X="\033[00;0m" # Reset
main () { main () {
# print help # print help
@ -104,7 +105,7 @@ update() {
} }
function printHelp { function printHelp {
printf "HALP" printf "./$0 update | disable | enable"
exit 0; exit 0;
} }
@ -252,15 +253,8 @@ function isRoot() {
} }
motdGen() { motdGen() {
# The different colours as variables
W="\033[01;97m"
G="\033[00;92m"
R="\033[01;31m"
P="\033[01;35m"
X="\033[00;0m"
# Collect useful information about your system # Collect useful information about your system
LASTLOGIN="$(date --date "$(lastlog -u $USER | tail -n 1 | tr -s ' ' | cut -d" " -f4-)" "+%a %e %b %Y, %H:%M:%S")$W from$P $(lastlog -u $USER | tail -n 1 | tr -s ' ' | cut -d" " -f3)" LASTLOGIN="$(date --date "$(lastlog -u $USER | tail -n 1 | tr -s ' ' | cut -d" " -f4-)" "+%a %e %b %Y, %H:%M:%S")$C3 from$C1 $(lastlog -u $USER | tail -n 1 | tr -s ' ' | cut -d" " -f3)"
UPTIME_EXT=`uptime | sed -n 's/^.*\(up.*\),[0-9 ]*user.*\(load average.*\)/\1, \2/p'` UPTIME_EXT=`uptime | sed -n 's/^.*\(up.*\),[0-9 ]*user.*\(load average.*\)/\1, \2/p'`
@ -271,23 +265,23 @@ motdGen() {
command -v ip >/dev/null 2>&1 || parse_ifconfig command -v ip >/dev/null 2>&1 || parse_ifconfig
clear > $MOTD # to clear the screen when showing up clear > $MOTD # to clear the screen when showing up
echo -e "$G" >> $MOTD echo -e "$C2" >> $MOTD
prettyPrint $HOSTNAME >> $MOTD prettyPrint $HOSTNAME >> $MOTD
echo -e " $W$LBT" >> $MOTD echo -e " $C3$LBT" >> $MOTD
echo -e " $W$G • FQDN...............$W: $P $FQDN" >> $MOTD echo -e " $C3$C2 • FQDN...............$C3: $C1 $FQDN" >> $MOTD
echo -e " $W$G • Last Login.........$W: $P $LASTLOGIN" >> $MOTD echo -e " $C3$C2 • Last Login.........$C3: $C1 $LASTLOGIN" >> $MOTD
echo -e " $W$G • Pkg to update......$W: $P $PKG_NU" >> $MOTD echo -e " $C3$C2 • Pkg to update......$C3: $C1 $PKG_NU" >> $MOTD
echo -e " $W$G • Uptime,Load........$W: $P $UPTIME_EXT" >> $MOTD echo -e " $C3$C2 • Uptime,Load........$C3: $C1 $UPTIME_EXT" >> $MOTD
echo -e " $W$G • Kernel.............$W: $P $KERNEL" >> $MOTD echo -e " $C3$C2 • Kernel.............$C3: $C1 $KERNEL" >> $MOTD
echo -e " $W$G • External IP........$W: $P $EXTERNAL" >> $MOTD echo -e " $C3$C2 • External IP........$C3: $C1 $EXTERNAL" >> $MOTD
for (( i=0; i<${#arr[@]}; i++ )); do for (( i=0; i<${#arr[@]}; i++ )); do
if [ $i -eq 0 ]; then if [ $i -eq 0 ]; then
echo -e "$W$G • Network Interfaces.$W: $P ${arr[$i]}" >> $MOTD echo -e "$C3$C2 • Network Interfaces.$C3: $C1 ${arr[$i]}" >> $MOTD
else else
echo -e "$W$G $P ${arr[$i]}" >> $MOTD echo -e "$C3$C2 $C1 ${arr[$i]}" >> $MOTD
fi fi
done done
echo -e " $W$LBB" >> $MOTD echo -e " $C3$LBB" >> $MOTD
echo -e "$X" >> $MOTD echo -e "$X" >> $MOTD
} }

Loading…
Cancel
Save