SOLVED Another startup/shutdow scripts question - SSH to a TinyCore Linux Rasperery Pi running PiCorePlayer for UPS initated shutdown transmission

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
Hi all,
I read a lot of posts here, related to my problem, but could not find a solution. So....

Here's the setting:
I need to have another computer running tinycore linux turned off when my Truenas shuts down.
The only way I can do it remotely is by sending a command over ssh.
ssh user@host 'pcp sd'

I set up a keypair based authentication, so password is not a problem.
When I run my command from shell, it works. But when I try to use it via Tasks->Startup/Shutdown scripts, it does not work.

I tried:
-use type "command" with my command line, both with and without full path to ssh command
-create a small script with my command in it, both with and without full path to ssh command and invoke this script with tasks->startup(...)
In my script I inserted a "mkdir" command, in order to check that the script is indeed run at shutdown. Which is the case.

Could it be because the script is not ran as root ? So the ssh keypair would not be used and the ssh command would fail ?

I have no idea what to try next... If anyone has an hint ...

Thank you for your help !
Thomas
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Use a script and put this in the first two lines:
Code:
#! /bin/sh
exec >/root/myscript.log 2>&1

# ... here goes the rest of your script


Then you will be able to examine the log file for errors.
 

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
Use a script and put this in the first two lines:
(...)
Then you will be able to examine the log file for errors.

Hi Patrick, and thanks a lot for this easy trick I hadn't thought of.
It really helped me to find the problem, and to fix it.

In fact, it has nothing to do with TrueNas. Here's the explanation, for future referecence, should anyone face the same problem.

The real problem was that TinyCore Linux has a special way to run : at startup, it will clone the whole system in RAM, and will no longer access the SD Card. In my case, when you use the web UI of PiCorePlayer to make config changes, the changes are automatically reflected back to the SD card.

But since I added the public key using an SSH session, there was no automatic update of the SD card, and this change was lost after the reboot I had triggered manually when testing the command from my TrueNAS SSH session.
All this time I tested my script assuming the ssh passwordless connection was already setup, when in fact that was not the case !

The fix was easy: after copying the public key on the PCP RPI, I just wnet to the web UIand did a manual backup.

I will edit the title of the post to make it more easy to find by someone with the same problem. And add a little more context in the first post.

Thanks again !
 
Top