Date: Tue, 18 Dec 2007 21:07:15 +0100 From: Miroslav Lachman <000.fbsd@quip.cz> To: Anton - Valqk <lists@lozenetz.org> Cc: stable@freebsd.org Subject: Re: jlogin.sh - a small nice jails helper! Message-ID: <47682873.8050601@quip.cz> In-Reply-To: <4767E08C.2090803@lozenetz.org> References: <4767E08C.2090803@lozenetz.org>
index | next in thread | previous in thread | raw e-mail
Anton - Valqk wrote:
> Because I'm lazy and love the scripts, I wrote a nice small script that
> matches a jailname and do a jexec JAILPID SHELL
> so I can login fast to my jails.
> According to me, there should be such tool!
> Hopes something like this goes to STABLE!
>
> here it is....
>
> #!/bin/sh
> loginSHELL="/bin/tcsh"
> [ -z "$1" ] && echo "No jail specified." && exit 1;
> jName=$1;
> jID=`jls | awk '{print $1,$3}'|grep $jName|awk '{print $1}'`
> jRealName=`jls | awk '{print $1,$3}'|grep $jName|awk '{print $2}'`
> [ -z "$jID" ] && echo "No such jail name $jName!" && exit 1;
> echo "Logging in to $jRealName"
> jexec $jID $loginSHELL
It is nice idea, but I think you should have a better scripting style ;)
#!/bin/sh
login_shell="/bin/tcsh"
if [ -z "$1" ]; then
echo "No jail specified."
exit 1
fi
jail_name=$1
jail_id=`jls | awk '$3 ~ /^'${jail_name}'\./ { print $1 }'`
jail_hostname=`jls | awk '$3 ~ /^'${jail_name}'\./ { print $3 }'`
if [ -z "$jail_id" ]; then
echo "No such jail name ${jail_name}!"
exit 1
fi
echo "Logging in to ${jail_hostname}"
jexec $jail_id $login_shell
And still there are some imperfections.
1) script assume first part of a hostname as name, but in the rc.conf
jail name can be different
2) script does not expect multiple occurrence of the same first part of
a hostname
example: johndoe.example.org and johndoe.comethingelse.org
3) script does not expect multiple occurrence of exactly matching
hostname (coused by jail zombies)
Miroslav Lachman
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47682873.8050601>
