Announcement

Collapse
No announcement yet.

[INFO] HS systemd script

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

    #46
    Originally posted by ARA View Post
    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
    Ahh, now that you're saying this, it does ring a bell... I think I maybe installed mono complete in order to get around this early on???

    Comment


      #47
      Instructions? I did upgrade mono yesterday from 3.xx to 4.xx to fix some other issues. Instuctions on how to do a complete install would be helpful. Thanks

      Comment


        #48
        Originally posted by integlikewhoa View Post
        Instructions? I did upgrade mono yesterday from 3.xx to 4.xx to fix some other issues. Instuctions on how to do a complete install would be helpful. Thanks
        I'd be very careful with this, as it could break your install.... but, depending on how far into HS you are, that may not be a big deal. Maybe perform a full backup prior to installing this? I'd maybe wait for ARA's advice again on this as a second opinion, but this is what I have installed and working in terms of mono packages

        Code:
        root@nuc:~# dpkg --get-selections | grep mono
        ca-certificates-mono                            install
        fonts-tlwg-mono                                 install
        fonts-tlwg-mono-ttf                             install
        libmono-2.0-dev                                 install
        libmono-accessibility4.0-cil                    install
        libmono-c5-1.1-cil                              install
        libmono-cairo4.0-cil                            install
        libmono-cecil-private-cil                       install
        libmono-cecil-vb0.9-cil                         install
        libmono-cil-dev                                 install
        libmono-codecontracts4.0-cil                    install
        libmono-compilerservices-symbolwriter4.0-cil    install
        libmono-corlib4.5-cil                           install
        libmono-cscompmgd0.0-cil                        install
        libmono-csharp4.0c-cil                          install
        libmono-custommarshalers4.0-cil                 install
        libmono-data-tds4.0-cil                         install
        libmono-db2-1.0-cil                             install
        libmono-debugger-soft4.0a-cil                   install
        libmono-http4.0-cil                             install
        libmono-i18n-cjk4.0-cil                         install
        libmono-i18n-mideast4.0-cil                     install
        libmono-i18n-other4.0-cil                       install
        libmono-i18n-rare4.0-cil                        install
        libmono-i18n-west4.0-cil                        install
        libmono-i18n4.0-all                             install
        libmono-i18n4.0-cil                             install
        libmono-ldap4.0-cil                             install
        libmono-management4.0-cil                       install
        libmono-messaging-rabbitmq4.0-cil               install
        libmono-messaging4.0-cil                        install
        libmono-microsoft-build-engine4.0-cil           install
        libmono-microsoft-build-framework4.0-cil        install
        libmono-microsoft-build-tasks-v4.0-4.0-cil      install
        libmono-microsoft-build-utilities-v4.0-4.0-cil  install
        libmono-microsoft-build4.0-cil                  install
        libmono-microsoft-csharp4.0-cil                 install
        libmono-microsoft-visualbasic10.0-cil           install
        libmono-microsoft-visualc10.0-cil               install
        libmono-microsoft-web-infrastructure1.0-cil     install
        libmono-oracle4.0-cil                           install
        libmono-parallel4.0-cil                         install
        libmono-peapi4.0a-cil                           install
        libmono-posix4.0-cil                            install
        libmono-rabbitmq4.0-cil                         install
        libmono-relaxng4.0-cil                          install
        libmono-security4.0-cil                         install
        libmono-sharpzip4.84-cil                        install
        libmono-simd4.0-cil                             install
        libmono-smdiagnostics0.0-cil                    install
        libmono-sqlite4.0-cil                           install
        libmono-system-componentmodel-composition4.0-cil        install
        libmono-system-componentmodel-dataannotations4.0-cil    install
        libmono-system-configuration-install4.0-cil     install
        libmono-system-configuration4.0-cil             install
        libmono-system-core4.0-cil                      install
        libmono-system-data-datasetextensions4.0-cil    install
        libmono-system-data-entity4.0-cil               install
        libmono-system-data-linq4.0-cil                 install
        libmono-system-data-services-client4.0-cil      install
        libmono-system-data-services4.0-cil             install
        libmono-system-data4.0-cil                      install
        libmono-system-design4.0-cil                    install
        libmono-system-drawing-design4.0-cil            install
        libmono-system-drawing4.0-cil                   install
        libmono-system-dynamic4.0-cil                   install
        libmono-system-enterpriseservices4.0-cil        install
        libmono-system-identitymodel-selectors4.0-cil   install
        libmono-system-identitymodel4.0-cil             install
        libmono-system-io-compression-filesystem4.0-cil install
        libmono-system-io-compression4.0-cil            install
        libmono-system-json-microsoft4.0-cil            install
        libmono-system-json4.0-cil                      install
        libmono-system-ldap-protocols4.0-cil            install
        libmono-system-ldap4.0-cil                      install
        libmono-system-management4.0-cil                install
        libmono-system-messaging4.0-cil                 install
        libmono-system-net-http-formatting4.0-cil       install
        libmono-system-net-http-webrequest4.0-cil       install
        libmono-system-net-http4.0-cil                  install
        libmono-system-net4.0-cil                       install
        libmono-system-numerics4.0-cil                  install
        libmono-system-reactive-core2.2-cil             install
        libmono-system-reactive-debugger2.2-cil         install
        libmono-system-reactive-experimental2.2-cil     install
        libmono-system-reactive-interfaces2.2-cil       install
        libmono-system-reactive-linq2.2-cil             install
        libmono-system-reactive-observable-aliases0.0-cil       install
        libmono-system-reactive-platformservices2.2-cil install
        libmono-system-reactive-providers2.2-cil        install
        libmono-system-reactive-runtime-remoting2.2-cil install
        libmono-system-reactive-windows-forms2.2-cil    install
        libmono-system-reactive-windows-threading2.2-cil        install
        libmono-system-runtime-caching4.0-cil           install
        libmono-system-runtime-durableinstancing4.0-cil install
        libmono-system-runtime-serialization-formatters-soap4.0-cil     install
        libmono-system-runtime-serialization4.0-cil     install
        libmono-system-runtime4.0-cil                   install
        libmono-system-security4.0-cil                  install
        libmono-system-servicemodel-activation4.0-cil   install
        libmono-system-servicemodel-discovery4.0-cil    install
        libmono-system-servicemodel-internals0.0-cil    install
        libmono-system-servicemodel-routing4.0-cil      install
        libmono-system-servicemodel-web4.0-cil          install
        libmono-system-servicemodel4.0a-cil             install
        libmono-system-serviceprocess4.0-cil            install
        libmono-system-threading-tasks-dataflow4.0-cil  install
        libmono-system-transactions4.0-cil              install
        libmono-system-web-abstractions4.0-cil          install
        libmono-system-web-applicationservices4.0-cil   install
        libmono-system-web-dynamicdata4.0-cil           install
        libmono-system-web-extensions-design4.0-cil     install
        libmono-system-web-extensions4.0-cil            install
        libmono-system-web-http-selfhost4.0-cil         install
        libmono-system-web-http-webhost4.0-cil          install
        libmono-system-web-http4.0-cil                  install
        libmono-system-web-mvc3.0-cil                   install
        libmono-system-web-razor2.0-cil                 install
        libmono-system-web-routing4.0-cil               install
        libmono-system-web-services4.0-cil              install
        libmono-system-web-webpages-deployment2.0-cil   install
        libmono-system-web-webpages-razor2.0-cil        install
        libmono-system-web-webpages2.0-cil              install
        libmono-system-web4.0-cil                       install
        libmono-system-windows-forms-datavisualization4.0a-cil  install
        libmono-system-windows-forms4.0-cil             install
        libmono-system-windows4.0-cil                   install
        libmono-system-xaml4.0-cil                      install
        libmono-system-xml-linq4.0-cil                  install
        libmono-system-xml-serialization4.0-cil         install
        libmono-system-xml4.0-cil                       install
        libmono-system4.0-cil                           install
        libmono-tasklets4.0-cil                         install
        libmono-webbrowser4.0-cil                       install
        libmono-webmatrix-data4.0-cil                   install
        libmono-windowsbase4.0-cil                      install
        libmono-xbuild-tasks4.0-cil                     install
        libmonoboehm-2.0-1                              install
        libmonoboehm-2.0-dev                            install
        mono-4.0-gac                                    install
        mono-csharp-shell                               install
        mono-devel                                      install
        mono-gac                                        install
        mono-mcs                                        install
        mono-runtime                                    install
        mono-runtime-common                             install
        mono-runtime-sgen                               install
        mono-vbnc                                       install
        mono-xbuild                                     install
        mono-xsp4                                       install
        mono-xsp4-base                                  install
        ubuntu-mono                                     install

        Comment


          #49
          I started with Mono 4.x.x so missed the 3.x -> 4.x problems. But I have also heard reports of Mono upgrades breaking HS3 installs. I've kept 4.x.x updated (the minor releases - 4.0.x) and haven't run into any problems yet. And it's always a good idea to keep a backup of the HS3 folder when you start to make changes. I just copy the whole main HomeSeer folder to a backups folder in my home directory.

          Here's a list of the Mono packages I have installed:
          Code:
          ~:# rpm -qa | grep mono | sort
          apache2-mod_mono-3.12-3.2.x86_64
          dbus-1-mono-0.63-213.8.x86_64
          libmono-2_0-1-4.0.4-1.8.x86_64
          libmono-2_0-devel-4.0.4-1.8.x86_64
          libmonoboehm-2_0-1-4.0.4-1.8.x86_64
          libmonoboehm-2_0-devel-4.0.4-1.8.x86_64
          libmonosgen-2_0-1-4.0.4-1.8.x86_64
          libmonosgen-2_0-devel-4.0.4-1.8.x86_64
          mono-addins-1.2-3.10.noarch
          mono-addins-devel-1.2-3.10.noarch
          mono-addins-msbuild-1.2-3.10.noarch
          mono-basic-4.0.1-3.2.noarch
          mono-complete-4.0.4-1.8.x86_64
          mono-core-4.0.4-1.8.x86_64
          mono-data-4.0.4-1.8.x86_64
          mono-data-oracle-4.0.4-1.8.x86_64
          mono-data-sqlite-4.0.4-1.8.x86_64
          mono-devel-4.0.4-1.8.x86_64
          monodevelop-5.10.0-154.4.x86_64
          monodevelop-database-5.10-1.2.noarch
          monodoc-core-4.0.4-1.8.x86_64
          mono-extras-4.0.4-1.8.x86_64
          mono-locale-extras-4.0.4-1.8.x86_64
          mono-mvc-4.0.4-1.8.x86_64
          mono-nunit-4.0.4-1.8.x86_64
          mono-reactive-4.0.4-1.8.x86_64
          mono-tools-3.10-2.20.noarch
          mono-uia-2.1-11.2.x86_64
          mono-uia-devel-2.1-11.2.x86_64
          mono-wcf-4.0.4-1.8.x86_64
          mono-web-4.0.4-1.8.x86_64
          mono-winforms-4.0.4-1.8.x86_64
          mono-winfxcore-4.0.4-1.8.x86_64
          patterns-openSUSE-devel_mono-20150918-12.1.x86_64
          Looking over the two lists, you can see that OpenSuSE and Debian/Ubuntu split it into different packages. For vbnc, you'll want to check that the package 'mono-vbnc' is installed. I was able to get a complete set of packages by selecting the pattern for mono-development (I think that brought most everything in, I may have had to select mono-wcf and mono-winforms separately). Jon102034050 will have more relevant advice on this, as the package structure of Ubuntu is closer to Debian.

          -Alex

          Comment


            #50
            just migrated my HS to a new version of Raspbian lite

            hey all, i was a little confused having to use the systemctl instead of the old init.d, but thanks to you guys I was able to get up and running quickly.

            Comment


              #51
              Originally posted by Kerat View Post
              hey all, i was a little confused having to use the systemctl instead of the old init.d, but thanks to you guys I was able to get up and running quickly.
              Yay! This was my goal with this thread, to help at least 1 person!

              Comment


                #52
                Thank you for this thread. It's a bit cleaner than starting in rc.local, and also allows for a clean shutdown when rebooting the box.

                I'm wondering: is there some way to hide the "shutdown" script from HSTouch? I'd hate for my wife to mistakenly shutdown the homeseer server when I'm not home as she'd have no way to get it started again.

                Also, in case anyone is interested, you should also be able to put the homeseer.service control file in /usr/local/lib/systemd/system. (I tend to stick any non-distro stuff in /usr/local.)

                Take care
                Gary

                Comment


                  #53
                  I don't know how to hide events - maybe some combination of virtual devices and user permissions? But as a workaround, you can cause systemd to always restart HS3. In your `homeseer.service` file, change the line:
                  Code:
                  Restart=on-failure
                  To:
                  Code:
                  Restart=always
                  This will cause systemd to restart HS3 if it exits by any method other than:
                  Code:
                  systemctl stop homeseer.service
                  Eg, if the `shutdown` event/script is called via the Web UI or other than with the systemctl command, systemd will detect this and automatically restart HS3.

                  Thanks for pointing out the alternate unit path, I didn't know about that one. I must remember not to confuse it (/usr/local/lib/systemd/system/) with the system directory (/usr/lib/systemd/system/) as the latter will get overwritten during software instillation and update.

                  -Alex

                  Comment


                    #54
                    I tried the "JSON"-method to perform a shutdown, but I always got an "{ "Response":"Error, running event" }" in return and no shutdown was initiated.

                    I edited the curl-command in "stop_homeseer.sh":
                    Code:
                    #!/bin/bash
                    /usr/bin/curl 'http://127.0.0.1/LinuxTools' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'ConfirmShutdownhs=Yes' --compressed
                    sleep 10s
                    That seems to do the trick!

                    My homeseer.service:
                    Code:
                    [Unit]
                    Description=HomeSeer Server
                    After=network.target
                    
                    [Service]
                    WorkingDirectory=/usr/local/HomeSeer
                    ExecStart=/usr/bin/mono /usr/local/HomeSeer/HSConsole.exe --log
                    ExecStop=/usr/local/HomeSeer/scripts/stop_homeseer.sh
                    Restart=on-failure
                    TimeoutStopSec=90
                    
                    [Install]
                    WantedBy=multi-user.target

                    Comment


                      #55
                      Restart Entire System via Event?

                      About to implement this solution to cleanly start, stop HomeSeer and rebooting entire RPi3.

                      Question, is there a way from an HS Event to manually trigger the HS3 to cleanly shutdown and reboot the RPi3 with what is in this thread?

                      Thanks,

                      Jim

                      Comment


                        #56
                        Originally posted by AutomatedJim View Post
                        About to implement this solution to cleanly start, stop HomeSeer and rebooting entire RPi3.

                        Question, is there a way from an HS Event to manually trigger the HS3 to cleanly shutdown and reboot the RPi3 with what is in this thread?

                        Thanks,

                        Jim
                        I can think of one way to do this, not sure it's the best way, but I'm sure it'd work. Create an event that runs a bash script. Inside of that script, you'd have 1 line (this would shutdown HS cleanly assuming your systemd script works):

                        shutdown -r now

                        In fact, you may not need this event... There is a reboot option in the menus already, but I'm not entirely sure how that terminates the HS process. Tools > System > Restart System. Maybe somebody with more knowledge of how this works can chime in.

                        Comment


                          #57
                          Missing something.

                          After copying homeseer.service to lib/systemd/system/, tried to enable, my results:

                          Code:
                          pi@RPi3-HS3PRO:~ $ systemctl enable homeseer.service
                          Failed to execute operation: Access denied
                          What am I doing wrong?

                          Thanks,

                          Jim

                          Comment


                            #58
                            Originally posted by AutomatedJim View Post
                            Missing something.

                            After copying homeseer.service to lib/systemd/system/, tried to enable, my results:

                            Code:
                            pi@RPi3-HS3PRO:~ $ systemctl enable homeseer.service
                            Failed to execute operation: Access denied
                            What am I doing wrong?

                            Thanks,

                            Jim

                            This looks like a permission issue. If you have the root account calling the program you will need to provision access to the HS3 program folder and files.

                            1. Where is your HS3 program folder?
                            2. Are you using a specific account to start the service in your systemd init command?



                            Sent from my iPhone using Tapatalk

                            Comment


                              #59
                              Originally posted by Kerat View Post
                              This looks like a permission issue. If you have the root account calling the program you will need to provision access to the HS3 program folder and files.

                              1. Where is your HS3 program folder?
                              2. Are you using a specific account to start the service in your systemd init command?



                              Sent from my iPhone using Tapatalk
                              2nd this. Only thing to add is that systemctl commands need to be ran as root, and it looks like you're calling it as the 'pi' user.

                              Comment


                                #60
                                As Kerat and Jon pointed out, this is most likely a permissions issue. The systemd `systemctl` command needs to be executed as root. You also mentioned that you put your `homeseer.service` file in `/lib/systemd/system/`. Normally it's recommended to use either `/etc/systemd/system/` or `/usr/local/systemd/system/` for custom configurations.

                                As for shutting down the entire system, Jon is correct, a HS3 Event that runs a Bash scrip is maybe the simplest way to do it. I would also note that there are the commands `reboot` and `poweroff` in addition to the traditional `shutdown` command - they all will need to be run as root.

                                ZoRaC has an interesting solution, in that he uses the actual web interface commands to shutdown HS3. This is simpler (and perhaps cleaner) than having a separate VB scrip as described earlier in the thread. I haven't had a chance to test it yet, but look forward to trying it out. It should also be possible to run the commands for system shutdown and restart. Perhaps he can tell us how he determined the exact curl command to send the HS3 interface?

                                -Alex

                                Comment

                                Working...
                                X