Date: Thu, 20 Dec 2007 18:41:13 +0100 (CET) From: Oliver Fromme <olli@lurza.secnetix.de> To: freebsd-stable@FreeBSD.ORG, 000.fbsd@quip.cz, lists@lozenetz.org Subject: Re: jlogin.sh - a small nice jails helper! Message-ID: <200712201741.lBKHfDRb069152@lurza.secnetix.de> In-Reply-To: <47682873.8050601@quip.cz>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712201741.lBKHfDRb069152>