Install SQL on FreeBSD Jail

Hi all,

I plan to write a script that automatically creates a FreeBSD Jail with SQL installed. I have succeeded to create a jail, but I have a problem when installing SQL. I found in some documents that I have to use the ports collection to install SQL, but I have no idea about installing SQL without entering the jail. If I use jexec to enter the jail, the script cannot execute the remaining commands of the script.

I'm a newbie to shell scripting so I really need your suggestion about this issue.

Sincerely thanks,
 
If you are using the new (pkgng) package system, you can use # pkg -j <jailname or id> install mysql55-server. The -j flag will execute pkg operations for a jail, wile the similar -c flag will execute pkg as chroot. Replace the install part of the code for whatever other pkg operation you might want to do.

All from the comfort of your host environment.
 
Many thanks @Beeblebrox for your reply, but as I know, I have to use the ports collection to install SQL, PKGNG is only used for installing binary packages. On the other hand, we have to bootstrap pkg for the first use, but I have no idea for bootstrapping it without entering the jail.

I have found in some documents, it says that we can mount /usr/ports into the jail, and add some variables (WRKDIRPREFIX, DISTFILES, PACKAGES) to /etc/make.conf to redirect the build machine to an area inside the jail, but I don't really understand the meaning of these.

Thanks,
 
Last edited by a moderator:
Binary packages for the new pkgng system have become available for a month now. Unless you have specific compile option requirements, the binary package built with the default settings should be enough for your needs. Therefore you are not limited to the ports system.

Define your pkg repository on the host (read https://wiki.freebsd.org/pkgng). You are then set to use pkgng.

The other hand, we have to bootstrap pkg for the first use, but I have no idea for bootstrapping it without enter the jail.
No. That's the point - pkg -c takes care of all of that and you do not have to do any bootstrapping.

I have found on some documents, it says that we can mount /usr/ports to the jail, and add some variables (WRKDIRPREFIX, DISTFILES, PACKAGES) into /etc/make.conf to redirect the build machine to an area inside the jail

Again, that's if you MUST use ports and even then, all of that is not necessary unless you are targeting a different architecture (say building for 386 on amd64 platform). None of this is needed for a simple & and quick solution.
  • Define your repository. Read the necessary documentation.
  • Convert to the PKGNG system (run pkg2ng).
  • Try an install & and delete of a simple binary with the method I described in the first post. You will see how it works.
 
Back
Top