Announcement

Collapse
No announcement yet.

[INFO] HS systemd script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Originally posted by ARA View Post
    As Jon says, the web interface should also shutdown when HS3 is stopped. If you can still use it and issue commands, something interesting is happening and HS3 is not shutting down.

    Now, systemd is supposed to restart HS3 if it fails. That's the "Restart=on-failure" line in the HS3 unit file. If you are executing the shutdown event via the Web UI, it might be that systemd detects this as a failure and automatically restarts it. (My theory is that HS3 doesn't have any Linux IPC, so it can't tell systemd that it exited cleanly - systemd assumes it failed and restarts it.)

    As Jon mentioned, using "systemctl stop homeseer" should stop HS3.
    And post the result?

    -Alex

    Could not having a HomeSeer user do this? I do everything as root and don't have a HomeSeer user created or used. Also the restart sounds logical as the Web ui does go down for like a 1min but then comes back and starts working again.

    Comment


      #32
      Originally posted by jon102034050 View Post
      That isn't right, the web ui should also be stopping. Can you run the following as the homeseer user?

      ps -ef | grep -i homeseer
      Am I supposed to do that after it's shut down? This is what it looks like running.

      root@raspberrypi:~# ps -ef | grep -i homeseer
      root 8709 1 29 09:34 ? 03:13:46 /usr/bin/mono /usr/local/HomeSeer/HSConsole.exe --log
      root 8754 8709 0 09:34 ? 00:05:02 /usr/bin/mono /usr/local/HomeSeer/HSPI_PUSHOVER.exe
      root 8769 8709 1 09:35 ? 00:12:30 /usr/bin/mono /usr/local/HomeSeer/HSPI_ULTRAWEATHERWU3.exe
      root 8796 8709 2 09:35 ? 00:18:49 /usr/bin/mono /usr/local/HomeSeer/HSPI_Sonos.exe
      root 8808 8709 22 09:35 ? 02:25:11 /usr/bin/mono /usr/local/HomeSeer/HSPI_BLLAN.exe
      root 8857 8709 1 09:35 ? 00:12:11 /usr/bin/mono /usr/local/HomeSeer/HSPI_THINKINGCLEANER.exe
      root 8871 8709 2 09:35 ? 00:19:01 /usr/bin/mono /usr/local/HomeSeer/HSPI_HSTOUCH.exe
      root 8885 8709 1 09:35 ? 00:11:51 /usr/bin/mono /usr/local/HomeSeer/HSPI_EasyTrigger.exe
      root 8902 8709 1 09:35 ? 00:12:22 /usr/bin/mono /usr/local/HomeSeer/HSPI_ImperiHome.exe
      root 8930 8709 0 09:35 ? 00:05:29 /usr/bin/mono /usr/local/HomeSeer/HSPI_BI.exe
      root 8957 8709 1 09:35 ? 00:11:41 /usr/bin/mono /usr/local/HomeSeer/HSPI_BLBackup.exe
      root 12642 12513 0 20:21 pts/0 00:00:00 grep -i homeseer
      root 16990 8709 2 13:06 ? 00:11:27 /usr/bin/mono /usr/local/HomeSeer/HSPI_OpenSprinkler.exe
      root@raspberrypi:~#

      Comment


        #33
        Originally posted by integlikewhoa View Post
        Could not having a HomeSeer user do this? I do everything as root and don't have a HomeSeer user created or used. Also the restart sounds logical as the Web ui does go down for like a 1min but then comes back and starts working again.
        No, I use root as well (because I'm lazy and haven't switched it yet). Just do a shutdown using the systemctl command, not the webui. I don't doubt what ARA is saying that systemd thinks its getting killed so it attempts to restart it

        Originally posted by integlikewhoa View Post
        Am I supposed to do that after it's shut down? This is what it looks like running.
        Do it after it is shutdown, yes.

        Comment


          #34
          Originally posted by jon102034050 View Post
          No, I use root as well (because I'm lazy and haven't switched it yet). Just do a shutdown using the systemctl command, not the webui. I don't doubt what ARA is saying that systemd thinks its getting killed so it attempts to restart it



          Do it after it is shutdown, yes.
          Just ran his commands and found some errors, working on that now.

          root@raspberrypi:~# systemctl stop homeseer.service
          root@raspberrypi:~# systemctl status homeseer.service
          ● homeseer.service - HomeSeer HS3 Home Automation Server
          Loaded: loaded (/etc/systemd/system/homeseer.service; enabled)
          Active: failed (Result: exit-code) since Mon 2016-10-10 20:27:13 PDT; 36s ago
          Process: 13431 ExecStop=/usr/local/HomeSeer/stop_homeseer.sh (code=exited, status=2)
          Main PID: 8709 (code=killed, signal=TERM)

          Oct 10 20:24:13 raspberrypi mono[8709]: [10/10/2016 20:24:13] Message Total Reset
          Oct 10 20:25:13 raspberrypi mono[8709]: [10/10/2016 20:25:13] Message Total Reset
          Oct 10 20:26:13 raspberrypi mono[8709]: [10/10/2016 20:26:13] Message Total Reset
          Oct 10 20:27:13 raspberrypi systemd[1]: Stopping HomeSeer HS3 Home Automation Server...
          Oct 10 20:27:13 raspberrypi stop_homeseer.sh[13431]: /usr/local/HomeSeer/stop_homeseer.sh: line 2: cd: /usr/local/homeseer/HomeSeer: No such file or directory
          Oct 10 20:27:13 raspberrypi stop_homeseer.sh[13431]: curl: option --XXXXXX:XXXXX: is unknown
          Oct 10 20:27:13 raspberrypi stop_homeseer.sh[13431]: curl: try 'curl --help' or 'curl --manual' for more information
          Oct 10 20:27:13 raspberrypi systemd[1]: homeseer.service: control process exited, code=exited status=2
          Oct 10 20:27:13 raspberrypi systemd[1]: Stopped HomeSeer HS3 Home Automation Server.
          Oct 10 20:27:13 raspberrypi systemd[1]: Unit homeseer.service entered failed state.
          root@raspberrypi:~#
          I XXX'd the user and password above but seems to be a problem there and with the file directory.

          Comment


            #35
            Originally posted by integlikewhoa View Post
            Just ran his commands and found some errors, working on that now.



            I XXX'd the user and password above but seems to be a problem there and with the file directory.
            Looks like you typo'ed the /usr/local/homeseer/HomeSeer in the stop_homeseer.sh?

            Comment


              #36
              Originally posted by jon102034050 View Post
              Looks like you typo'ed the /usr/local/homeseer/HomeSeer in the stop_homeseer.sh?
              Yes. I just edited that.

              Comment


                #37
                Originally posted by integlikewhoa View Post
                Yes. I just edited that.
                Wanna re-run and post results again?

                Comment


                  #38
                  Originally posted by jon102034050 View Post
                  Wanna re-run and post results again?
                  THis

                  root@raspberrypi:~# systemctl stop homeseer.service
                  root@raspberrypi:~# systemctl status homeseer.service
                  ● homeseer.service - HomeSeer HS3 Home Automation Server
                  Loaded: loaded (/etc/systemd/system/homeseer.service; enabled)
                  Active: failed (Result: exit-code) since Mon 2016-10-10 20:45:44 PDT; 11s ago
                  Process: 1610 ExecStop=/usr/local/HomeSeer/stop_homeseer.sh (code=exited, status=2)
                  Process: 730 ExecStart=/usr/bin/mono /usr/local/HomeSeer/HSConsole.exe --log (code=killed, signal=TERM)
                  Main PID: 730 (code=killed, signal=TERM)

                  Oct 10 20:44:47 raspberrypi mono[730]: [10/10/2016 20:44:47] ActionName() 3
                  Oct 10 20:44:47 raspberrypi mono[730]: [10/10/2016 20:44:47] ActionName Return: Change Emergency Settings
                  Oct 10 20:44:47 raspberrypi mono[730]: Action count for instance:
                  Oct 10 20:45:26 raspberrypi mono[730]: [10/10/2016 20:45:26] Message Total Reset
                  Oct 10 20:45:44 raspberrypi systemd[1]: Stopping HomeSeer HS3 Home Automation Server...
                  Oct 10 20:45:44 raspberrypi stop_homeseer.sh[1610]: curl: option --XXXXXX:XXXXX: is unknown
                  Oct 10 20:45:44 raspberrypi stop_homeseer.sh[1610]: curl: try 'curl --help' or 'curl --manual' for more information
                  Oct 10 20:45:44 raspberrypi systemd[1]: homeseer.service: control process exited, code=exited status=2
                  Oct 10 20:45:44 raspberrypi systemd[1]: Stopped HomeSeer HS3 Home Automation Server.
                  Oct 10 20:45:44 raspberrypi systemd[1]: Unit homeseer.service entered failed state.
                  root@raspberrypi:~#
                  Is the xxx'd password wrong? Is that a HS3 User password or a Linux Root:Password?

                  Also the WEB is staying down now. So it is shutting down.

                  Comment


                    #39
                    Originally posted by integlikewhoa View Post
                    THis



                    Is the xxx'd password wrong? Is that a HS3 User password or a Linux Root:Password?

                    Do you have authentication setup to get to the HS web ui? If not, you don't need a username/password in this curl command. It looks like the syntax of the command is wrong, can you paste the command and just blank out the user/pass?

                    Comment


                      #40
                      Originally posted by jon102034050 View Post
                      Do you have authentication setup to get to the HS web ui? If not, you don't need a username/password in this curl command. It looks like the syntax of the command is wrong, can you paste the command and just blank out the user/pass?
                      #!/bin/bash
                      cd /usr/local/HomeSeer
                      exec /usr/bin/curl --XXXXXX:XXXXXX 'http://192.168.1.245:10201/JSON?request=runevent&group=Admin&name=Shutdown'

                      For local connection user and password is turned off. So I'm assuming I shouldnt need a user and password.

                      I'm also unsure of the cd then exec in a different folder. That look correct?

                      Comment


                        #41
                        Originally posted by integlikewhoa View Post
                        #!/bin/bash
                        cd /usr/local/HomeSeer
                        exec /usr/bin/curl --XXXXXX:XXXXXX 'http://192.168.1.245:10201/JSON?request=runevent&group=Admin&name=Shutdown'

                        For local connection user and password is turned off. So I'm assuming I shouldnt need a user and password.

                        I'm also unsure of the cd then exec in a different folder. That look correct?
                        I'm not sure why you're running exec... I believe this is what your script should look like (if you are indeed using authentication, or else, you can remove the --user USERNAME:PASSWORD):

                        #!/bin/bash
                        cd /usr/local/HomeSeer
                        /usr/bin/curl --user USERNAME:PASSWORD 'http://192.168.1.245:10201/JSON?request=runevent&group=Admin&name=Shutdown'
                        sleep 30s

                        Comment


                          #42
                          Originally posted by jon102034050 View Post
                          I'm not sure why you're running exec... I believe this is what your script should look like (if you are indeed using authentication, or else, you can remove the --user USERNAME:PASSWORD):

                          #!/bin/bash
                          cd /usr/local/HomeSeer
                          /usr/bin/curl --user USERNAME:PASSWORD 'http://192.168.1.245:10201/JSON?request=runevent&group=Admin&name=Shutdown'
                          sleep 30s
                          Ok, I removed the password.

                          The sleep 30s caused a pause after I ran the shutdown.

                          then I ran the status and got this.

                          root@raspberrypi:~# systemctl stop homeseer
                          root@raspberrypi:~# systemctl status homeseer
                          ● homeseer.service - HomeSeer HS3 Home Automation Server
                          Loaded: loaded (/etc/systemd/system/homeseer.service; enabled)
                          Active: inactive (dead) since Mon 2016-10-10 21:06:22 PDT; 4s ago
                          Process: 2500 ExecStop=/usr/local/HomeSeer/stop_homeseer.sh (code=exited, status=0/SUCCESS)
                          Process: 727 ExecStart=/usr/bin/mono /usr/local/HomeSeer/HSConsole.exe --log (code=killed, signal=TERM)
                          Main PID: 727 (code=killed, signal=TERM)

                          Oct 10 21:05:52 raspberrypi stop_homeseer.sh[2500]: Dload Upload Total Spent Left Speed
                          Oct 10 21:05:52 raspberrypi stop_homeseer.sh[2500]: [155B blob data]
                          Oct 10 21:05:52 raspberrypi stop_homeseer.sh[2500]: { "Response":"ok" }
                          Oct 10 21:05:52 raspberrypi mono[727]: 09:05:52:1766:[Event]->Event Trigger "admin Shutdown"
                          Oct 10 21:05:52 raspberrypi mono[727]: 09:05:52:1866:[Event]->Running script in background: /usr/local/HomeSeer/scripts/DoShutdown.vb
                          Oct 10 21:05:52 raspberrypi mono[727]: Unhandled Exception:
                          Oct 10 21:05:52 raspberrypi mono[727]: System.TypeLoadException: Could not load type 'vbnc.Compiler' from assembly 'vbnc, Version=0.0.0.5943, Culture=neutral, PublicKeyToken=null'.
                          Oct 10 21:05:52 raspberrypi mono[727]: 09:05:52:2862:[Error]->Compiling script /usr/local/HomeSeer/scripts/DoShutdown.vb:
                          Oct 10 21:05:54 raspberrypi mono[727]: [10/10/2016 21:05:54] Message Total Reset
                          Oct 10 21:06:22 raspberrypi systemd[1]: Stopped HomeSeer HS3 Home Automation Server.
                          root@raspberrypi:~#

                          Comment


                            #43
                            Originally posted by integlikewhoa View Post
                            Oct 10 21:05:52 raspberrypi mono[727]: 09:05:52:1866:[Event]->Running script in background: /usr/local/HomeSeer/scripts/DoShutdown.vb
                            Oct 10 21:05:52 raspberrypi mono[727]: Unhandled Exception:
                            Oct 10 21:05:52 raspberrypi mono[727]: System.TypeLoadException: Could not load type 'vbnc.Compiler' from assembly 'vbnc, Version=0.0.0.5943, Culture=neutral, PublicKeyToken=null'.
                            Oct 10 21:05:52 raspberrypi mono[727]: 09:05:52:2862:[Error]->Compiling script /usr/local/HomeSeer/scripts/DoShutdown.vb:
                            This is a little over my head, I know very little about mono, so I'm not sure why you're seeing this. I tried googling it, but couldn't find much. I think we're on the right track, but maybe another expert will chime in....

                            Comment


                              #44
                              Originally posted by jon102034050 View Post
                              This is a little over my head, I know very little about mono, so I'm not sure why you're seeing this. I tried googling it, but couldn't find much. I think we're on the right track, but maybe another expert will chime in....
                              Thanks for your help.

                              Comment


                                #45
                                I must apologize, there was a typo in my post you followed regarding the curl --user option. Without these past few posts I wouldn't have noticed it. I have fixed it now.

                                I don't know much about Mono itself either, but I do remember having trouble with 'vbnc.Compiler' when I first started playing with HS3. I took the easy way out, and installed every Mono package I could (on the idea that I would be learning more). I believe that vbnc is the compiler responsible for Visual Basic -> CLR translation. Without it, we can't compile the *.vb scripts to Mono executables. On OpenSuSE, vbnc is part of the mono-basic package. If you have 'Command Not Found' installed, you can search for it with:
                                Code:
                                $ cnf vbnc
                                else check the package manager.

                                -Alex

                                Comment

                                Working...
                                X