diff options
| -rwxr-xr-x | ezjail-admin | 51 | ||||
| -rwxr-xr-x | ezjail.conf.sample | 3 | ||||
| -rwxr-xr-x | man1/ezjail-admin.1 | 16 | ||||
| -rwxr-xr-x | man5/ezjail.conf.5 | 5 |
4 files changed, 72 insertions, 3 deletions
diff --git a/ezjail-admin b/ezjail-admin index 56290c9..372f30e 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
| @@ -22,6 +22,7 @@ ezjail_flavours=${ezjail_flavours:-"${ezjail_jaildir}/flavours"} | |||
| 22 | ezjail_portscvsroot=${ezjail_portscvsroot:-":pserver:anoncvs@anoncvs.at.FreeBSD.org:/home/ncvs"} | 22 | ezjail_portscvsroot=${ezjail_portscvsroot:-":pserver:anoncvs@anoncvs.at.FreeBSD.org:/home/ncvs"} |
| 23 | ezjail_sourcetree=${ezjail_sourcetree:-"/usr/src"} | 23 | ezjail_sourcetree=${ezjail_sourcetree:-"/usr/src"} |
| 24 | ezjail_uglyperlhack=${ezjail_uglyperlhack:-"YES"} | 24 | ezjail_uglyperlhack=${ezjail_uglyperlhack:-"YES"} |
| 25 | ezjail_default_execute=${ezjail_default_execute:-"/bin/sh"} | ||
| 25 | 26 | ||
| 26 | ezjail_mount_enable=${ezjail_mount_enable:-"YES"} | 27 | ezjail_mount_enable=${ezjail_mount_enable:-"YES"} |
| 27 | ezjail_devfs_enable=${ezjail_devfs_enable:-"YES"} | 28 | ezjail_devfs_enable=${ezjail_devfs_enable:-"YES"} |
| @@ -33,12 +34,13 @@ ezjail_dirlist="bin boot lib libexec rescue sbin usr/bin usr/games usr/include u | |||
| 33 | case `uname -p` in amd64) ezjail_dirlist="${ezjail_dirlist} usr/lib32";; esac | 34 | case `uname -p` in amd64) ezjail_dirlist="${ezjail_dirlist} usr/lib32";; esac |
| 34 | 35 | ||
| 35 | # Synopsis messages | 36 | # Synopsis messages |
| 36 | ezjail_usage_ezjailadmin="Usage: ${ezjail_admin} [config|create|delete|install|list|update] {params}" | 37 | ezjail_usage_ezjailadmin="Usage: ${ezjail_admin} [config|console|create|delete|install|list|update] {params}" |
| 37 | ezjail_usage_install="Usage: ${ezjail_admin} install [-mps] [-h host] [-r release]" | 38 | ezjail_usage_install="Usage: ${ezjail_admin} install [-mps] [-h host] [-r release]" |
| 38 | ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli] [-C args] jailname jailip" | 39 | ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli] [-C args] jailname jailip" |
| 39 | ezjail_usage_delete="Usage: ${ezjail_admin} delete [-w] jailname" | 40 | ezjail_usage_delete="Usage: ${ezjail_admin} delete [-w] jailname" |
| 40 | ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree] [-i] [-pP]" | 41 | ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree] [-i] [-pP]" |
| 41 | ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-i attach|detach|fsck] jailname" | 42 | ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-i attach|detach|fsck] jailname" |
| 43 | ezjail_usage_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname" | ||
| 42 | ezjail_usage_list="Usage: ${ezjail_admin} list" | 44 | ezjail_usage_list="Usage: ${ezjail_admin} list" |
| 43 | 45 | ||
| 44 | ################################ | 46 | ################################ |
| @@ -639,6 +641,53 @@ install) | |||
| 639 | 641 | ||
| 640 | exerr "Could not find ezjail's rc.d script in ${ezjail_prefix}/etc/rc.d/. You need to type it the long way." | 642 | exerr "Could not find ezjail's rc.d script in ${ezjail_prefix}/etc/rc.d/. You need to type it the long way." |
| 641 | ;; | 643 | ;; |
| 644 | ######################## ezjail-admin CONSOLE ######################## | ||
| 645 | console) | ||
| 646 | # Clean variables, prevent polution | ||
| 647 | unset ezjail_execute ezjail_forcestart | ||
| 648 | |||
| 649 | shift; while getopts :e:f arg; do case ${arg} in | ||
| 650 | e) ezjail_execute=${OPTARG};; | ||
| 651 | f) ezjail_forcestart="YES";; | ||
| 652 | ?) exerr ${ezjail_usage_console};; | ||
| 653 | esac; done; shift $(( $OPTIND - 1 )) | ||
| 654 | |||
| 655 | # we need name of jail to attach to | ||
| 656 | [ $# -eq 1 ] || exerr ${ezjail_usage_console} | ||
| 657 | |||
| 658 | # Get all info we have on that jail | ||
| 659 | fetchjailinfo $1 | ||
| 660 | |||
| 661 | # check for existence of jail in our records | ||
| 662 | [ -n "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." | ||
| 663 | |||
| 664 | # if jail is not running, we either try to force start it or fail | ||
| 665 | if [ -z "${ezjail_id}" ]; then | ||
| 666 | |||
| 667 | # If force start is requested, try that | ||
| 668 | [ -n "$ezjail_forcestart}" ] || exerr "Error: Jail ${ezjail_name} appears not to be running, start it first (or use console -f for force start)." | ||
| 669 | |||
| 670 | echo "Trying to bring up ${ezjail_name} ..." | ||
| 671 | # Try to locate and run ezjails rc.d script | ||
| 672 | if [ -x "${ezjail_prefix}/etc/rc.d/ezjail" ]; then | ||
| 673 | (exec "${ezjail_prefix}/etc/rc.d/ezjail" start ${ezjail_name}); | ||
| 674 | elif [ -x "${ezjail_prefix}/etc/rc.d/ezjail.sh" ]; then | ||
| 675 | (exec "${ezjail_prefix}/etc/rc.d/ezjail.sh" start ${ezjail_name}); | ||
| 676 | else | ||
| 677 | exerr "Could not find ezjail's rc.d script in ${ezjail_prefix}/etc/rc.d/. You need to start ${ezjail_name} by hand." | ||
| 678 | fi | ||
| 679 | |||
| 680 | # See, if it is running now | ||
| 681 | fetchjailinfo ${ezjail_name} | ||
| 682 | |||
| 683 | [ -n "${ezjail_id}" ] || exerr "Error: Could not start ${ezjail_name}. You need to start it by hand." | ||
| 684 | fi | ||
| 685 | |||
| 686 | # Try to attach to jail | ||
| 687 | [ -n "${ezjail_execute}" ] && exec jexec ${ezjail_id} ${ezjail_execute} | ||
| 688 | |||
| 689 | exec jexec ${ezjail_id} ${ezjail_default_execute} | ||
| 690 | ;; | ||
| 642 | ######################## ezjail-admin CONFIG ######################## | 691 | ######################## ezjail-admin CONFIG ######################## |
| 643 | config) | 692 | config) |
| 644 | # Clean variables, prevent polution | 693 | # Clean variables, prevent polution |
diff --git a/ezjail.conf.sample b/ezjail.conf.sample index 3dfd336..5fee81a 100755 --- a/ezjail.conf.sample +++ b/ezjail.conf.sample | |||
| @@ -26,6 +26,9 @@ | |||
| 26 | # This is where the install sub command defaults to fetch its packages from | 26 | # This is where the install sub command defaults to fetch its packages from |
| 27 | # ezjail_ftphost=ftp.freebsd.org | 27 | # ezjail_ftphost=ftp.freebsd.org |
| 28 | 28 | ||
| 29 | # This is the command that is being executed by the console subcommand | ||
| 30 | # ezjail_default_execute=/bin/sh | ||
| 31 | |||
| 29 | # base jail will provide a soft link from /usr/bin/perl to /usr/local/bin/perl | 32 | # base jail will provide a soft link from /usr/bin/perl to /usr/local/bin/perl |
| 30 | # to accomodate all scripts using '#!/usr/bin/perl'... | 33 | # to accomodate all scripts using '#!/usr/bin/perl'... |
| 31 | # ezjail_uglyperlhack="YES" | 34 | # ezjail_uglyperlhack="YES" |
diff --git a/man1/ezjail-admin.1 b/man1/ezjail-admin.1 index 4425ac6..81d98d8 100755 --- a/man1/ezjail-admin.1 +++ b/man1/ezjail-admin.1 | |||
| @@ -16,14 +16,20 @@ ezjail-admin \- Administrate ezjail | |||
| 16 | .B ezjail-admin config\fR [-r run|norun] [-n newname] [-i attach|detach|fsck]\fI jailname | 16 | .B ezjail-admin config\fR [-r run|norun] [-n newname] [-i attach|detach|fsck]\fI jailname |
| 17 | 17 | ||
| 18 | .T | 18 | .T |
| 19 | .B ezjail-admin console\fR [-f] [-e command]\fI jailname | ||
| 20 | |||
| 21 | .T | ||
| 19 | .B ezjail-admin install\fR [-mps] [-h host] [-r release] | 22 | .B ezjail-admin install\fR [-mps] [-h host] [-r release] |
| 20 | 23 | ||
| 21 | .T | 24 | .T |
| 22 | .B ezjail-admin update\fR [-s sourcetree] [-i] [-pP] | 25 | .B ezjail-admin update\fR [-s sourcetree] [-i] [-pP] |
| 23 | .SH DESCRIPTION | 26 | .SH DESCRIPTION |
| 24 | The \fB ezjail-admin\fR tool is used to manage jails inside the ezjail | 27 | The \fB ezjail-admin\fR tool is used to manage jails inside the ezjail |
| 25 | scope. It is not used to start or stop ezjails jails. Refer to \fIezjail(5)\fR | 28 | scope. |
| 26 | for more details. | 29 | |
| 30 | It can also be used to start or stop and to get a console in ezjails | ||
| 31 | jails by proxying everything looking like | ||
| 32 | \fBezjail-admin start\fR, \fBstop\fR or \fBrestart\fR to the ezjail rc.d script. | ||
| 27 | .SH ezjail-admin create | 33 | .SH ezjail-admin create |
| 28 | copies the template jail to the root of a new jail, whose name and IP | 34 | copies the template jail to the root of a new jail, whose name and IP |
| 29 | address are provided as mandatory parameters. | 35 | address are provided as mandatory parameters. |
| @@ -87,6 +93,12 @@ renamed as well. | |||
| 87 | You can attach image jails for administrative purposes by the -i attach | 93 | You can attach image jails for administrative purposes by the -i attach |
| 88 | option and detach them with -i detach. It is not possible to run or delete | 94 | option and detach them with -i detach. It is not possible to run or delete |
| 89 | an attached jail. You can force fscking a jail image with the -i fsck command. | 95 | an attached jail. You can force fscking a jail image with the -i fsck command. |
| 96 | .SH ezjail-admin console | ||
| 97 | Attaches your console to a jail by executing a jexec with its jid. | ||
| 98 | |||
| 99 | The command executed in that jail defaults to /bin/sh but can be set with the | ||
| 100 | -e modifier or by the ezjail_default_execute config variable. A non-running | ||
| 101 | jail is not started by default. If you want that, force it with -f. | ||
| 90 | .SH ezjail-admin install | 102 | .SH ezjail-admin install |
| 91 | fetches everything needed to setup a base jail from an FTP server and | 103 | fetches everything needed to setup a base jail from an FTP server and |
| 92 | installs it. | 104 | installs it. |
diff --git a/man5/ezjail.conf.5 b/man5/ezjail.conf.5 index 6afede0..8e00e87 100755 --- a/man5/ezjail.conf.5 +++ b/man5/ezjail.conf.5 | |||
| @@ -46,6 +46,11 @@ This is where the install sub command defaults to fetch its packages from | |||
| 46 | Set to YES, if ezjail should provide a soft link from /usr/bin/perl to /usr/local/bin/perl in base jail. | 46 | Set to YES, if ezjail should provide a soft link from /usr/bin/perl to /usr/local/bin/perl in base jail. |
| 47 | .br | 47 | .br |
| 48 | .I default: YES | 48 | .I default: YES |
| 49 | .TP | ||
| 50 | .B ezjail_default_execute (str) | ||
| 51 | This is the default command executed in a jail by ezjail-admin console. | ||
| 52 | .br | ||
| 53 | .I default: YES | ||
| 49 | .SH JAIL CREATION OPTIONS | 54 | .SH JAIL CREATION OPTIONS |
| 50 | Default options for newly created jails. Used by the | 55 | Default options for newly created jails. Used by the |
| 51 | .B ezjail-admin(1) | 56 | .B ezjail-admin(1) |
