 |
 |
 |
 |
| Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum. |

15th October 2009, 08:18 PM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 10

|
|
How-To ?: Start a service on user login to gnome
Does anyone know a secure method for starting a service after a user logs in to the desktop environment? There are a couple of issues that I'm trying to work around / troubleshoot and this would assist with doing that.
I'm running Fedora 11, not sure if that matters for this question.
|

15th October 2009, 09:21 PM
|
 |
Administrator
|
|
Join Date: Aug 2007
Location: London Postbox (the red one)
Age: 47
Posts: 3,847

|
|
|
Hi and Welcome to the forum.
Have you looked at adding a command/script/program etc to Menu>>system>>Preferences>>Startup Applications
or you could add a command to /etc/rc.d/rc.local
Dave
|

15th October 2009, 09:35 PM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 10

|
|
|
Thanks, dangermouse. I actually did try those methods already. The problems I'm troubleshooting I think occur when the services are included in the general boot process, and even in rc.local. When I start and/or restart the services after logging in to gnome, none of the problems occur. My goal is the exclude these services from the normal startup sequence, yet still have them automagically start after login.
Better yet, is there a way to restart a service after the computer boots up but before login? Currently I've got a cron job that restarts one of the services at 15 minute intervals, not sure if there is something that will simply restart (or start) a service once automatically after the machine has booted completely, but sans any user interaction. Sorry, just had that idea and I'm kind of shooting from the hip here.
Last edited by heftigrat; 15th October 2009 at 09:42 PM.
Reason: Clarification (Redundancy)
|

15th October 2009, 09:40 PM
|
 |
Administrator
|
|
Join Date: Aug 2007
Location: London Postbox (the red one)
Age: 47
Posts: 3,847

|
|
|
It might be easier if you say what the problems you have originally that you are trying to workout.
|

15th October 2009, 09:53 PM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 10

|
|
Quote:
Originally Posted by Dangermouse
It might be easier if you say what the problems you have originally that you are trying to workout.
|
I wonder if that would only cloud the issue of what I'm trying to accomplish short-term, but here goes. The services I'm having issues with are ddclient and xrdp.
Regarding ddclient, when I have the service start at boot, I get the following error when ddclient attempts to update my IP with dyndns.org:
Code:
ddclient[<PID>]: WARNING: cannot connect to checkip.dyndns.com:80 socket: IO::Socket::INET: Bad hostname 'checkip.dyndns.com'
When I restart the service everything works fine, and ddclient has no further issues updating my IP when it changes. I currently have ddclient restart every 15 minutes, as the whole point is remote access so I cannot restart it manually. Hence, if I ever have to reboot remotely, and subsequently reboot my router, I lose access to my box.
Regarding xrdp, when I have the service start at boot, nm-applet will not load and instead simply throws an error on login to gnome. This isn't as critical, but I do have TCP port 3389 permanently open to my box, which I view as a potential security risk if xrdp is not active and listening on that port.
I hope that helps clarify the situation. In a nutshell, until I can figure out why the two issues above are occurring, I would like a workaround whereby ddclient will start after everything else is initialized and where xrdp will start after logging in (as I'm not sure, but I believe nm-applet starts after login as well).
Thanks for your assistance!
|

17th October 2009, 02:45 AM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 10

|
|
Follow up thought, I've enabled ddclient in runlevel 5 only. However, the problem persists. I noticed that the sym links in /etc/rc5.d/ (or any of the runlevel folders) are named [S/K]#<service>. Does the number have anything to do with the order in which the services are started? For example, on my system the NetworkManager is assigned 27 and ddclient is assigned 65:
Code:
# ls -l /etc/rc5.d/ | grep NetworkManager
lrwxrwxrwx. 1 root root 24 2009-08-05 23:52 S27NetworkManager -> ../init.d/NetworkManager
# ls -l /etc/rc5.d/ | grep ddclient
lrwxrwxrwx. 1 root root 18 2009-10-16 20:34 S65ddclient -> ../init.d/ddclient
I'm assuming the # has nothing to do with the order, as ddclient is still started prior to the network interface being initialized (see below). Is there any possible way to make sure ddclient (or any other service for that matter) starts after eth0 is initialized?
Code:
Oct 16 16:28:26 <HOST> ddclient[<PID>]: WARNING: cannot connect to checkip.dyndns.com:80 socket: IO::Socket::INET: Bad hostname 'checkip.dyndns.com'
...
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): device state change: 1 -> 2 (reason 2)
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): bringing up device.
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): preparing device.
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): deactivating device (reason: 2).
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): carrier now ON (device state 2)
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): device state change: 2 -> 3 (reason 40)
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) starting connection 'System eth0'
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): device state change: 3 -> 4 (reason 0)
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) scheduled...
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) started...
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 2 of 5 (Device Configure) scheduled...
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) complete.
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 2 of 5 (Device Configure) starting...
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): device state change: 4 -> 5 (reason 0)
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 2 of 5 (Device Configure) successful.
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) scheduled.
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 2 of 5 (Device Configure) complete.
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) started...
Oct 16 16:28:28 <HOST> NetworkManager: <info> (eth0): device state change: 5 -> 7 (reason 0)
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 4 of 5 (IP Configure Get) scheduled...
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) complete.
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 4 of 5 (IP Configure Get) started...
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 5 of 5 (IP Configure Commit) scheduled...
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 4 of 5 (IP Configure Get) complete.
Oct 16 16:28:28 <HOST> NetworkManager: <info> Activation (eth0) Stage 5 of 5 (IP Configure Commit) started...
Oct 16 16:28:28 <HOST> avahi-daemon[<PID>]: Joining mDNS multicast group on interface eth0.IPv4 with address <static_ip>.
|

17th October 2009, 01:30 PM
|
 |
Registered User
|
|
Join Date: Nov 2008
Location: Canada
Posts: 2,048

|
|
I wonder if your nic's coming up before the service begins? Yeah I use ddclient here, np, are you using network services or network manager?
Edit: opps, I see it. So I suspect ddclient as a service cant resolve because network manager hasn't connected. Try this:
Quote:
su
chkconfig ddclient off
reboot
|
Login, jump to a terminal and:
Quote:
ifconfig eth0
service ddclient restart
|
What's the output?
Last edited by beaker_; 17th October 2009 at 01:36 PM.
|

17th October 2009, 06:19 PM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 10

|
|
Beaker, I'm not sure what output from ifconfig eth0 you're looking for. Here it is, with IP and MAC removed (after removing ddclient from all runlevels and rebooting):
Code:
[<HOST> ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr <MAC>
inet addr:<IP> Bcast:<IP_BCAST> Mask:255.255.255.0
inet6 addr: <IP6> Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2371 errors:0 dropped:0 overruns:0 frame:0
TX packets:2336 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1952896 (1.8 MiB) TX bytes:432194 (422.0 KiB)
Interrupt:23 Base address:0xe000
And since the service wasn't started at boot time, restarting the service fails on stopping, succeeds on starting:
Code:
[<HOST> ~]# service ddclient restart
Stopping ddclient: [FAILED]
Starting ddclient: [ OK ]
[<HOST> ~]#
Does that give you the info you're looking for? Thanks!
|

17th October 2009, 06:30 PM
|
 |
Registered User
|
|
Join Date: Nov 2008
Location: Canada
Posts: 2,048

|
|
|
I was checking if you nic was being assigned an ip-address and if starting ddclient after you've logged in would give network manager a chance to get rolling. I think it has. Do you receive the same errors and does ddclient update your ip? ddclient appears to have restarted successfully. So I'd try moving control way from networkmanager and into network services or try enabling eth0 on start up.
edit: i see ipv6 also running. do you need it?
Last edited by beaker_; 17th October 2009 at 06:36 PM.
|

17th October 2009, 06:34 PM
|
 |
Registered User
|
|
Join Date: Nov 2008
Location: Canada
Posts: 2,048

|
|
Sorry for the double post.
At the terminal paste the output of
su
chkconfig --list network
chkconfig --list NetworkManager
cat /etc/sysconfig/network-scripts/ifcfg-eth0 Yeah edit out your ip if it's public.
|

17th October 2009, 10:25 PM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 10

|
|
No problem, beaker, thanks for the reply again. The network management is being done by NetworkManger, so the network service is disabled in all runlevels while the NetworkManager service is enabled in runlevels 2-5. Here's the output just for the record:
Code:
[root@IN-FS-N01 ~]# chkconfig --list network
network 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@IN-FS-N01 ~]# chkconfig --list NetworkManager
NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@IN-FS-N01 ~]#
Got tired of removing my hostname, obviously.  Anyway, here are the contents of the ifcfg-eth0 file as well:
Code:
[root@IN-FS-N01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Networking Interface
DEVICE=eth0
HWADDR=<MAC>
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.0.0.57
PREFIX=24
GATEWAY=10.0.0.254
DNS1=<DNS1>
DNS2=<DNS2>
NAME="System eth0"
UUID=<UUID>
ONBOOT=yes
NETMASK=255.255.255.0
NM_CONTROLLED=yes
IPV6INIT=no
USERCTL=no
[root@IN-FS-N01 ~]#
I noticed that IPV6INIT=no, does that mean IP v6 is disabled? I don't need it but I'm not sure that would be causing any problems anyway? Not sure if there are known bugs since it's still relatively new.
As stated previously, if I start and/or restart ddclient after everything is up and running it updates just fine. The problem (apparently) occurs when ddclient initializes prior to eth0, and for some reason doesn't recover even after the network connection is active. This is (I believe) a bug in ddclient itself, but yes you are definitely on to something in stating that eth0 needs to be initialized first. I guess the crux if the issue is I need a way to do that. Any ideas? Thanks again for the help!
|

17th October 2009, 10:40 PM
|
 |
Registered User
|
|
Join Date: Nov 2008
Location: Canada
Posts: 2,048

|
|
Um ipv6 isn't disabled because it kicked back an ipv6 address when you ran ifconfig. Is it a problem? Not likely, normally firefox stumbles on it though. However you're not complaining about that so I think it's harmless enough.
Let's enable network services and move eth0's control over. Leaving Network Manager running is harmless enough, and you'll want it if you have wireless. However we will disable it to troubleshoot.
Quote:
su
chkconfig network on
chkconfig NetworkManager off
chkconfig ddclient on
|
Add you ip, mask, dns...
reboot
Does everything pull up correctly?
Edit: Besure to check 'activate device when computer starts' and uncheck 'controlled by network manager' within system-config-network's dialogue.
Last edited by beaker_; 17th October 2009 at 10:45 PM.
|

17th October 2009, 11:56 PM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 10

|
|
|
Done, and that seems to have resolved the problem. ddclient is running after boot and correctly updated my IP after rebooting my router. However, nm-applet is no longer running and I don't get the nifty icon in the notification area. That's obviously not a huge deal, but I would prefer to have that applet active. I'm assuming this is only possible using NetworkManager. Any ideas on that one? If not I'm fine leaving the config as is. Thanks!
|

18th October 2009, 12:26 AM
|
 |
Registered User
|
|
Join Date: Nov 2008
Location: Canada
Posts: 2,048

|
|
Actually most will argue Network Manager is a pain in the but, as you have just seen.
Your applet will return after you restart network manager su
chkconfig NetworkManager on
service NetworkManager restart You might have to log out and back in again to see the applet and you can move control between network manager & network services by checking/unchecking 'controlled by network manager' within system-config-network's dialogue.
Now try this: su
system-config-network
-- check controlled by network manager
-- check activate when computer starts
-- leave the other two unchecked
-- set your nic's properties; dhcp, or manual config Save it all and reboot. Is there joy & does NM applet pop up? If it doesn't double check network & network manger's services. They both should be enabled and running.
|

18th October 2009, 01:00 AM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 10

|
|
|
You rock. So it was basically as simple as enabling the network service? Activate when computer starts was already checked so... not sure why they don't just have network run at boot by default. Oh well, your help was much appreciated! Now to tackle the issue of xrdp. I'm going to leave that for another day. Thanks so much!
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 14:04 (Wednesday, 22-05-2013)
|
|
 |
 |
 |
 |
|
|