Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
initd scripts w/o initd
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
TheLexx
Tux's lil' helper
Tux's lil' helper


Joined: 04 Dec 2005
Posts: 137
Location: Austin Tx

PostPosted: Thu Dec 28, 2017 12:37 am    Post subject: initd scripts w/o initd Reply with quote

I am trying to start services manually without using initd. It seams now a days, the only online documents I can find only talks about starting with initd or systemd. I did try running MySQL and Apache with initd, then simply using ps find the following CLI commands.

Code:
/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf &

/usr/sbin/apache2 -D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST-D LANGUAGE -D PHP -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -k start


After starring and stopping with initd, I was able to start those services using just the CLI command shown above It works as long as a start and stop with initd first.

If on the other hand I reboot, then run those same CLI commands both Apache and MySQL will fail. This indicates to me, that the initd system preformed some operation prior to starting MySQL or Apache. I know that initd will automatically start prerequisite services, but looking at the output of "/etc/init.d/mysql start" no other services were started (same with Apache).

Reading /var/log/mysql/mysqld.err I see a prominent error that happens when I attempt to start MySQL without initd.

Code:

2017-12-26 16:31:04 1899 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2017-12-26 16:31:04 1899 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2017-12-26 16:31:04 1899 [Note] Server socket created on IP: '127.0.0.1'.
2017-12-26 16:31:04 1899 [ERROR] Can't start server : Bind on unix socket: Permission denied
2017-12-26 16:31:04 1899 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
2017-12-26 16:31:04 1899 [ERROR] Aborting


This error seems to indicate that the initd script does something that effects the permissions assigned to port 3306. Is there any way to figure out what the initd script is doing? I will report more info on the failure of Apache on a later post in this thread. Thanks in advance for any advice.



Version numbers:
sys-apps/sysvinit: 2.88-r9
sys-apps/openrc: 0.23.2
dev-db/mysql-init-scripts: 2.1-r1
dev-db/mysql: 5.6.35
www-servers/apache: 2.4.25

/etc/mysql/my.cnf https://pastebin.com/fwcdBxU2
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Thu Dec 28, 2017 2:25 am    Post subject: Reply with quote

Why are you trying to avoid the init system?

You misunderstood the error message. It failed to bind the unix domain socket, not the TCP socket. The failed unix socket is on the next line: /var/run/mysqld/mysqld.sock. Most likely, your /run was made a tmpfs (by the init system ;)), so rebooting clears the startup work done by the initscript. If you don't use the initscript to start mysql, you need to do the job the initscript would have done. You could find these steps by reading the initscript in /etc/init.d.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Thu Dec 28, 2017 4:19 am    Post subject: Reply with quote

No offense, but may it be we have an XY problem here?
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Thu Dec 28, 2017 9:45 am    Post subject: Reply with quote

TheLexx,

init runs things as root.
Code:
2017-12-26 16:31:04 1899 [ERROR] Can't start server : Bind on unix socket: Permission denied
hinsts that you are not root.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
TheLexx
Tux's lil' helper
Tux's lil' helper


Joined: 04 Dec 2005
Posts: 137
Location: Austin Tx

PostPosted: Wed Jan 03, 2018 7:59 pm    Post subject: Reply with quote

Hu wrote:
You misunderstood the error message. It failed to bind the unix domain socket, not the TCP socket. The failed unix socket is on the next line: /var/run/mysqld/mysqld.sock. Most likely, your /run was made a tmpfs (by the init system ;)), so rebooting clears the startup work done by the initscript.

Thank you for your help, I did not realize that the key was the file mysqld.sock. Looking around I found that the directory /var/run/mysqld/ as not created until the initd script was run and the a reboot emoved the directory. I am able to get MySQL to run after I create he /var/run/mysqld/ owned by user mysql.



Hu wrote:
If you don't use the initscript to start mysql, you need to do the job the initscript would have done. You could find these steps by reading the initscript in /etc/init.d.

That is basically that I was I am asking, how do I read the script and figure out what it is doing? The scripts are written in the /sbin/runscript language. Is there some sort of standard debugging that can be used to interpret the /sbin/runscript language? The /sbin/runscript language appears similar to train wreck syntax of the bash scripting language. Even with "post hoc analysis", I was not able to find the line in the script that created the needed directory.



Jaglover wrote:
No offense, but may it be we have an XY problem here?

Hu wrote:
Why are you trying to avoid the init system?


All I wish to do is decouple the starting of those two services from the initd system. Back in the 90's and 00's this was a perfectly legitimate way to run those services.

In a different thread, I explained why I wanted to do the decoupling, however I seamed to spend more and more time justifying myself instead of just doing the decoupling. The short answer is, if I do not have to rely on a functioning initd system (in the sandbox environment), it gives me more options for working in a sandbox environment.

I admit that the best way to start servives at boot is to use the initd system. However, right now, I am looking for a sandbox to experiment with. Because of this, manually starting services is not a problem. When I rent a VPS, I will be starting the services with initd.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Wed Jan 03, 2018 11:56 pm    Post subject: Reply with quote

As I understand it, runscript, like ebuild, is fundamentally bash (and is executed by running GNU Bourne Shell), but with various standard libraries sourced in automatically before the script begins evaluation.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


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

PostPosted: Thu Jan 04, 2018 10:00 am    Post subject: Reply with quote

Hu wrote:
As I understand it, runscript, like ebuild, is fundamentally bash (and is executed by running GNU Bourne Shell), but with various standard libraries sourced in automatically before the script begins evaluation.

Hu ... actually, posix sh, so not like ebuilds (which are bash). All initscripts should not contain bashisms for this reason (though because /bin/sh is linked to /bin/bash by default they tend to pass).

TheLexx wrote:
That is basically that I was I am asking, how do I read the script and figure out what it is doing? The scripts are written in the /sbin/runscript language. Is there some sort of standard debugging that can be used to interpret the /sbin/runscript language? The /sbin/runscript language appears similar to train wreck syntax of the bash scripting language.

The standard shell method, 'set -x ; <section of code to be debugged> ; set +x'.

TheLexx wrote:
Even with "post hoc analysis", I was not able to find the line in the script that created the needed directory.

It's this:

/etc/init.d/mysql:
checkpath -d --owner mysql:mysql --mode 0755 "$piddir"

HTH & best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security 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