Re: Daemons in schroot or how to start chroot automatically
On Fri, 20 Jul 2012 10:42:58 +0100, Roger Leigh wrote:
> On Thu, Jul 19, 2012 at 12:34:26PM +0000, Ramon Hofer wrote:
>> I have some questions about starting daemons in a chroot environment or
>> rather about starting schroot on bootup.
>> The reason I want to do this is to clean up my server. It's a Squeeze
>> with an AMD64 kernel from backports. Some packages are from testing
>> which gives me problems because of dependencies that can't be
>> fullfilled: sabnzbdplus from testing depends on python so I can't
>> install build- essential...
>>
>> So far I was able to setup a chroot with schroot and installed sid in
>> it.
>>
>> [sid]
>> description=Debian sid (unstable)
>> directory=/srv/chroot/sid users=hoferr groups=hoferr root-groups=root
>> aliases=unstable,default
>
> set type=directory here
That sounds great what I can read in the schroot.conf manpage:
"In consequence, filesystems such as /proc are not mounted in
plain chroots; it is the responsibility of the system
administrator to configure such chroots by hand, whereas
directory chroots are automatically configured."
This means I can remove the remounts of /proc, /dev and /sys to /srv/
chroot/sid/... from my /etc/fstab?
But when I try this out and comment the proc and dev remounts and restart
the system sabnzbd+ isn't started automatically and when I try it when
the init.d script manually I get:
[....] Starting SABnzbd+ binary newsgrabber:start-stop-daemon: nothing
in /proc - not mounted?
failed!
>> In the chroot I have created a new user called hoferr and am now able
>> to login without root privilieges.
>> But in there sudo is missing. Maybe this can be resolved by installing
>> the correct base system meta package mentioned above?
>
> You could install sudo. But why? This is what schroot /is/ (chroot +
> sudo). If you want to do stuff as root inside the chroot,
> just add yourself to root-groups/root-users.
Or start it with `sudo schroot -p -c sid`.
>> Aside some missing packages everything looks promising.
>> To get back to my main reason of doing this: After stopping the "old"
>> sabnzbdplus can I just install the chroot sabnzbplus with the "normal"
>> home partition mounted? It will probably start automatically when the
>> chroot is started and I should be able to access its web service from
>> the LAN.
>>
>> But how can I start the chroot on bootup automatically. i probably just
>> have to write a init.d script and do a update.rc.
>>
>> Is this enough as init.d script?
>> http://pastebin.com/raw.php?i=hHSvG30v
>
> No. You need LSB dependencies (you'll need
> Required-Start: $local_fs $remote_fs $network $syslog schroot
> and the same for Required-Stop).
> You will also need to start an schroot /session/, and then start up the
> services inside that session. And you'll need to stop the services and
> end the session on stop.
>
> Note that schroot 1.6.x (in unstable) have a new facility for starting
> and stopping services inside the chroot. In schroot.conf, add
> "setup.services=service1,service2" etc. It won't handle LSB ordering or
> anything advanced though--it just runs invoke-rc.d in order on the list
> when you start a session, and stop in reverse order on ending the
> session. Using this facility would avoid the need to manually stop and
> start services in your init script; you'd just need to create and end a
> session. Whether that's useful or not depends on your specific needs,
> but it's there if you want to try it out.
I'm still using version 1.4.19. But this feature sounds very good!
Btw I have accidentally run `schroot -v` instead -V to get the version
number. First I got a little shock but now the prompt shows the name of
the chroot I'm logged into even if I only do `schroot -p -c sid`. That's
great :-)
Thanks
Ramon
Reply to: