Accessing filesystem and printing script output

#1

Hi all,

I’ve been following this thread to try and ssh into the etc. It seems like the route to go down includes modifying wpa_supplicant.conf but I am unsure how to get to that file on the filesystem of the etc. What are the commands I need to run to mount the filesystem correctly?

Once I’ve ssh’d into the etc, is it possible to see the output of a running python script? Debugging modes by prayer/hope is pretty time-consuming.

Any guidance would be adored!

0 Likes

#2

If ssh is working for you then use the command scp to transfer the files from your local computer to the ETC. Mac OS has ssh/scp included. For Windows look for WinSCP.
Befor you can write to the filesystem you have to call /root/ETC_Sys/scripts/remount-rw.sh in the ssh shell.

I personally prefer to edit the files on the ETC directly using and editor (vim in my case).

If you are logged in, then stop the ETC-programm (killall python)
Then call /root/ETC_Sys/scripts/etc_start.sh, which starts the program from the commandline. Now you will get all Output on the commandline window, which displays all standardmessages (like, which mode has been loaded) and - more important - all errormessages.

0 Likes

#3

@fanwander I haven’t been able to ssh into the etc at all. Any guidance on how to do that?

0 Likes

#4

There are two prerequesites.
1.) you have to enable the SSH-daemon
2.) the Wifi has to work

To enabling the SSHD can be done via a special MODE, but you don’t get any response of it. So I suggest to use the scripting-possibilities on the USB-drive. Since the run.sh mechanism does not work (@thetechnobear found that), we have to “misuse” Wifi.sh.

The first example starts a local WLAN as described in the manual. I named the network “critternet”

/root/ETC_Sys/scripts/remount-rw.sh
sleep 1
date >> /usbdrive/wifi.log 2>&1
echo "WiFi.sh"  >> /usbdrive/wifi.log 2>&1
systemctl enable sshd   >> /usbdrive/wifi.log 2>&1
sleep 2
systemctl start sshd   >> /usbdrive/wifi.log 2>&1
sleep 2
create_ap wlan0 eth0 critternet >> /usbdrive/wifi.log 2>&1 &
echo "WiFi.sh ended" >> /usbdrive/wifi.log 2>&1

As you can see, I write a log-file wifi.log on the USB-stick.
Be aware, that I put some “sleep” statements in the script. This will make the boot process take 5 seconds longer!

The version running on my ETC is still a bit different. I can select between this local “critternet” and the WLAN at home, depending on a variable “NET” which I set manually in the script:

/root/ETC_Sys/scripts/remount-rw.sh
sleep 2
date >> /usbdrive/wifi.log 2>&1
#NET="critter"
NET="home"
echo "WiFi.sh"  >> /usbdrive/wifi.log 2>&1
echo "NET = $NET" >> /usbdrive/wifi.log 2>&1
systemctl enable sshd   >> /usbdrive/wifi.log 2>&1
sleep 2
systemctl start sshd   >> /usbdrive/wifi.log 2>&1
sleep 2
#### Variation 1 -> local Critternet
if [ $NET = "critter" ] ; then 
   echo "I will setup the critternet" >> /usbdrive/wifi.log 2>&1 
   create_ap wlan0 eth0 critternet >> /usbdrive/wifi.log 2>&1 &
fi
#### Variation 2 -> log on to the home WLAN
if  [ $NET = "home" ] ; then 
    echo "calling wpa_supplicant" >> /usbdrive/wifi.log 2>&1
    wpa_supplicant -B -D nl80211,wext -i wlan0 -c <(wpa_passphrase "YOURNETWORKNAME" "YOUR NETWORKPASSPHRASE") >> /usbdrive/wifi.log 2>&1 &
    sleep 5 
    echo "calling dhcpcd" >> /usbdrive/wifi.log 2>&1 
    dhcpcd wlan0  >> /usbdrive/wifi.log 2>&1 &
fi
echo "WiFi.sh ended" >> /usbdrive/wifi.log 2>&1

This script contains even more sleep commands, because the connection to the home network needs enough time. So this will prolongate the the boot process for 10 seconds.

I hope that helps.

0 Likes

#5

Thanks, that did help. I was able to ssh in. When I run your suggestion of

killall python2
start-etc.sh

I get the error:
“server error 9904: cannot find free port”

and the ETC modes don’t begin to run again. Any insights?

0 Likes

#6

Assumingly the “killall python2” did not succeed to end the python2 process, so the process still exists and blocks a port (for the graphics output?). You should check with:
ps -ef | grep python | grep -v grep
It should return nothing. If there is still a python process listed then you have to kill it with
kill -9 <PROCESSID>

0 Likes