Can you be more specific?
screen
is a Linux application you can install using apt that can emulate a terminal. Many use it to keep a process running when starting it manually from a remote session.
- Install screen
- Run screen
- Start openhab
- Detach from screen (ctrl+a then ctrl+d)
- Safely logout of your linux box
- Use
screen -r
to get back into the session running out
Does the command:
nohup openhab-cli start &
work? I thought it would have…
Looks like Ben beat me to it, but I would run…
screen -S openhab
… then start.sh to start OH. ctrl+a then ctrl+d to detach. Then
screen -r openhab
… to reattach.
Maybe that should be ctrl+a
then d
to detach?
Both versions should work
root@localhost:/home/android# start.sh
.bash: start.sh: command not found
root@localhost:/home/android# cd ..
root@localhost:/home# cd ..
root@localhost:/# cd usr/
root@localhost:/usr# cd share/
root@localhost:/usr/share# cd openhab2/
root@localhost:/usr/share/openhab2# start.sh
bash: start.sh: command not found
root@localhost:/usr/share/openhab2# ls
LICENSE.TXT addons runtime start.sh start_debug.sh
root@localhost:/usr/share/openhab2# start.sh
bash: start.sh: command not found
root@localhost:/usr/share/openhab2# start
bash: start: command not found
root@localhost:/usr/share/openhab2#
it works ok from the terminal. i can close it and it keeps running
but how to make it autostart on boot?
I’m not sure where start.sh is located in an apt install. You should find it in one of these directories…
If I were to guess, I’d try /usr/share/openhab2/start.sh. Also, you’ll need to fully qualify the name. You could go to the direcotry and use ./start.sh, but I recall an issue with that because of how the DIRNAME variable is defined.
root@localhost:/home/android# /usr/share/openhab2/start.sh
Launching the openHAB runtime...
mkdir: cannot create directory '/usr/share/openhab2/userdata/tmp': No such file or directory
KARAF_BASE is not valid: /usr/share/openhab2/userdata
root@localhost:/home/android#
root@localhost:/home/android# cd /usr/share/openhab2
root@localhost:/usr/share/openhab2# ls
LICENSE.TXT addons nohup.out runtime start.sh start_debug.sh
Do you normally run OH as root? If not, change to that user.
i logged in as another user and did
su root
then ran the entire installation process as root
and i am right now as root
changed to another used, and tryed
/usr/share/openhab2/start.sh
with same results
Strange… I’ve seen this reported before. I can’t reproduce it, but I use a manual install, so maybe it has to do with the apt install.
root@localhost:/usr/share/openhab2# /usr/share/openhab2/start.sh
Launching the openHAB runtime...
mkdir: cannot create directory '/usr/share/openhab2/userdata/tmp': No such file or directory
KARAF_BASE is not valid: /usr/share/openhab2/userdata
root@localhost:/usr/share/openhab2# mkdir userdata
root@localhost:/usr/share/openhab2# /usr/share/openhab2/start.sh
Launching the openHAB runtime...
KARAF_ETC is not valid: /usr/share/openhab2/userdata/etc
root@localhost:/usr/share/openhab2# cd userdata
root@localhost:/usr/share/openhab2/userdata# ls
tmp
root@localhost:/usr/share/openhab2/userdata# mkdir etc
root@localhost:/usr/share/openhab2/userdata# /usr/share/openhab2/start.sh
Launching the openHAB runtime...
null
Error occurred shutting down framework: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at org.apache.karaf.main.ConfigProperties.<init>(ConfigProperties.java:2 30)
at org.apache.karaf.main.Main.updateInstancePidAfterShutdown(Main.java:2 27)
at org.apache.karaf.main.Main.main(Main.java:192)
root@localhost:/usr/share/openhab2/userdata#
will try manual install!
Thanks
Have you tried running this in the screen?
ok. i installed it manually
first problem,
if i do:
sudo su -s /bin/bash -c '/opt/openhab2/start.sh' openhab
as in the documentation it goes:
Launching the openHAB runtime...
java.net.SocketException: Permission denied
at java.net.ServerSocket.createImpl(ServerSocket.java:307)
at java.net.ServerSocket.getImpl(ServerSocket.java:257)
at java.net.ServerSocket.bind(ServerSocket.java:375)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at org.apache.karaf.main.InstanceHelper.setupShutdown(InstanceHelper.jav a:142)
at org.apache.karaf.main.Main$KarafLockCallback.lockAcquired(Main.java:7 52)
at org.apache.karaf.main.Main.doMonitor(Main.java:392)
at org.apache.karaf.main.Main.access$100(Main.java:74)
at org.apache.karaf.main.Main$3.run(Main.java:377)
__ _____ ____
____ ____ ___ ____ / / / / | / __ )
/ __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __ |
/ /_/ / /_/ / __/ / / / __ / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/ |_/_____/
/_/ 2.4.0
Release Build
and website never starts
if i do:
sudo su -s /bin/bash -c '/opt/openhab2/start.sh' root
it start ok and website is ok.
Now, how can i set openhab to autostart with linux ?
if i edit /etc/rc.local
and add:
nohup /opt/openhab2/start.sh server &
it goes:
Launching the openHAB runtime...
Error ocurred shutting down framework: java.lang.NumberFormatException: null
another alernative:
/etc/rc.local
nohup sudo su -s /bin/bash -c '/opt/openhab2/start.sh' root &
it startup ok, website ok
after a couple minutes, it stops…
If i try:
screen -S openhab
/opt/openhab2/start.sh
ctrl+a then ctrl+d
Website starts ok
when i close the terminal session the website keeps running ok,.
This seem to be the solution, how do i implement the last one in /etc/rc.local ?
i also tryied
/usr/bin/screen -dmS openhab /opt/openhab2/start.sh
And does nothing.
You could try putting this in rc.local to launch a screen session, and launches OH in the session (this is what we used before setting up the service)…
screen -d -m -S openhab
screen -S openhab -p 0 -X stuff "/opt/openhab2/start.sh$(printf \\r)"
ok. if
placed in rc.local
screen -d -m -S openhab2
screen -S openhab2 -p 0 -X stuff2 "/opt/openhab2/start.sh$(printf \\r)"
nothing happens
websites doesn’t start
can’t see java on top
and i see this:
root@localhost:/home/android# screen -ls
There are screens on:
5830.openhab (01/09/19 05:23:54) (Dead ???)
6011.openhab (01/09/19 05:23:54) (Dead ???)
Remove dead screens with 'screen -wipe'.
2 Sockets in /var/run/screen/S-root.
´
if i do
screen -d -m -S openhab
screen -S openhab -p 0 -X stuff "/opt/openhab2/start.sh$(printf \\r)"
from the terminal, everything works. ok and keeps working even when i close it.
my god, it can’t be so dificut!!
maybe trying with a manual init.d ??
the only problem i have is that i cannot autostart openhab with linux,
Thanks for the patience.
ok. we are moving:
root@localhost:/home# screen -list
There are screens on:
8167.openhab2 (01/09/19 05:44:45) (Detached)
5312.openhab (01/09/19 05:41:11) (Dead ???)
Remove dead screens with 'screen -wipe'.
2 Sockets in /var/run/screen/S-root.
screen -r openhab2
/opt/openhab2/start.sh
root@localhost:~# /opt/openhab2/start.sh
Launching the openHAB runtime...
null
Error occurred shutting down framework: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at org.apache.karaf.main.ConfigProperties.<init>(ConfigProperties.java:230)
at org.apache.karaf.main.Main.updateInstancePidAfterShutdown(Main.java:227)
at org.apache.karaf.main.Main.main(Main.java:192)
root@localhost:~#
same error as before, it had to do with the user.
how can i run:
sudo su -s /bin/bash -c '/opt/openhab2/start.sh' root
in screen instead of
/opt/openhab2/start.sh
YEEEES!!! --------------
created another script
Star2.sh
#!/bin/bash
sudo su -s /bin/bash -c '/opt/openhab2/start.sh' root
an then in
/etc/rc.local
screen -d -m -S openhab2
screen -S openhab2 -p 0 -X stuff "/opt/openhab2/start2.sh$(printf \\r)"
And now it starts automatically!!!
Thanks man for all the help!
Best regards.