• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Magic Mirror startup script.

Scheduled Pinned Locked Moved Unsolved Troubleshooting
3 Posts 2 Posters 1.5k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    JevanHa
    last edited by Nov 26, 2018, 12:18 PM

    Hello,
    Because I believe that Computers are much better at performing and repeating recurring commands and I regularly forget to do it the right way, I thought it would be nice to create a Magic Mirror startup script for myself. Another reason for making those scripts is for me to better understand how the Operating Systems works.

    I worked with Unix for the last time more than 20 years ago on a Four Phase/Motorola Unix System V Office computers. Very slowly pieces of memory come up from frequently used commands and making useful scripts that sometimes also look a lot like existing Windows environment commands. Sorry for that ;-)

    The script that I have now does almost do what I want. Testing the presence of the Magic Mirror home directory. Then change directory to that directory, and then perform a test on the configuration script for possible syntax errors. No errors found, then start Magic Mirror and enjoy the result. And so far it works nice and easy and the way I like it. But …

    At least that’s what I thought till now. Until I made a error in the configuration script. Despite the syntax error Magic Mirror was starting. And that’s precisely NOT my intention of this startup script. In that case, I want first to solve the error(s) I made.

    The syntax checker test that I found was listed in the MM documentation: ./MagicMirror/npm run config:check. This gives a lot of information about why and where to look for errors when syntax errors are found. Only after the extraction and error code listing the error (echo $?) gives always a 0. And I d’not know why, and what the underlying idea is.

    Changing made into someone else’s script with the danger that after an update or re-installation you lose everything with what you have adjusted in it is great, and that’s why I prefer not to do it. I also do not understand everything in detail with what is being executed in the config_check.js script yet.

    So therefore, in my startup script I run first the “./MagicMirror/npm run config:check” test to receive in a case of a error a nice list with syntax errors and second than I run the command’s “node -c config/config.js” to receive a errorcode -ne 0. Then I test this and decide not to start Magic Mirror but first solving the syntax error. Not the best solution but at the moment I do not know a better way how to do it.

    But I would like to know why the error code cannot be retrieved and what I can do to get it done. Is there anybody who likes to help me and give me a nice solution how to solve this problem ?

    1 Reply Last reply Reply Quote 0
    • B Offline
      BKeyport Module Developer
      last edited by Nov 26, 2018, 1:20 PM

      Personally, I don’t see why you’d have anything more than

      cd ~/MagicMirror
      DISPLAY=:0 npm start

      in your magic mirror startup script. I personally have a 2nd script with the config check in it, so I can see errors and fix them before I manually run the PM2 restart.

      The "E" in "Javascript" stands for "Easy"

      J 1 Reply Last reply Nov 26, 2018, 9:21 PM Reply Quote 0
      • J Offline
        JevanHa @BKeyport
        last edited by Nov 26, 2018, 9:21 PM

        @bkeyport . You’re absolutely right in that, and that’s how I did it all the time. But to create a script where it does not matter where you are at that moment, it seemed like a fun project to start building scripts again.
        Do you happen to have an answer about my questions?

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          3/3
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy