FreeBSD jails: how to login /jexec JID SHELL/ quickly in a jail by name (jlog command)?
Posted by valqk on
Have you ever wondered why the heck you write jls then jexec JID /bin/csh?
I got sick of this few year ago and I wrote a tiny little script that makes my life easy every day.
Be warned, there are few cases when you'll have to see your jid but this works with jid too.
(for example when you have hang jail that won't shutdown /stop/ - happens to me pretty often and this is reported as non-critical bug for years...)
How it works?
Let's pretend that we have a jail named: 'mailserver.valqk.com'. Then you simply type this to get in the mailserver:
It's that easy. Also you can add a preffered custom shell for this session after the jail (or part) name.
What looks like the script itself?
There it goes:
I'll definitely add changes if I like them!!!
I got sick of this few year ago and I wrote a tiny little script that makes my life easy every day.
Be warned, there are few cases when you'll have to see your jid but this works with jid too.
(for example when you have hang jail that won't shutdown /stop/ - happens to me pretty often and this is reported as non-critical bug for years...)
How it works?
Let's pretend that we have a jail named: 'mailserver.valqk.com'. Then you simply type this to get in the mailserver:
#>jlog mail Logging in to mailserver.valqk.com mailserver#
It's that easy. Also you can add a preffered custom shell for this session after the jail (or part) name.
What looks like the script itself?
There it goes:
#!/bin/sh [ -z "$1" ] && echo "No jail specified." && exit 1; [ -z "$2" ] && loginSHELL="/bin/tcsh" || loginSHELL="$2" jName=$1; jID=`jls | grep $jName|awk '{print $1}'` jRealName=`jls | grep $jName|awk '{print $3}'` [ -z "$jID" ] && echo "No such jail name $jName!" && exit 1; echo "Logging in to $jRealName" jexec $jID $loginSHELLplease feel free to use, comment, improve this script! If you make any improvements, pls tell me!
I'll definitely add changes if I like them!!!
Trackbacks
Trackback specific URI for this entryThis link is not meant to be clicked. It contains the trackback URI for this entry. You can use this URI to send ping- & trackbacks from your own blog to this entry. To copy the link, right click and select "Copy Shortcut" in Internet Explorer or "Copy Link Location" in Mozilla.
No Trackbacks
Comments
Display comments as Linear | ThreadedNo comments