running screen in rc.d/rc.local cannot be resumed

Post here if you are a new Porteus member and you're looking for some help.
att
Contributor
Contributor
Posts: 137
Joined: 28 Dec 2010, 17:09

running screen in rc.d/rc.local cannot be resumed

Post#1 by att » 19 Jul 2016, 20:23

Hello,

I have modded my porteus a bit so my startscript suits my needs.
Thus:
In /mnt/sdh1/porteus/rootcopy/etc/rc.d/rc.local I have my own commands:

/usr/bin/chmod 777 /root/VPNS/test.sh
/usr/bin/screen -dmS startup-openvpn /root/VPNS/test.sh

So it starts a VPN connection at every reboot automatically.

This works beautifully, but I cannot resume this screen session.

Screen -r says:

bash-4.2# screen -ls
No Sockets found in /root/.screen.

"ps aux" however clearly says that screen is running, and the VPN ip of 10.9.0.x is there.

Also, a "kill -CHLD (pid.of.screen)" does NOT restore the obviously missing /root/.screen/XXXX.pts-1.porteus file.

The SAME command typed in into a normal shell DOES work and the screen CAN be resumed. But it DOES NOT WORK when it is inside the rc.local script. Then the screen CANNOT be resumed.

Any help how to fix that?
Rights are proper.... /root/VPNS/test.sh is chmod 777, etc.etc.

att
Contributor
Contributor
Posts: 137
Joined: 28 Dec 2010, 17:09

Re: running screen in rc.d/rc.local cannot be resumed

Post#2 by att » 19 Jul 2016, 21:05

I found the solution !!!!!

At startup, the "HOME" Variable is not properly defined!

I had to add to my rc.local script the following line:

export HOME="/root"

and then it worked, beautifully!!!!

Hint: If you have a directory called /.screen instead of /root/.screen you have a clue that you need to set your HOME variable in the rc.local script.

Post Reply