[squeak-dev] How to shutdown Raspbian from within Squeak?
David T. Lewis
lewis at mail.msen.com
Fri Mar 10 00:36:20 UTC 2017
On Thu, Mar 09, 2017 at 06:53:31PM -0500, Louis LaBrunda wrote:
> Hi Dave and Tim,
>
> Thanks for all the help. I'm running Raspbian Jessie Lite (no desktop or GUI) and Squeak
> headless.
OK good, in that case I don't think you need to worry about entering a password for sudo.
> On boot I auto run Squeak. Given that I didn't load CommandShell, which I think is
> a GUI interface.
CommandShell is not a GUI interface, although it does provide one for both
Morphic and MVC. Mainly it is a simulation of a simple Unix shell, connected
to OSProcess for running the external commands.
Here is something that might do what you want:
shell := CommandShell new.
shell if: 'sudo shutdown -P now'
then: [ Smalltalk snapshot: false andQuit: true ]
else: [ self error: shell errorStream contents ].
This should ensure that the shutdown command has run successfully before you
quit the image. I am pretty sure that the quit will happen before the OS has
a chance to kill it as a result of the shutdown command, so I don't think you
need to worry about timing.
Dave
> Squeak auto runs a Seaside program that only has one user so there is a
> password but no user id. There is a setting screen and a main screen that allows the user to
> control up to 4 relays and view the status of up to 4 sensors/switches.
>
> This first pass is going to a friend where we will install it to control his garage doors thru
> the internet via a smart phone (or any browser). I want to be able to reboot and shutdown from
> the browser just because sometime you need to.
>
> The reboot and shutdown code I used is below. Just before calling those methods, I call a
> method to logoff from the web session.
>
> I'm not sure I need to but it seemed prudent to quit Squeak before shutting down. I wait 10
> seconds to give the logoff time to paint. I wanted to have the shutdown delay for a few
> seconds with the "-t sec" option but on Raspbian the sec option is taken as minutes (seems like
> a bug to me). Anyway the "now" option seems to give Squeak enough time to quit without a
> problem.
>
> Thanks again for the help.
>
> Lou
>
> reboot
> "Reboot the computer."
>
> [
> (Delay forSeconds: 10) wait.
> UnixProcess thisOSProcess command: 'sudo shutdown -r now'.
> Smalltalk snapshot: false andQuit: true.
> ] fork.
>
> shutdown
> "Shutdown the computer."
>
> [
> (Delay forSeconds: 10) wait.
> UnixProcess thisOSProcess command: 'sudo shutdown -P now'.
> Smalltalk snapshot: false andQuit: true.
> ] fork.
>
> On Wed, 8 Mar 2017 20:17:06 -0500, "David T. Lewis" <lewis at mail.msen.com> wrote:
>
> >On Wed, Mar 08, 2017 at 07:33:18PM -0500, David T. Lewis wrote:
> >> On Wed, Mar 08, 2017 at 04:23:45PM -0800, tim Rowledge wrote:
> >> >
> >> > > On 08-03-2017, at 4:07 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> >> > >
> >> > >
> >> > > Having said that, I suspect that the reboot is going to be tricky.
> >> > > The sudo command is designed for security, and it is smart enough not
> >> > > to let the password input come from some arbitrary input stream such as
> >> > > the one connected to your Squeak image. I'll try tinkering around with
> >> > > it a bit, but I'm afraid this may not be not as simple as you might expect.
> >> > Actually on a Pi ???sudo??? is normally password-free, wjich is probably enough to make some people???s heads explode, but there y???are.
> >> >
> >>
> >> Yes, on raspbian it will probably work. The tricky bit is that if you do
> >> need to enter a password, sudo will read the password from the controlling
> >> terminal the Squeak VM process, represented by /dev/tty. That more or less
> >> equates to your keyboard. There is no easy way for Squeak to insert a keyboard
> >> wedge to supply the password keystrokes, which of course is exactly what
> >> was intended from a security point of view.
> >>
> >
> >Actually, that reminds me - and I want to mention it now before I forget about
> >it yet again - I think that the sudo password input issue might be effectively
> >handled with the unix pseudo terminal interface (man 7 pty). Ian Piumarta made
> >a plugin for this along with his really quite amazingly good telnet terminal
> >emulator.
> >
> >That stuff, along with other things such as the VNC server, is still available here:
> >
> > http://squeakvm.org/unix/goodies.html
> >
> >I also recall Ian asking me a long time ago why I didn't add pty support to
> >the OSProcess plugin, which was a very good question, and I probably should have
> >paid attention to it.
> >
> >Dave
> >
> >
> --
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
>
>
More information about the Squeak-dev
mailing list
|