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

Debug mode option #791

Closed
wants to merge 6 commits into from
Closed

Conversation

JRGTH
Copy link
Collaborator

@JRGTH JRGTH commented Jan 5, 2025

This is a quick enhancement I've added since bastille is getting several PR's lately, so this will be useful for quick track down issues, the debug option has been added to common.sh so the option can be added to others command as well if needed.

Regards!

JRGTH added 2 commits January 5, 2025 16:00
Add start/stop debug mode option/function for development debugging ease.
@JRGTH JRGTH self-assigned this Jan 5, 2025
@JRGTH
Copy link
Collaborator Author

JRGTH commented Jan 5, 2025

This will add the following behavior if debug mode is requested with either options -x,--debug useful for developers and end user as well to track down issues.

# bastille start
Usage: bastille start TARGET [option]
    Options:

    -x | --debug  -- Start the Jail(s) with debug mode to track down startup issues.
# bastille stop
Usage: bastille stop TARGET [option]
    Options:

    -x | --debug  -- Stop the Jail(s) with debug mode to track down stop issues.

Sample output:

root@nas-mserver: ~# bastille start jail_0
[jail_0]:
jail_0: created

root@nas-mserver: ~# bastille start jail_1 -x
***DEBUG MODE START***
+ shift
+ [ 0 -gt 0 ]
+ start_loop
+ [ jail_1 '=' ALL ]
+ [ jail_1 '!=' ALL ]
+ bastille list jails
+ awk '/^jail_1$/'
+ JAILS=jail_1
+ [ ! -d /mnt/storage/bastille/jails/jail_1 ]
+ /usr/sbin/jls name
+ awk '/^jail_1$/'
+ [ '' ]
+ /usr/sbin/jls name
+ awk '/^jail_1$/'
+ [ ! '' ]
+ bastille config jail_1 get vnet
+ [ 'not set' '!=' enabled ]
+ bastille config jail_1 get interface
+ _interface=em0
+ ifconfig
+ grep ^em0:
+ bastille config jail_1 get ip4.addr
+ _ip4=10.0.0.11
+ [ 10.0.0.11 '!=' 'not set' ]
+ ifconfig
+ grep -wF 10.0.0.11
+ pfctl -q -t jails -T add 10.0.0.11
+ info '[jail_1]:'
+ echo -e '\033[0;32m[jail_1]:\033[0;0m'
[jail_1]:
+ jail -f /mnt/storage/bastille/jails/jail_1/jail.conf -c jail_1
jail_1: created
+ [ -s /mnt/storage/bastille/jails/jail_1/rctl.conf ]
+ [ -s /mnt/storage/bastille/jails/jail_1/rdr.conf ]
+ echo

+ [ 1 -eq 1 ]
+ warn '***DEBUG MODE END***'
+ echo -e '\033[1;33m***DEBUG MODE END***\033[0;0m'
***DEBUG MODE END***
root@nas-mserver: ~# bastille stop jail_0
[jail_0]:
jail_0: removed

root@nas-mserver: ~# bastille stop jail_1 --debug
***DEBUG MODE START***
+ shift
+ [ 0 -gt 0 ]
+ stop_loop
+ /usr/sbin/jls name
+ awk '/^jail_1$/'
+ [ jail_1 ]
+ bastille config jail_1 get ip4.addr
+ _ip4=10.0.0.11
+ [ 10.0.0.11 '!=' 'not set' ]
+ bastille rdr jail_1 list
+ [ '' ]
+ [ -s /mnt/storage/bastille/jails/jail_1/rctl.conf ]
+ info '[jail_1]:'
+ echo -e '\033[0;32m[jail_1]:\033[0;0m'
[jail_1]:
+ jail -f /mnt/storage/bastille/jails/jail_1/jail.conf -r jail_1
jail_1: removed
+ [ -n '' ]
+ echo

+ [ 1 -eq 1 ]
+ warn '***DEBUG MODE END***'
+ echo -e '\033[1;33m***DEBUG MODE END***\033[0;0m'
***DEBUG MODE END***
root@nas-mserver: ~#

@tschettervictor
Copy link
Collaborator

Take a look at my "new_rewrite" branch and see if you are ok with the way I'm handling options.

I'd like to stay consistent, and would be nice if we could agree on something.

@JRGTH
Copy link
Collaborator Author

JRGTH commented Jan 6, 2025

Take a look at my "new_rewrite" branch and see if you are ok with the way I'm handling options.

I'd like to stay consistent, and would be nice if we could agree on something.

Hi @tschettervictor, I've look at your "new_rewrite" branch and saw you've added some overall improvements/update bits to start/stop commands, while I've followed the previous/current code for the added options in a rush.

Are you ok if I adjust some bits here to follow the overall consistency with you?, so you can adjust your PR with your new update/content after, or do you like me to close this PR so I can add the debug options on a later time.

Between your case/esac options handling seems to be consistent/readable with the overall code.

Regards!

@tschettervictor
Copy link
Collaborator

I'm happy to work on bastille adding these improvements.

If you could test PR #792 we could move ahead with this. It bring in the new common.sh file, as well as adding JID support for console and jail autocomplete.

@tschettervictor
Copy link
Collaborator

@JRGTH If you're ok with closing this, we can add the debug (PR #790) option in a cleaner way.

@bmac2
Copy link
Collaborator

bmac2 commented Jan 8, 2025

@JRGTH are you ok with closing this one and working with @tschettervictor on his PR to put all the features you want in his branch so we can test it all at once? Let me know.

Hop in Discord if you want to discuss.

@JRGTH
Copy link
Collaborator Author

JRGTH commented Jan 8, 2025

@JRGTH are you ok with closing this one and working with @tschettervictor on his PR to put all the features you want in his branch so we can test it all at once? Let me know.

Hop in Discord if you want to discuss.

Hey! Barry nice to hear you man, sure I will close this to avoid possible conflicts since @tschettervictor can add the bits in his existing enhancements PR's

Regards!

@JRGTH
Copy link
Collaborator Author

JRGTH commented Jan 8, 2025

Closed as suggested by @bmac2, @tschettervictor will merge the enable_debug option on his PR's.
Regards!

@JRGTH JRGTH closed this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants