Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update common.sh with functions for all jails+first migration "console.sh" #792

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bb7f73e
bastille: rename functions to "old" in place of new ones
tschettervictor Jan 6, 2025
dbd303f
common.sh: integrate new functions
tschettervictor Jan 6, 2025
5017ad0
console: new update
tschettervictor Jan 6, 2025
61788cc
fix shellcheck
tschettervictor Jan 6, 2025
53295ba
quick oopsy fix for exporting TARGET
tschettervictor Jan 6, 2025
f766f26
common: move export to after for loop
tschettervictor Jan 6, 2025
02396f5
vnet: start VNET jails at 1 because bastille0 is used as a loopback
tschettervictor Jan 6, 2025
677540a
clone: change interfaces to start with 1 for VNET
tschettervictor Jan 6, 2025
0c2c93c
clone: quietly check for "ether" string when cloning
tschettervictor Jan 6, 2025
49a9ce9
clone: 0>1 for base interface grep
tschettervictor Jan 6, 2025
873a523
common: 0>1 for base interface grep
tschettervictor Jan 6, 2025
e9ad74d
clone: revert VNET function
tschettervictor Jan 6, 2025
a9bd2d5
common.sh: revert VNET function
tschettervictor Jan 6, 2025
5d3f473
common: grep quietly for "check_target_is*" functions
tschettervictor Jan 6, 2025
27fe77d
console: use -s to force start instead of -f
tschettervictor Jan 7, 2025
c4b1d2a
Merge branch 'BastilleBSD:master' into common.sh_functions
tschettervictor Jan 7, 2025
e3a57e2
common: simplify debug message
tschettervictor Jan 7, 2025
0aac59a
console: Change -s to -a
tschettervictor Jan 7, 2025
1882666
common: support single target function error when multi-target selected
tschettervictor Jan 8, 2025
3c49a47
console: jail > jail(s)
tschettervictor Jan 9, 2025
4aff04d
console: missed check_fib function
tschettervictor Jan 9, 2025
fb145b3
common: error when jail name is a number
tschettervictor Jan 10, 2025
d1e475e
common: fix brackets []
tschettervictor Jan 10, 2025
f55335e
common: fix []
tschettervictor Jan 10, 2025
3076765
docs: document JID login for console
tschettervictor Jan 11, 2025
3674c84
docs: add code block for console
tschettervictor Jan 11, 2025
59296d6
console: _jail>TARGET
tschettervictor Jan 14, 2025
edc6f29
common: final revision of changes
tschettervictor Jan 15, 2025
fb1d4fc
Merge branch 'master' into common.sh_functions
tschettervictor Jan 15, 2025
fdff42a
common: fix epair naming
tschettervictor Jan 18, 2025
69ef27f
Merge branch 'master' into common.sh_functions
tschettervictor Jan 18, 2025
342087c
Merge branch 'BastilleBSD:master' into common.sh_functions
tschettervictor Jan 20, 2025
d4d747d
create: Do not allow only numbers in name
tschettervictor Jan 21, 2025
603da3c
common: Adjust fstab function
tschettervictor Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions docs/chapters/subcommands/console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,33 @@
console
=======

This sub-command launches a login shell into the container. Default is password-less
root login.
This sub-command launches a login shell into the container. Default is password-less root login.

.. code-block:: shell

ishmael ~ # bastille console folsom
[folsom]:
root@folsom:~ #

TARGET can also be a running jails JID value.

.. code-block:: shell

ishmael ~ # bastille list
JID IP Address Hostname Path
1 10.1.2.3 ishmael /usr/local/bastille/jails/ishmael/root
ishmael ~ # bastille console 1
[ishmael]:
root@ishmael:~ #

At this point you are logged in to the container and have full shell access. The
system is yours to use and/or abuse as you like. Any changes made inside the
container are limited to the container.

.. code-block:: shell

"Usage: bastille console [option(s)] TARGET [user]"
Options:

-a | --auto Auto mode. Start/stop jail(s) if required.
-x | --debug Enable debug mode.
18 changes: 9 additions & 9 deletions usr/local/bin/bastille
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ EOF
CMD=$1
shift

target_all_jails() {
target_all_jails_old() {
_JAILS=$(/usr/sbin/jls name)
JAILS=""
for _jail in ${_JAILS}; do
Expand All @@ -149,7 +149,7 @@ target_all_jails() {
done
}

check_target_is_running() {
check_target_is_running_old() {
if [ ! "$(/usr/sbin/jls name | awk "/^${TARGET}$/")" ]; then
error_exit "[${TARGET}]: Not started. See 'bastille start ${TARGET}'."
fi
Expand All @@ -164,10 +164,10 @@ version|-v|--version)
help|-h|--help)
usage
;;
bootstrap|create|destroy|etcupdate|export|htop|import|list|mount|rdr|restart|setup|start|top|umount|update|upgrade|verify)
bootstrap|console|create|destroy|export|htop|import|list|mount|rdr|restart|setup|start|top|umount|update|upgrade|verify)
# Nothing "extra" to do for these commands. -- cwells
;;
clone|config|cmd|console|convert|cp|edit|limits|pkg|rcp|rename|service|stop|sysrc|tags|template|zfs)
clone|config|cmd|convert|cp|edit|limits|pkg|rcp|rename|service|stop|sysrc|tags|template|zfs)
# Parse the target and ensure it exists. -- cwells
if [ $# -eq 0 ]; then # No target was given, so show the command's help. -- cwells
PARAMS='help'
Expand All @@ -188,15 +188,15 @@ clone|config|cmd|console|convert|cp|edit|limits|pkg|rcp|rename|service|stop|sysr
fi

if [ "${TARGET}" = 'ALL' ]; then
target_all_jails
target_all_jails_old
elif [ "${CMD}" = "pkg" ] && [ "${TARGET}" = '-H' ] || [ "${TARGET}" = '--host' ]; then
TARGET="${1}"
USE_HOST_PKG=1
if [ "${TARGET}" = 'ALL' ]; then
target_all_jails
target_all_jails_old
else
JAILS="${TARGET}"
check_target_is_running
check_target_is_running_old
fi
shift
elif [ "${CMD}" = 'template' ] && [ "${TARGET}" = '--convert' ]; then
Expand All @@ -212,8 +212,8 @@ clone|config|cmd|console|convert|cp|edit|limits|pkg|rcp|rename|service|stop|sysr
fi

case "${CMD}" in
cmd|console|pkg|service|stop|sysrc|template)
check_target_is_running
cmd|pkg|service|stop|sysrc|template)
check_target_is_running_old
;;
convert|rename)
# Require the target to be stopped. -- cwells
Expand Down
Loading