> On Sep 29, 2016, at 7:02 AM, the outsider <[email protected]> wrote:
> 
> It would be nice to have shutdown and/or reboot functions on the global zone 
> protected with a yes/no option. 
>  
> It is just something to make the system fool proof, where sender considers 
> himself foolish
>  
> Yesterday I needed to reboot a couple of zones but before that I needed to 
> shutdown some user services first in the zones. 
>  
> So… after 5 logins, taking over user sessions, do stuff, type exit, type init 
> 6, type exit, I ended my last zone with exit, exit, init 6. And rebooted the 
> whole server….
>  
> That moment that your fingers freeze above the keyboard and you stare at the 
> command prompt for 1 minute with your jaw sinking towards the desk….

This is actually a bit of a yak shaving exercise [1], but here goes...

On SmartOS, the global zone root user's login shell is bash(1).  It is fairly 
trivial to set up an alias in ~root/.bashrc for init, and then from within the 
alias call the real init (/usr/sbin/init) by full path.  For examples of how to 
do this, look here:  
http://stackoverflow.com/questions/3231804/in-bash-how-to-add-are-you-sure-y-n-to-any-command-or-alias

Of course, now you have a problem:  since you put the alias in ~root/.bashrc, 
it will be gone after you reboot, because the SmartOS global zone is volatile 
(filesystem is run from ram).  So what you need is an SMF service to copy files 
out of persistent (zpool) storage into /root at boot time.  The details on how 
to do that are here:  
https://wiki.smartos.org/display/DOC/Administering+the+Global+Zone (search for 
"Creating Persistent Services Using SMF").

Back when I was a novice at using SMF I decided that the most low-drag way to 
handle this general case was to have a sparse-populated file hierarchy to tar | 
tar over a running memory filesystem.  Although crude and a bit inelegant, it's 
served me well for almost four years.  I used the xml in the wiki (linked 
above) as a template and had it call /opt/custom/tar-root.sh which contains 
this:

#!/bin/sh

if [ -d /opt/custom/root ]
then
  cd /opt/custom/root
  tar cf - . | (cd / ; tar xfp -)
fi

exit 0

so you could have a file in /opt/custom/root/root/.bashrc and have it end up in 
/root/.bashrc automagically after a reboot.

-r


[1] https://www.techopedia.com/definition/15511/yak-shaving





-------------------------------------------
smartos-discuss
Archives: https://www.listbox.com/member/archive/184463/=now
RSS Feed: https://www.listbox.com/member/archive/rss/184463/25769125-55cfbc00
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=25769125&id_secret=25769125-7688e9fb
Powered by Listbox: http://www.listbox.com

Reply via email to