LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-22-2004, 06:56 PM   #1
MikTheUser
LQ Newbie
 
Registered: Jun 2004
Posts: 26

Rep: Reputation: 15
Cool change braodcast message at shutdown


hi folks,

nothing serious, I've just been wondering if I could possibly change the "Bradcast message from root (tty1) ..." - I grep-ed it out of /sbin/shutdown, but since that's a binary file, I won't meddle with it.
Any hints?

TIA,
Mik
 
Old 07-22-2004, 07:03 PM   #2
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
What do you want it to say?
 
Old 07-23-2004, 03:58 AM   #3
MikTheUser
LQ Newbie
 
Registered: Jun 2004
Posts: 26

Original Poster
Rep: Reputation: 15
if there's a choice to make, I'd go with "Braodcast message from God (tty0): the Universe is going down for shutdown NOW!"

well, seriously, the trouble with that would be that I'd have t remove two %s-placeholders (the username and tty-indicator) from the message in the binary code - which would lead to programming errors. So... would I have to re-compile it?
 
Old 07-23-2004, 08:02 AM   #4
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
Yes, you would have to recompile it. Which is not a serious challenge considering what you want to do. I'll go see if I can find the shutdown source for slackware myself and if I can give you some pointers.

In the meantime, have you tried adding a message to the command?

shutdown -h now "All you guys are going to pay!"

Or something like that... it might meet your needs, although I am not certain it wouldn't print both.

Last edited by frob23; 07-23-2004 at 08:39 AM.
 
Old 07-23-2004, 08:34 AM   #5
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
Oh, it looks like you are going to have to change the default behavior of wall... which would be a bad thing. But that is the program that is adding the information you want to change (root->God). You can create an account named God, su into that, and then run shutdown and it might change the name.

For your other change, edit shutdown.c (it is in the sysvinit-2.84.tar.gz file).

Code:
/*
 * Tell everyone the system is going down in 'mins' minutes.
 */
void warn(mins)
int mins;
{
  char buf[MESSAGELEN + sizeof(newstate)];
  int len;

  strncpy(buf, message, sizeof(buf));
  buf[sizeof(buf) - 1] = 0;
  len = strlen(buf);

  if (mins == 0)
        snprintf(buf + len, sizeof(buf) - len,
                "\rThe system is going down %s NOW!\r\n",
                newstate);
  else
        snprintf(buf + len, sizeof(buf) - len,
                "\rThe system is going DOWN %s in %d minute%s!\r\n",
                        newstate, mins, mins == 1 ? "" : "s");
  wall(buf, 1, 0);
}
You need to change system to Universe in both places where it occures. There are other messages where it still says system and you might want to change them also to it reflects the word universe. Rebuild the program, install it with the correct permissions and you are all set.

EDIT: The other program you would change would be dowall.c -- you could do it the easy way, and break its functionality by hardcoding strings, or you could perform a test and if you are root change the string to God. I leave that up as an exercise to you.

Hint: user = pwd ? pwd->pw_name : (uid == 0 ? "root" : uidbuf);
Look for that line. And, YOU MUST REBUILD ALL PROGRAMS THAT DEPEND ON THIS IF YOU CHANGE IT. Just rebuild everything in the directory to be safe.

Last edited by frob23; 07-23-2004 at 08:43 AM.
 
Old 07-24-2004, 01:28 PM   #6
MikTheUser
LQ Newbie
 
Registered: Jun 2004
Posts: 26

Original Poster
Rep: Reputation: 15
Hi all!

Thanks for your hints! In the end, I settled with echo-ing a Latin bible quote right before powerdown, so I won't have to recompile everything - but I might just take a look at that shutdown code to play around a little - nothing wild tho

Thanks again, Mik
 
Old 11-20-2013, 01:07 AM   #7
Izra
LQ Newbie
 
Registered: Jul 2012
Posts: 7

Rep: Reputation: Disabled
How to change broadcast message..while shoutdown or reboot

I want to change the reboot/shutdown ..message..

Broadcast message from root@Server197
(/dev/pts/0) at 10:49 ...

The system is going down for reboot NOW!


this messages...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel bug message at shutdown and in syslog? M$ISBS Linux - General 2 05-24-2005 09:12 PM
Change Welcome Message Zebe SUSE / openSUSE 1 03-25-2005 10:21 PM
Windows LASS shutdown message the_imax General 0 02-28-2005 09:57 AM
error message just before shutdown jwijesundra Linux - General 5 11-10-2004 05:48 AM
Giving message on shutdown... Ninja_212 Slackware 1 11-11-2003 10:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration