jlogin.sh - a small nice jails helper!
Oliver Fromme
olli at lurza.secnetix.de
Thu Dec 20 09:41:22 PST 2007
Miroslav Lachman wrote:
> It is nice idea, but I think you should have a better scripting style ;)
Yes, it almost looked like perl. :-)
May I suggest a few further improvements?
> login_shell="/bin/tcsh"
I certainly wouldn't want tcsh. How about looking at
$SHELL, and if it doesn't exist, then fall back to the
standard shell (which is /bin/sh).
Also, the last command (jexec) should be preceded by
"exec" so the shell doesn't hang around. So the last
part of the script would look like this:
jail_path=$(jls | awk '$1=='$jail_id' {print $4}')
if [ -z "$SHELL" -o ! -x "$jail_path/$SHELL" ]; then
login_shell="$SHELL"
else
login_shell="/bin/sh"
fi
echo "Logging in to $jail_hostname"
exec jexec $jail_id $login_shell
Best regards
Oliver
PS: By the way, here's another useful script that displays
processes running in jails, ordered by jail IDs:
http://www.secnetix.de/~olli/scripts/jps
--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart
FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd
One Unix to rule them all, One Resolver to find them,
One IP to bring them all and in the zone to bind them.
More information about the freebsd-stable
mailing list