Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Editing /etc/issue and /etc/motd to get a cooler login.
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
nichocouk
Guru
Guru


Joined: 10 Mar 2005
Posts: 585
Location: Glasgow

PostPosted: Wed Mar 28, 2007 11:45 am    Post subject: Reply with quote

ecatmur wrote:
Code:
#! /bin/bash
 
if [ -x "$(which cowsay)" ]; then
        cows=(/usr/share/cowsay*/cows/*.cow)
        modes=("-b" "-d" "-g" "-s" "-t" "-w" "-y" "")
        filter="cowsay -f ${cows[$(($RANDOM%${#cows}))]} ${modes[$(($RANDOM%${#modes}))]}"
else
        filter="cat"
fi
 
if [ -x "$(which fortune)" ]; then
        producer="fortune"
else
        producer="uname -a"
fi
 
$producer | $filter > /etc/motd

Ecatmur,
Thanks for a nice tip, but I've got some problems I don't understand:
In the script, the command
Code:
echo ${#modes}
always return 2, and the selected modes are "-b" or "-d" only. What could be the reason?
Thanks!
_________________
nichocouk

L'Etat, c'est moi.
Back to top
View user's profile Send private message
nichocouk
Guru
Guru


Joined: 10 Mar 2005
Posts: 585
Location: Glasgow

PostPosted: Wed Mar 28, 2007 1:19 pm    Post subject: Reply with quote

OK, I found the problem, I had to add [*] so that the number of elements in the array is returned:
Code:
filter="cowsay -f ${cows[$(($RANDOM%${#cows[*]}))]} ${modes[$(($RANDOM%${#modes[*]}))]}"

For some reason this problem does not occur for the cows array, but I added the [*] for consistency.

Cheers,
_________________
nichocouk

L'Etat, c'est moi.
Back to top
View user's profile Send private message
Akkara
Bodhisattva
Bodhisattva


Joined: 28 Mar 2006
Posts: 6702
Location: &akkara

PostPosted: Mon Apr 02, 2007 1:18 am    Post subject: Reply with quote

Quote:
dynamically draws the box and fills it with whatever needed number of whitespaces


A quick way to output fixed-length lines using sed:
Code:
sed -e 's/$/                /' -e 's/^\(................\).*/| \1 |/'
(Adjust the number of spaces in the 1st expression and the number of dots in the second expression to equal the desired line length)

Or, for right-justified:
Code:
sed -e 's/^/                /' -e 's/.*\(................\)$/| \1 |/'
Back to top
View user's profile Send private message
eyoung100
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1428

PostPosted: Mon Jun 14, 2010 8:53 pm    Post subject: Reply with quote

dub.wav wrote:
Another suggestion:
Code:
emerge linux-logo
linux_logo -L 3 > /etc/issue (back up /etc/issue first)


Headhunter123 wrote:
Hi!

Cool tips, thanks :)

One improvement for your cowsay thing, what about showing a random cow each time?

Try this script (it isn't mine, I have it from some guy from #gentoo.de, don't ask me who it was, anyway, he deserves the credits, not me)
Code:
#!/bin/sh
cowsay -f $(perl -le 'opendir COWS, "/usr/share/cowsay-3.03/cows/";push @a, $_ foreach readdir COWS;closedir COWS;$a[int rand $#a]=~/(.*)\.cow/;print $1') $1joj


NeddySeagoon wrote:

Code:
# run fortune at login
echo
fortune
echo
to the end of /etc/bash/bashrc ?
Every login gets a new fortune


I took all three of the above ideas, and added this to my /etc/bash/bashrc:
Code:
# Run fortune from random cowsay for everyone at new login
echo
fortune | cowsay -f $(perl -le 'opendir COWS, "/usr/share/cowsay-3.03/cows/";push @a, $_ foreach readdir COWS;closedir COWS;$a[int rand $#a]=~/(.*)\.cow/;print $1') $1
echo
The joj was removed as I would get the diferrent .cow files, but they were all returning joj. I then added this to /etc/conf.d/linux-logo (I'd leave out the comments but you need them to decipher the meaning):
Code:
# Seq   Description             Output
# ----------------------------------------------------------------
# ##                            #
# #B    Bogomips                374.37
# #C    Compiled Date           #47 Fri Jan 8 10:37:09 EST 1999
# #E    User Text               My Favorite Linux Distribution
#       Displayed with -t
# #H    Hostname                deranged
# #L    Load average            Load average 0.04, 0.01, 0.01
# #M    Megahertz               188Mhz
#       where supported
# #N    Number of CPU's         Two
# #O    OS Name                 Linux
# #P    Processor or Processors Processor
# #R    Ram                     64M
#       in Megabytes
# #S    Plural                  s
# #T    Type of CPU             K6
# #U    Uptime                  Uptime 10 hours 59 minutes
# #V    Version of OS           2.2.0-pre5
# #X    CPU Vendor              AMD
# \\n   carriage return

FORMAT="Gentoo #O `cat /etc/gentoo-release | awk '{ print $5,$6 }'`\n#O #V, Compiled #C\n#N #X #T #M CPU#S, #R RAM, #B Bogomips\nHost: #H  / Login Terminal: \l\nToday's Date: \d\n        Local Time: \t\n"
FORMATNET="Gentoo #O `cat /etc/gentoo-release | awk '{ print $5,$6 }'`\n#O #V, Compiled #C\n#N #X #T #M CPU#S, #R RAM, #B Bogomips\nHost: #H / Today's Date: \d\n        Local Time: \t\n"
OPTIONS="-L 2 -f -u"


2 is passed to /usr/bin/linux_logo which is the word gentoo in purple. Also note the extra spaces in the Time Section. Those are there to somewhat center evenly the time under the date. Notice also that some of our original pieces of /etc/issue can be added from the original as Jeedo decoded:
Jeedo wrote:

1. Customizing /etc/issue

/etc/issue is the text that is displayed before any user is able to log on the system, the default output on Gentoo is:

Code:

This is \n.\O (\s \m \r) \t


Which translates to:

Quote:

This is hostname.iso-domain (kernel arch version) HH:MM:SS



I'm sure theres a fancy way to code to put them in the center, but I'm lazy :roll: This will give you both login art and a fortune without the need for /etc/motd as that can only be a plain text file.
_________________
The Birth and Growth of Science is the Death and Atrophy of Art -- Unknown
Registerd Linux User #363735
Adopt a Post | Strip Comments| Emerge Wrapper
Back to top
View user's profile Send private message
zzxop
n00b
n00b


Joined: 26 Mar 2004
Posts: 5

PostPosted: Tue Aug 02, 2011 1:57 pm    Post subject: Reply with quote

COOL TIPS! :D
THANKS && Bookmarked :lol:
Back to top
View user's profile Send private message
logical_guy
Apprentice
Apprentice


Joined: 18 Sep 2007
Posts: 268

PostPosted: Tue Aug 02, 2011 4:16 pm    Post subject: Reply with quote

tom56 wrote:
Am I the only one who thinks the picture at the top of this is page is inappropriate? IMO the fact that it is in ASCII doesn't make it any more or less suitable.


+1 on this one. Just because most gentoo users are geeks, it doesn't mean what's appropriate in a chan4 forum is appropriate here.
Please keep gentoo forums clean and minors-friendly.
Back to top
View user's profile Send private message
coolzxbin
n00b
n00b


Joined: 30 Dec 2012
Posts: 1

PostPosted: Sun Dec 30, 2012 5:44 pm    Post subject: Reply with quote

nichocouk wrote:
ecatmur wrote:
Code:
#! /bin/bash
 
if [ -x "$(which cowsay)" ]; then
        cows=(/usr/share/cowsay*/cows/*.cow)
        modes=("-b" "-d" "-g" "-s" "-t" "-w" "-y" "")
        filter="cowsay -f ${cows[$(($RANDOM%${#cows}))]} ${modes[$(($RANDOM%${#modes}))]}"
else
        filter="cat"
fi
 
if [ -x "$(which fortune)" ]; then
        producer="fortune"
else
        producer="uname -a"
fi
 
$producer | $filter > /etc/motd

Ecatmur,
Thanks for a nice tip, but I've got some problems I don't understand:
In the script, the command
Code:
echo ${#modes}
always return 2, and the selected modes are "-b" or "-d" only. What could be the reason?
Thanks!


try

echo ${#modes[*]}
Back to top
View user's profile Send private message
P.Kosunen
Guru
Guru


Joined: 21 Nov 2005
Posts: 309
Location: Finland

PostPosted: Tue Mar 15, 2016 9:53 am    Post subject: Reply with quote

Code:
cat /etc/issue > /etc/motd

At (ssh) login i see this:
Code:
This is \n.\O (\s \m \r) \t


How can i get these escape sequences to show up correctly?

Edit: /etc/login.defs might be correct place to set this.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum