Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

Please give an example as well instead of just the syntax

asked 04 Nov '14, 16:55

piyush128kk's gravatar image

piyush128kk
1112
accept rate: 0%




The above will be effective on reboot. With the Gnome Interface, when you click on a user name, the System name and the timestamp will appear while you enter the paassword.

link

answered 18 Oct '16, 21:41

lsatenstein's gravatar image

lsatenstein
1
accept rate: 0%

#!/bin/bash
#
# This script generates a one liner file which is positioned on the
# Gnome Logon Screen above the first name on the list. The intention
# is to present a message to the user, prior to his logging 
# into the system.  However, this script serves to identify the system
# being logged into by using a field from /etc/os-release
# The script has been tested with SUSE, and Fedora (2 versions)
# It is GPL'd -- no license. Do with it what you want. I take 
# No responsibilities if the message is too long or too short.
# or the message is inappropriate.
#
# Version Sun Jan 16 18:33:29 
# Author Leslie Satenstein
# create a message on the logon screen.
#echo "Run as sudo $0"
#########################################################################
function TEST_FOR_ROOT_ACCESS                                           #
{                                                                       #
if [ $EUID -ne 0 ]; then                                                #
   echo ""                                                              #
   echo "##################################################"            #
   echo "#       You cannot run as user $LOGNAME           "            #
   echo "#       You cannot run as user $LOGNAME           "            #
   echo "#       You cannot run as user $LOGNAME           "            #
   echo "#                                 "        #
   echo "#       You must run as root                 "         #
   echo "#       You must run as root                 "         #
   echo "##################################################"            #
   echo ""                                                              #
   exit 1                                   #
fi                                                                      #      
}                                                                       #
#                                                                       #       
#########################################################################

TEST_FOR_ROOT_ACCESS        #root access ?
#setup vars
DIR1=/tmp/
DIR2=/tmp/
DCONF="echo"
#  ======================================================
#  If testing, comment out the following three lines 
#  or modify this script
#  and uncomment (if not done) the preceding three lines
#  ======================================================
DIR1=/etc/dconf/profile         #redefine
DIR2=/etc/dconf/db/gdm.d        #redefine
DCONF=dconf             #redefine
#
if [ ! -f $DIR1/gdm ]; then
# Following does the same as previous 3 with 1 line
echo -e "user-db:user\nsystem-db:gdm\nfile-db:/usr/share/gdm/greeter-dconf-defaults"  > $DIR1/gdm
fi

mkdir -p $DIR2

# Following are typical contents of /etc/dconf/db/gdm.d/01-banner-message

P1="banner-message-text='"
P2=$(grep PRETTY_NAME /etc/os-release |  cut -d\" -f2)
if [ -d /boot/lost+found ]; then
    P3=$(stat /boot/lost+found | grep ^Modify | cut -d' ' -f2-| cut -d'.' -f1)
else
    P3=$(stat /boot | grep ^Modify | cut -d' ' -f2-| cut -d'.' -f1)

fi

echo  "installing to $DIR1 and $DIR2"
echo  "[org/gnome/login-screen]"             >  ${DIR2}/01-banner-message
echo  "banner-message-enable=true"                      >>  ${DIR2}/01-banner-message
echo "$P1$P2 installed on\\r\\n$P3'"            >>  ${DIR2}/01-banner-message
echo "#Created by $0 at $(date)"            >>  ${DIR2}/01-banner-message
${DCONF} update
echo -e "$P2\ninstalled on: $P3"
exit 0**strong text**
link

answered 18 Oct '16, 21:38

lsatenstein's gravatar image

lsatenstein
1
accept rate: 0%

If it is a new Linux system, you can look at the timestamp of /boot/lost+found.

If it is not there, for RedHat type systems try the timestamp of /etc/os-release

For example, my system was installed:

[root@scientific etc]# ls -l os-release -rw-r--r--. 1 root root 484 Feb 24 12:33 os-release

link

answered 05 Apr '16, 08:30

lsatenstein's gravatar image

lsatenstein
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×14

Asked: 04 Nov '14, 16:55

Seen: 3,128 times

Last updated: 18 Oct '16, 21:41

powered by OSQA