puppylinux-woof-CE / woof-CE

woof - the Puppy builder
GNU General Public License v2.0
393 stars 283 forks source link

can't create save file when using ssh (headless) #1716

Open 01micko opened 4 years ago

01micko commented 4 years ago

I've solved the issue of booting headless and connecting via wifi in e8647f4 in PUPMODE=5 so I logged in to a pi over ssh, using mpscan -t 6 -p 22 10.1.1.1 - 10.1.1.254 to find the IP.

However I've tried a few methods to save session;

I didn't try shutdown-config directly. Maybe it will work?

Wondering if @gyrog or @woodenshoe-wi have any ideas?

This is not a raspberry pi specific problem.

s243a commented 4 years ago

Isn't there some flag that is set that triggers snapmergepuppy? I think said flag is created when you press the save button.

01micko commented 4 years ago

@s243a you misunderstand, I can't create the save file from pupmode 5. Perhaps I should change the title.

gyrog commented 4 years ago

shutdownconfig is interactive, but it is supposed to have a non-X mode, so maybe it will work with ssh. The alternative would be to write what is needed diretly to /tmp/shutdownconfig_results.

01micko commented 4 years ago

Thanks @gyrog

I'm using X forwarding so running shutdownconfig directly does work - with bugs.

  1. There is constant loop of a 'broken pipe', varies in frequency but doesn't seem to affect the result.

  2. No matter what reboot routine I try to use, the only one that works is nohup busybox reboot. The touble with that though is that the ssh VT is left hanging, a simple close of the window seems sufficient.

  3. On the pi though (this is a pi specific anomaly) it reboots to pupmode 5. Luckily, I have a gtkdialog GUI to set the default boot option and set it to the raspupave. I can ssh in and run that GUI. Another reboot and we land in pupmode 13, however stuff isn't saved. I need to run save2flash then kill stuff and run nohup busybox reboot

It would be nice to fix all this but I can live without as long as I carefully document my steps. It probably would be better booting pfix=nox and not using X forwarding. I'll try that on the weekend.

01micko commented 4 years ago

shutdownconfig actually works with X forwarding. A save folder is created where I want it.

The problem seems to be rebooting and shutting down, even prepending with nohup.

With out X forwarding may well be the go, but we don't have CLI utils for some things, such as syncing to a time server, need to fix that.

s243a commented 4 years ago

The following issue sounds related to me: "On-the-fly save session on first boot #951" https://github.com/puppylinux-woof-CE/woof-CE/issues/951

found by googling "Pupmode 5"

woodenshoe-wi commented 4 years ago

I don’t know if this will help with the creation of a save file, but this is how I handle remotely rebooting/shutting down a PC. (I’ve always used a monitor/TV with my pis.)

remote-helper

#!/bin/sh

while [ "`ps -f -C sshd | grep 'sshd:'`" != "" ]
do
 sleep 5s
done

exec "$@"

remote-poweroff

#!/bin/sh

nohup remote-helper wmpoweroff > /dev/null 2> /dev/null < /dev/null &

remote-reboot

#!/bin/sh

nohup remote-helper wmreboot > /dev/null 2> /dev/null < /dev/null &

I put them in /root/my-applications/bin but anywhere in PATH should work.

01micko commented 4 years ago

Thanks @woodenshoe-wi , I'll try that.

CollaboratorGCM commented 4 years ago

@Mike, et. al.

Hasn't anyone ever heard of XRDP? It does NOT require ANY software installation on PUP or on Windows or Macs to gain a Multimedia desktop session on a PC where it is actively running. And this open-source uses an encrypted protocol. It has a relatively small footprint and extends services beyond just headless PCs because of its multimedia built-in component. In other words, developers and users alike benefit. It addresses security concerns while providing desktop services beyond that of SSH without the usual headaches associated with SSH use.

Please evaluate for all PUP distributions.

01micko commented 4 years ago

@woodenshoe-wi

Unfortunately I'm using dropbear lightweight ssh daemon so substituting 'dropbear' in your script fails.

However, I can establish if there is an ssh connection with netstat so I modified remote-helper like so:

#/bin/sh 

while netstat | grep 'ssh' | grep -qi 'ESTABLISHED'
do
  sleep 5
  exec "$@"
done

That performs a clean shutdown or reboot whether X is running on the remote or not, whether I request X forwarding (ssh -Y root@$IP_ADDRESS) or not.

Now to test if it works in PUPMODE=5 and makes a save file. If not I can work around that I think, so we can run a remote puppy without ever plugging in a monitor.