diff --git a/bmotd.sh b/bmotd.sh index 1840237..b122b2f 100755 --- a/bmotd.sh +++ b/bmotd.sh @@ -1,7 +1,7 @@ #!/bin/bash # Config -MOTD="/etc/motd2" +MOTD="/etc/motd" INSTPATH="/etc/bmotd.sh" CACHEPATH="/var/cache/bmotd" @@ -105,8 +105,8 @@ update() { echo $PKG_NU > "$CACHEPATH/pkg_count" fi PKG_NU=$(cat $CACHEPATH/pkg_count) - # Test if /etc/motd writable and run motd generator if so - test -w $MOTD && motdGen + # run motd generator if so + motdGen } function printHelp { @@ -259,7 +259,8 @@ function isRoot() { motdGen() { # 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'`