Fixed last login retrive

master
czoczo 7 years ago
parent 37b69fff3f
commit dfbea44b2d
  1. 9
      bmotd.sh

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Config # Config
MOTD="/etc/motd2" MOTD="/etc/motd"
INSTPATH="/etc/bmotd.sh" INSTPATH="/etc/bmotd.sh"
CACHEPATH="/var/cache/bmotd" CACHEPATH="/var/cache/bmotd"
@ -105,8 +105,8 @@ update() {
echo $PKG_NU > "$CACHEPATH/pkg_count" echo $PKG_NU > "$CACHEPATH/pkg_count"
fi fi
PKG_NU=$(cat $CACHEPATH/pkg_count) PKG_NU=$(cat $CACHEPATH/pkg_count)
# Test if /etc/motd writable and run motd generator if so # run motd generator if so
test -w $MOTD && motdGen motdGen
} }
function printHelp { function printHelp {
@ -259,7 +259,8 @@ function isRoot() {
motdGen() { motdGen() {
# 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")$C3 from$C1 $(lastlog -u $USER | tail -n 1 | tr -s ' ' | cut -d" " -f3)" LASTUSER=$(last | head -n 1 | cut -d' ' -f1)
LASTLOGIN="$LASTUSER$C3 on$C1 $(date --date "$(lastlog -u $LASTUSER | tail -n 1 | tr -s ' ' | cut -d" " -f4-)" "+%a %e %b %Y, %H:%M:%S")$C3 from$C1 $(lastlog -u $LASTUSER | 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'`

Loading…
Cancel
Save