Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Initscript modification
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Mon Sep 14, 2015 4:25 pm    Post subject: Initscript modification Reply with quote

I'm trying to modify a couple of initscripts via their /etc/conf.d files.

1. /etc/init.d/mythbackend
There is a "need net" in the depends section that I need to negate some how. I tried rc_need="!net" but that didn't work.

2. /etc/init.d/NetworkManager
I need to add "sleep 2". Here is the location:
Code:
start() {
   # If we are re-called by a dispatcher event, we want to mark the service
   # as started without starting the daemon again
   yesno "${IN_BACKGROUND}" && return 0

   [ -z "${INACTIVE_TIMEOUT}" ] && INACTIVE_TIMEOUT="1"

   ebegin "Starting NetworkManager"
   start-stop-daemon --start --quiet --pidfile /run/NetworkManager/NetworkManager.pid \
      --exec /usr/sbin/NetworkManager -- --pid-file /run/NetworkManager/NetworkManager.pid
   local _retval=$?
   sleep 2
   eend "${_retval}"
   if [ "x${_retval}" = 'x0' ] && ! nm-online -t "${INACTIVE_TIMEOUT}"; then
      einfo "Marking NetworkManager as inactive. It will automatically be marked"
      einfo "as started after a network connection has been established."
      mark_service_inactive
   fi
   return "${_retval}"
}

Any help would be apprecaited.
Thanks
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Mon Sep 14, 2015 4:48 pm    Post subject: Re: Initscript modification Reply with quote

davidbrooke wrote:
1. /etc/init.d/mythbackend
There is a "need net" in the depends section that I need to negate some how. I tried rc_need="!net" but that didn't work.

david ... close:

/etc/rc.conf
Code:
rc_mythbackend_need="!net"


davidbrooke wrote:
2. /etc/init.d/NetworkManager
I need to add "sleep 2". Here is the location:

I don't understand the question, or what you're trying to achieve. If you need something in your dependency tree to start after a successful retval from NM then have it start after.

/etc/rc.conf
Code:
rc_someservice_after="NetworkManager"

.... though, that said, NM usurps the idea of depends as it is 'managing' whatever is supposed to happen with 'net' ... so you may have to use its internal mechanisms.

best ... khay
Back to top
View user's profile Send private message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Mon Sep 14, 2015 5:41 pm    Post subject: Reply with quote

Thanks khayyam!

Item 2 is a result of a race condition between NM completing and mysql starting before NM was complete. It appears that NM restarts right after it is complete when mysql thinks it is OK to start. Mysql then gets stuck or it could work out. I tried using /etc/conf.d/mysql rc_need="net" but that still didn't quite work. I decided to try a delay, such that NM wouldn't say it was OK until it actually completed. I found by trial and error that placing the sleep statement as i previously posted works. I'm not sure what is going on with NM but this is as far as my troubleshooting could get me.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Mon Sep 14, 2015 8:47 pm    Post subject: Reply with quote

davidbrooke wrote:
Item 2 is a result of a race condition between NM completing and mysql starting before NM was complete. It appears that NM restarts right after it is complete when mysql thinks it is OK to start. Mysql then gets stuck or it could work out. I tried using /etc/conf.d/mysql rc_need="net" but that still didn't quite work. I decided to try a delay, such that NM wouldn't say it was OK until it actually completed. I found by trial and error that placing the sleep statement as i previously posted works. I'm not sure what is going on with NM but this is as far as my troubleshooting could get me.

david ... I'm still not 100% sure about what's happening as I can't see what might cause a "race condition", do you mean that mysql fails to start as there is no interface for it to bind to? It shouldn't need such a thing, in fact, unless you're serving data across the network you are probably best to bind it to the loopback. Looking at the default 'my.cnf' that seems to be the default ('bind-address = 127.0.0.1').

I can't see an init, or conf, in files/ so I don't know what its depending on, I'd suggest however you configure it not to depend on net (as this may circumvent the above "race condition").

/etc/rc.conf
Code:
rc_mysql_need="!net"

HTH & best ... khay

ps. you're welcome.
Back to top
View user's profile Send private message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Mon Sep 14, 2015 10:34 pm    Post subject: Reply with quote

Maybe someone could look at NM and tell me if there is an issue of reconnecting or if this looks normal?

Code:
09/14/15 03:26:36 PM   xxxxxx   syslog-ng[2079]   syslog-ng starting up; version='3.6.4'
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Found user 'avahi' (UID 105) and group 'avahi' (GID 997).
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Successfully dropped root privileges.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   avahi-daemon 0.6.31 starting up.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Successfully called chroot().
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Successfully dropped remaining capabilities.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Loading service file /services/sftp-ssh.service.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Loading service file /services/ssh.service.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Network interface enumeration completed.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Registering HINFO record with values 'X86_64'/'LINUX'.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Server startup complete. Host name is xxxxxx.local. Local service cookie is 3712543512.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Service "xxxxxx" (/services/ssh.service) successfully established.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Service "xxxxxx" (/services/sftp-ssh.service) successfully established.
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): link connected
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): device state change: unavailable -> disconnected (reason 'carrier-changed') [20 30 40]
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  Auto-activating connection 'Wired connection 1'.
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): Activation: starting connection 'Wired connection 1' (4e33b074-126e-4916-a26a-8bf1f79ee1fd)
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  NetworkManager state is now CONNECTING
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): device state change: prepare -> config (reason 'none') [40 50 0]
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): device state change: config -> ip-config (reason 'none') [50 70 0]
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Joining mDNS multicast group on interface enp2s0.IPv4 with address 192.168.107.100.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   New relevant interface enp2s0.IPv4 for mDNS.
09/14/15 03:26:36 PM   xxxxxx   avahi-daemon[2192]   Registering new address record for 192.168.107.100 on enp2s0.IPv4.
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): device state change: secondaries -> activated (reason 'none') [90 100 0]
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  NetworkManager state is now CONNECTED_LOCAL
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  NetworkManager state is now CONNECTED_GLOBAL
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  Policy set 'Wired connection 1' (enp2s0) as default for IPv4 routing and DNS.
09/14/15 03:26:36 PM   xxxxxx   NetworkManager[2016]   <info>  (enp2s0): Activation: successful, device activated.
09/14/15 03:26:36 PM   xxxxxx   nm-dispatcher   Dispatching action 'up' for enp2s0
09/14/15 03:26:37 PM   xxxxxx   rpc.statd[2392]   Version 1.3.1 starting
09/14/15 03:26:37 PM   xxxxxx   rpc.statd[2392]   Flags: TI-RPC
09/14/15 03:26:37 PM   xxxxxx   rpc.statd[2392]   Running as root.  chown /var/lib/nfs to choose different user
09/14/15 03:26:37 PM   xxxxxx   sm-notify[2452]   Version 1.3.1 starting
09/14/15 03:26:37 PM   xxxxxx   avahi-daemon[2192]   Joining mDNS multicast group on interface enp2s0.IPv6 with address fe80::d63d:7eff:fe05:d7b9.
09/14/15 03:26:37 PM   xxxxxx   avahi-daemon[2192]   New relevant interface enp2s0.IPv6 for mDNS.
09/14/15 03:26:37 PM   xxxxxx   avahi-daemon[2192]   Registering new address record for fe80::d63d:7eff:fe05:d7b9 on enp2s0.*.
09/14/15 03:26:38 PM   xxxxxx   rpc.mountd[2729]   Version 1.3.1 starting
09/14/15 03:26:38 PM   xxxxxx   sm-notify[2749]   Version 1.3.1 starting
09/14/15 03:26:38 PM   xxxxxx   sm-notify[2749]   Already notifying clients; Exiting!
09/14/15 03:26:38 PM   xxxxxx   ntpd[2773]   ntp engine ready
09/14/15 03:26:38 PM   xxxxxx   cron[2914]   (CRON) STARTUP (V5.0)
09/14/15 03:26:39 PM   xxxxxx   dbus[1996]   [system] Activating service name='org.freedesktop.UPower' (using servicehelper)
09/14/15 03:26:39 PM   xxxxxx   dbus[1996]   [system] Successfully activated service 'org.freedesktop.UPower'
09/14/15 03:26:39 PM   xxxxxx   dbus[1996]   [system] Activating service name='org.freedesktop.UDisks2' (using servicehelper)
09/14/15 03:26:39 PM   xxxxxx   udisksd[3017]   udisks daemon version 2.1.4 starting
09/14/15 03:26:39 PM   xxxxxx   dbus[1996]   [system] Successfully activated service 'org.freedesktop.UDisks2'
09/14/15 03:26:39 PM   xxxxxx   udisksd[3017]   Acquired the name org.freedesktop.UDisks2 on the system message bus
09/14/15 03:26:39 PM   xxxxxx   dbus[1996]   [system] Activating service name='org.kde.powerdevil.backlighthelper' (using servicehelper)
09/14/15 03:26:39 PM   xxxxxx   dbus[1996]   [system] Successfully activated service 'org.kde.powerdevil.backlighthelper'
09/14/15 03:26:41 PM   xxxxxx   NetworkManager[2016]   <info>  startup complete
Back to top
View user's profile Send private message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Mon Sep 14, 2015 10:54 pm    Post subject: Reply with quote

khayyam wrote:
david ... I'm still not 100% sure about what's happening as I can't see what might cause a "race condition", do you mean that mysql fails to start as there is no interface for it to bind to? It shouldn't need such a thing, in fact, unless you're serving data across the network you are probably best to bind it to the loopback. Looking at the default 'my.cnf' that seems to be the default ('bind-address = 127.0.0.1').

I can't see an init, or conf, in files/ so I don't know what its depending on, I'd suggest however you configure it not to depend on net (as this may circumvent the above "race condition").

/etc/rc.conf
Code:
rc_mysql_need="!net"

HTH & best ... khay

ps. you're welcome.


Mysql is serving data across the network to other clients so this option is set 'bind-address = 192.168.107.100'.
Below is the mysql error log. It shows mysql not seeing 192.168.107.100.

Code:
150913  3:59:59 [Warning] No argument was provided to --log-bin and neither --log-basename or --log-bin-index where used;  This may cause repliction to break when this server acts as a master and has its hostname changed! Please use '--log-basename=xxxxxx' or '--log-bin=mysqld-bin' to avoid this problem.
150913  3:59:59 [Note] InnoDB: Using mutexes to ref count buffer pool pages
150913  3:59:59 [Note] InnoDB: The InnoDB memory heap is disabled
150913  3:59:59 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
150913  3:59:59 [Note] InnoDB: Memory barrier is not used
150913  3:59:59 [Note] InnoDB: Compressed tables use zlib 1.2.8
150913  3:59:59 [Note] InnoDB: Using Linux native AIO
150913  3:59:59 [Note] InnoDB: Using CPU crc32 instructions
150913  3:59:59 [Note] InnoDB: Initializing buffer pool, size = 128.0M
150913  3:59:59 [Note] InnoDB: Completed initialization of buffer pool
150913  3:59:59 [Note] InnoDB: Highest supported file format is Barracuda.
150913  3:59:59 [Note] InnoDB: 128 rollback segment(s) are active.
150913  3:59:59 [Note] InnoDB: Waiting for purge to start
150913  3:59:59 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.25-73.1 started; log sequence number 9529553
150913  3:59:59 [Warning] /usr/sbin/mysqld: unknown option '--loose-federated'
150913  3:59:59 [Note] Server socket created on IP: '192.168.107.100'.
150913  3:59:59 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 99: Cannot assign requested address
150913  3:59:59 [ERROR] Do you already have another mysqld server running on port: 3306 ?
150913  3:59:59 [ERROR] Aborting

150913  3:59:59 [Note] InnoDB: FTS optimize thread exiting.
150913  3:59:59 [Note] InnoDB: Starting shutdown...


So then mysql just waits for the default 15 minutes (/etc/conf.d/mysql STARTUP_TIMEOUT="900") or I reboot the computer.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Tue Sep 15, 2015 12:45 pm    Post subject: Reply with quote

davidbrooke wrote:
Mysql is serving data across the network to other clients so this option is set 'bind-address = 192.168.107.100'.

david ... in which case NM doesn't really belong in such a setup. With a static IP, and clients dependent on that IP, there is really no reason for NM. I'd suggest you use the far simpler netifrc.

best ... khay
Back to top
View user's profile Send private message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Tue Sep 15, 2015 2:30 pm    Post subject: Reply with quote

khayyam wrote:
davidbrooke wrote:
Mysql is serving data across the network to other clients so this option is set 'bind-address = 192.168.107.100'.

david ... in which case NM doesn't really belong in such a setup. With a static IP, and clients dependent on that IP, there is really no reason for NM. I'd suggest you use the far simpler netifrc.

best ... khay

Thanks for the reply!
I still don't quite follow why NM is a bad fit. I have used KDE with NM (which is the default) in many other distro's ie Linux Mint, Arch, etc... without issue. Also I set all my computers to a set ip address, because of NFS, via the MAC address on the router. Not only that but NM has the ability to set a manual ip address via the GUI. Please be more specific as to the negative attributes of NM.
On the other point of the sleep statement....as of now I'm only using the "sleep 2" to solve my race issue on start up.
Thanks
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Wed Sep 16, 2015 2:09 pm    Post subject: Reply with quote

davidbrooke wrote:
I still don't quite follow why NM is a bad fit. I have used KDE with NM (which is the default) in many other distro's ie Linux Mint, Arch, etc... without issue. Also I set all my computers to a set ip address, because of NFS, via the MAC address on the router. Not only that but NM has the ability to set a manual ip address via the GUI. Please be more specific as to the negative attributes of NM.

david ... the purpose of init is to bring the machine up in a consistent manner. You've stated above that this isn't the case ("mysql then gets stuck or it could work out"), this inconsistency is that sometimes the interface is up when init subsequently runs mysql, sometimes it isn't. This is because NM has no idea of service management, but is none the less "managing" net. NM fullfils the function expected of a user interface, but fails in that its not actually intergrated with the logic underlying the system. All that needs to happen is that the interface is brought up and asigned an IP, you don't need to change this (ie, need something to "manage" it) becuase your serving data accross the network from a fixed IP. So, use something whos purpose is do do just that, and not a tool whos purpose is to replace the underlying logic with the interface.

/etc/conf.d/net
Code:
config_eth0="192.168.107.100/24"
routes_eth0="default via 192.168.107.1"

Code:
# rc-update del NetworkManager default
# ln -s /etc/init.d/net.lo /etc/init.d/net.eth0
# rc-update add net.eth0 default

best ... khay
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3509

PostPosted: Wed Sep 16, 2015 3:30 pm    Post subject: Reply with quote

For another data point, I'm doing exactly what's being suggested. I also use MAC mapping in my dhcp server, so that my "static" IPs come over dhcp.

My clients are all (but one) using netifrc, and end up calling dhcpcd. It all works.

The one client that isn't using netifrc is a laptop using dhcpcd directly. (There are HowTos for this under Gentoo.)
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
davidbrooke
Guru
Guru


Joined: 03 Jan 2015
Posts: 341

PostPosted: Thu Sep 17, 2015 6:56 am    Post subject: Reply with quote

Again thanks to khayyam and depontius for your replies! Your inputs help greatly in my learning of Gentoo.
So far this what I understand:
1. NM isn't setup to manage "net" like netifrc because NM isn't properly intergrated like netifrc.
2. The "race condition" problem didn't occur until I switched from a regular HD to a SSD. (this is new info I forgot to supply)
3. Linux Mint, Arch and Gentoo on a regular HD don't exhibit the "race condition" using KDE with NM where as Gentoo with a SSD does. I have not tried any other disto with the SSD.
4. Of the distro's tested Linux Mint, Arch and Gentoo all have different init systems.
5. I can't prove for certain that there is a "race condition". I can only deduct from the situation that there is a "race condition" and by applying the "sleep 2" statement in /etc/init.d/NetworkManager that my system boots up correctly.
6. I can prove that using rc statements like rc_mythbackend_need="mysql" or rc_need="net" in the /etc/conf.d or rc.conf files don't result in the expected outcome.
7. I have a couple of options for a working system:
A. Use the current work-around of the "sleep 2" statement with NM.
B. Use netifrc

The above findings are broad statements and I can go into further detail if needed.

Questions
1. I'm going to assume that NM isn't intergrated into Openrc like netifrc. If so, will NM be intergrated to the same level as netifrc?
2. Does netifrc have a GUI that provides openvpn intergration?
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Thu Sep 17, 2015 1:37 pm    Post subject: Reply with quote

davidbrooke wrote:
1. I'm going to assume that NM isn't intergrated into Openrc like netifrc. If so, will NM be intergrated to the same level as netifrc?

david ... the problem is it can't be, once NM is started the idea of what init is doing (ordered dependency) is then handed over to NM, but as I said, it doesn't have any idea of service management. Subsequent services 'need net' but once NM is started that provision is satisfied ... regardless of NM having completed its task of assigning an IP, or not. In your case replacing the HD with an SSD makes the process of initialisation faster, and so the issue is made all the more visible, it was simply luck that it worked previously.

In the case of Linux Mint, and Arch, these are using systemd, and so socket activation, as the "solution" to such "problems".

davidbrooke wrote:
2. Does netifrc have a GUI that provides openvpn intergration?

Thankfully no, because what would then happen is that the underlying system would need re-written to satisfy the needs of this "interface" ... and then what you have is a Windows/OS X clone. That's pretty much where linux is at currently, and god forbid anyone question its validity.

best ... khay
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3509

PostPosted: Thu Sep 17, 2015 3:33 pm    Post subject: Reply with quote

The fact that you're running "mythbackend" rather suggests you're running a server, but a query about an OpenVPN GUI is indicative of a client. I have two servers, running mythbackend on one and an OpenVPN endpoint on the other., though I hope to consolidate them on one server soon. I'm simply using OpenRC to start OpenVPN at boot time. I just looked, and according to the initscript, OpenVPN doesn't "provide" anything, so nothing will wait for it.

I would rather like to have an OpenVPN GUI for my laptop, also. Right now I just get root and start it that way, but I'd like something friendlier for my wife.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3131

PostPosted: Thu Sep 17, 2015 5:15 pm    Post subject: Reply with quote

Quote:
but once NM is started that provision is satisfied ... regardless of NM having completed its task of assigning an IP, or not.
Kinda weird. At one of my machines NM starts with status "inactive". It will turn "started" after it connects with anything. And status "inactive" doesn't satisfy dependencies of other services. They are just sitting there and waiting untl they can be started.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
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