View previous topic :: View next topic |
Author |
Message |
rootor n00b
Joined: 05 Dec 2011 Posts: 25
|
Posted: Fri May 18, 2012 4:01 am Post subject: Add my own init.d and conf.d directory |
|
|
As we know, Gentoo's default init scripts are in /etc/init.d/ directory, and each service(in /etc/init.d) may have a configuration file in /etc/conf.d
But, I installed(do not use portage) Apache, postgresql in /opt/own, and created their init scripts in /opt/own/init.d/ , configuration file in /opt/own/conf.d/...
Now, my problem is how to add my init scripts(in /opt/own/init.d) in default runlevel and each service can read it's configuration file(in /opt/own/conf.d) when it start.
Is the a configuration file for /sbin/rc ? Or others?
Thanks for help !!
The following is my test:
I created two file: /opt/own/init.d/chen, /opt/own/conf.d/chen
Code: | # cat /opt/own/init.d/chen
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
use net
}
start() {
ebegin "Start ...chen"
:>/opt/own/test.result
einfo ".... from conf.d: ${SAY}"
einfo ".... from conf.d: ${MY_DIR}"
echo ${SAY}>>/opt/own/test.result
echo ${MY_DIR}>>/opt/own/test.result
eend $?
}
stop() {
ebegin "Stop ...chen"
echo "Stop ....chen">>/opt/own/test.result
eend $?
}
|
Code: | # cat /opt/own/conf.d/chen
# just a test
SAY="Hello, gentooo"
MY_DIR="/opt/init/conf.d"
|
When I run: /opt/own/init.d/chen start, it can read /opt/own/con.d/chen, and everything seems OK.
Code: | # /opt/own/init.d/chen start
* Start ...chen ...
* .... from conf.d: Hello, gentooo
* .... from conf.d: /opt/init/conf.d [ ok ]
|
And rc-update also seems OK
Code: | # rc-update add /opt/own/init.d/chen default
* service /opt/own/init.d/chen added to runlevel default
# ls -l /etc/runlevels/default/chen
lrwxrwxrwx 1 root root 20 May 18 13:49 /etc/runlevels/default/chen -> /opt/own/init.d/chen
|
But /opt/own/init.d/chen do not execute when I boot system. |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Fri May 18, 2012 10:24 am Post subject: Re: Add my own init.d and conf.d directory |
|
|
rootor wrote: | Is the a configuration file for /sbin/rc ? Or others? |
That'd be /etc/rc.conf
You can find all the files installed by a package with qlist from portage-utils, so I just did: qlist openrc|grep man to find all the manpages, and qlist openrc|less to see what else was around.
Quote: | I installed(do not use portage) Apache, postgresql in /opt/own, and created their init scripts in /opt/own/init.d/ , configuration file in /opt/own/conf.d/...
Now, my problem is how to add my init scripts(in /opt/own/init.d) in default runlevel and each service can read it's configuration file(in /opt/own/conf.d) when it start.
..
But /opt/own/init.d/chen do not execute when I boot system. |
Well, I asked how to do this on IRC and was told "just use portage" with doinitd and doconfd in the ebuild. Personally I think it's an interesting idea (/opt and /usr/local both seem like plausible locations to install services to) but I think you'll have to stick the actual initscript and conf in /etc, then tweak which command gets started.
I do understand why developers say to use an ebuild (since the package manager can track the files installed as you change the code, and it helps prepare for eventual distribution since you have to make it build) but it just seems like a pita for a locally-customised webserver: unless of course you're not running standard apache/postgres at the same time, in which case I'd say to use /etc/portage/patches as outlined here (assuming the ebuild uses epatch_user or at least inherits eutils.) |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Wed May 23, 2012 1:04 pm Post subject: |
|
|
This is bug 350910. |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10587 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed May 23, 2012 1:25 pm Post subject: |
|
|
In a related question, I would like to establish my own root directory. I know Gentoo already has a root directory, but I would like to create my own where I can install software that works alongside all of the Portage-installed software in the traditional root directory. Can anyone help?
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Wed May 23, 2012 5:52 pm Post subject: |
|
|
You should be able to extract the latest stage 3 and work with ROOT:
Code: | export ROOT=/path/to/chroot
emerge -av pkg | or:
Code: | emerge -av pkg --root=/path/to/chroot | but that's not the same as running alongside an existing install.
The gentoo-prefix project is about running a portage install alongside an existing OS, whereby all apps for the portage instance are in /path/to/chroot. It's designed to allow using GNU tools safely on eg BSD, Solaris or Interix/Windows (so they only link to stuff in the prefix, and you can remove the lot just by deleting the directory, though obviously that will remove all your configuration.)
I don't see any reason in principle that you couldn't use prefix on an existing Gentoo install, though you might have to setup any initscripts in /etc/init.d, to call those in the prefix. I'd ask in #gentoo-prefix -- they're the one of the best projects in Gentoo imo (both in terms of the work they do, and their attitude to users.)
PORTAGE_CONFIG_ROOT is another variable that might be of interest. It's set with --config-root=DIR; see also the --root-deps option in man emerge. |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10587 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed May 23, 2012 5:53 pm Post subject: |
|
|
But inside the chroot, I'll lose access to the underlying root. I need both!
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Wed May 23, 2012 6:24 pm Post subject: |
|
|
#gentoo-prefix ;) Sorry I should have used /path/to/prefix for that as it's not a chroot. _________________
creaker wrote: | systemd. It is a really ass pain |
update - "a most excellent portage wrapper"
#friendly-coders -- We're still here for you™ ;) |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10587 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed May 23, 2012 6:34 pm Post subject: |
|
|
But /path/to/prefix isn't a root either. Seems there's no solution to my problem.
Maybe the moral to this story is that, sometimes there's only one place for something and sometimes that's okay?
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Thu May 24, 2012 3:41 am Post subject: |
|
|
John R. Graham wrote: | But /path/to/prefix isn't a root either. |
What do you mean by a "root"?
It functions as one, in the sense that packages within it will only depend on each other, and has all the standard directories underneath it ie: /etc /bin /sbin /lib /usr etc. Anything your system already has, you put in package.provided.
And packages installed there can run for you as a user, and access directories you can in the normal manner.
Quote: | Seems there's no solution to my problem. |
I'm still not certain what you're trying to achieve. You say a "root that has access to the main system" which is what prefix does afaik, but you need to clarify what that means precisely, and why prefix (assuming tweaks) isn't sufficient by design, as you seem to imply. In other words: what are you really trying to do?
What problem is it that leads you to want this "root that is not a chroot but nor is it a gentoo-prefix."
Cos I sure don't understand right now ;)
Quote: | Maybe the moral to this story is that, sometimes there's only one place for something and sometimes that's okay |
Well it may well be that this is an XY-problem ;-) |
|
Back to top |
|
|
|