Google
  Web www.spinics.net

Re: Determine if x is running

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Mon, February 9, 2009 3:25 pm, Ray Van Dolson wrote:
> On Mon, Feb 09, 2009 at 02:21:24PM -0800, redhat@xxxxxxxxxxxxxx wrote:
>> I'm am writing a script that sets some various security settings on
>> Redhat Boxes.  I would like to try to determine if a gui may be
>> running
>> on the box the script is run on.  If so, I would echo some additional
>> text to stdout that instructs the user that they may required to
>> manually perform some additional settings manually.  Things having to
>> do
>> with screen savers.  Anyway, I thought about the following:
>>
>> 1. use the runlevel command or who -r to see if the system is in
>> runlevel 5.  This seems flawed since the box may have been started in
>> runlevel 3 and the startx command may have been used. The commands
>> would
>> show runlevel 3.
>> 2. Check if the environment variable DISPLAY is set.  If so, seems
>> like
>> there is a good chance that they are running a gui. (maybe)

DISPLAY is set by the user's login process, so it would be empty for a
cron job.

>>
>> Is there a better way to check this that anyone can think of?
>
> Would it be sufficient for your needs to check is the X process is
> running?
>
> Theoretically, there is probably some way to interact with a running X
> server directly from a script (even if you're not in control of its
> terminal) to determine if it's running.
>
> Also, X typically listens on port 6000 locally.

Just run runlevel and it will return what runlevel is currently being
run in the second response, i.e: on boot, it will show N 5 or N 3 for X
or text depending on what's in /etc/inittab on the initdefault line.

Now then, that doesn't handle startx, but how many times might that
actually happen. On my servers, there's no CRT/LCD, so no user will be
running startx. They might run vncserver, however, and use an X display
remotely. But, they better not leave it in that state, else that will be
disabled for them. All the users in my network have Linux PCs anyway,
and have no reason to be on the server unless they are editing a web
page, but then they can use fish:// in Konqueror or sftp:/// in
Nautilus.

I suspect I've confused more than helped, but ask away and someone
smarter than me will respond.

Karl

>
> Ray
>
> _______________________________________________
> Redhat-install-list mailing list
> Redhat-install-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/redhat-install-list
> To Unsubscribe Go To ABOVE URL or send a message to:
> redhat-install-list-request@xxxxxxxxxx
> Subject: unsubscribe
>


---
Karl Pearson
Karlp@xxxxxxxxxxxxxxxx
Owner/Administrator of the sites at
http://ourldsfamily.com
---
"To mess up your Linux PC, you have to really work at it;
 to mess up a microsoft PC you just have to work on it."
---


_______________________________________________
Redhat-install-list mailing list
Redhat-install-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/redhat-install-list
To Unsubscribe Go To ABOVE URL or send a message to:
redhat-install-list-request@xxxxxxxxxx
Subject: unsubscribe

[Red Hat Kickstart]     [Fedora Users]     [Red Hat General]     [Red Hat Development]     [Samba]     [Kernel]     [Kernel Newbies]     [Hot Springs]     [Yosemite News]

Powered by Linux