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.

    YAPi0 Installer Stretch Lite

    Scheduled Pinned Locked Moved General Discussion
    118 Posts 4 Posters 82.5k Views 3 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.
    • S Offline
      stuartiannaylor
      last edited by stuartiannaylor

      Yet Another Pi Zero Installer.

      https://github.com/StuartIanNaylor/MagicMirrorPi0StretchLite

      Picks up the latest NodeJS LTS from the 10 series and creates sym links rather than dumping everything in …/bin so cleaner to remove and update.
      Also will automatically pick the latest.

      alt text

      Stretch lite on the poor old wee zero isn’t that bad with MM running as above.
      Automated installing just git clone and run the script.

      "In the console ignore the password complaints and at the prompt pi@raspberrypi:~ $ type sudo apt-get install git Then press enter You will have to wait for some wonderfull Pi0 speed but next we will clone (copy) this repository to the pi. Then again at the prompt pi@raspberrypi:~ $ type git clone https://github.com/StuartIanNaylor/MagicMirrorPi0StretchLite Which you can copy by clicking on the green clone or download button and the copy command or just copy and paste the above.

      Then either type or copy & paste chmod a+x ~/MagicMirrorPi0StretchLite/RaspberryPi0.sh && sh ~/MagicMirrorPi0StretchLite/RaspberryPi0.sh"

      1 Reply Last reply Reply Quote 0
      • garblefluxG Offline
        garbleflux Project Sponsor
        last edited by garbleflux

        I still have problems. Afer several installations, I always get after start a white screen:
        “This side can’t be readed - localhost refused to connect
        checking the proxy and the firewall”

        Also, this error message appears after new installation:

        "Extracting node-v10.15.1-linux-armv6l.tar.gz
        Extracting node-v10.15.1-linux-armv6l
        unlink: cannot unlink ‘/usr/bin/pm2’: No such file or directory
        unlink: cannot unlink ‘/usr/sbin/pm2’: No such file or directory
        unlink: cannot unlink ‘/sbin/pm2’: No such file or directory
        unlink: cannot unlink ‘/usr/local/bin/pm2’: No such file or directory

        Trying this command: chmod a+x ~/MagicMirrorPi0StretchLite/RaspberryPi0.sh && sh ~/MagicMirrorPi0StretchLite/RaspberryPi0.sh
        there is an error:
        /home/pi/MagicMirrorPi0StretchLite/RaspberryPi0.sh: 5: /home/pi/MagicMirrorPi0StretchLite/RaspberryPi0.sh: Syntax error: “(” unexpected

        Any ideas?
        Thanks in advance
        Michael

        1 Reply Last reply Reply Quote 0
        • S Offline
          stuartiannaylor
          last edited by stuartiannaylor

          Apols as have been editing and doing new for the last couple of days the unlink is nothing to worry about as if you run the script again it just deletes previous symbolic links.

          I have changed the way I install and going to update that github repo maybe tonight prob tomoz.

          But here is my much prefered method as basically its standard magicmirror install after you have installed node.

          So here is a quick run down from a new flash of Stretch Lite onto your SD.
          Boot the Pi0

          sudo raspi-config
          

          enable ssh, set your wifi, set boot to autologin console

          Do the usual

          sudo apt-get update
          sudo apt-get upgrade
          sudo apt-get dist-upgrade
          
          sudo apt-get install chromium-browser unclutter lightdm git rpd-plym-splash plymouth-x11 xdotool
          

          Then your choice of node install is yours but all I do is create a folder and sym link it as its easy just to delete with another version.
          You can just download the tar from https://nodejs.org/download/release/latest-v10.x/ and untar and copy folder contents into /usr/local/ if you wish.
          Even releases are LTS with v12 almost out, but the below will grab the latest LTS which is https://nodejs.org/download/release/latest-v10.x/node-v10.15.1-linux-armv6l.tar.gz

          so if you create a script node.sh throw this in just to get the latest or just grab it yourself either /usr/local or sym link it to a neater separate folder.

          web_dir="https://nodejs.org/download/release/latest-v10.x/";
          wget -nv -r -l1 --no-parent -A "*linux-armv6l.tar.gz" "$web_dir";
          find . -name "*linux-armv6l.tar.gz" -exec cp {} ~/ \;
          rm nodejs.org -r -f;
          full_file_name=$(find . -type f -name "*linux-armv6l.tar.gz" -printf '%f\n');
          echo "Extracting ${full_file_name}";
          tar -xzf "$full_file_name";
          file_name="${full_file_name%.*.*}";
          echo "Extracting ${file_name}";
          sudo rm -rf /opt/nodejs;
          # This next line will copy Node over to the appropriate folder.
          sudo mv "${file_name}" /opt/nodejs/;
          # Remove existing symlinks
          sudo unlink /usr/bin/node;
          sudo unlink /usr/sbin/node;
          sudo unlink /sbin/node;
          sudo unlink /usr/local/bin/node;
          sudo unlink /usr/bin/npm;
          sudo unlink /usr/sbin/npm;
          sudo unlink /sbin/npm;
          sudo unlink /usr/local/bin/npm;
          sudo unlink /usr/bin/pm2;
          sudo unlink /usr/sbin/pm2;
          sudo unlink /sbin/pm2;
          sudo unlink /usr/local/bin/pm2;
          # Create symlinks to node && npm
          sudo ln -s /opt/nodejs/bin/node /usr/bin/node;
          sudo ln -s /opt/nodejs/bin/node /usr/sbin/node;
          sudo ln -s /opt/nodejs/bin/node /sbin/node;
          sudo ln -s /opt/nodejs/bin/node /usr/local/bin/node;
          sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm;
          sudo ln -s /opt/nodejs/bin/npm /usr/sbin/npm;
          sudo ln -s /opt/nodejs/bin/npm /sbin/npm;
          sudo ln -s /opt/nodejs/bin/npm /usr/local/bin/npm;
          

          then we just clone the main repo

          git clone https://github.com/MichMich/MagicMirror.git
          
          cd ~/MagicMirror
          

          Install magic mirror

          npm install
          

          The only thing we need to do is change the /MagicMirror/run-start.sh from

          if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
          	export DISPLAY=:0 # Set by default display
          fi
          electron js/electron.js $1
          

          to

          if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
          	export DISPLAY=:0 # Set by default display
          	
          fi
          sh xdotool.sh &
          node serveronly $1
          

          electron will not run on the zero hence why we installed chromium and make these changes.
          we will also add xdotool.sh which is a sendkey ctrl+F5 which clears the java cache & refreshes as killing and restarting is heavy lifting for the zero and likely unnecessary.
          When I do the git I will do something where after 3 concurrent refreshes it will kill and restart.

          nano ~/MagicMirror/xdotool.sh paste the following

          export DISPLAY=:0
          export XAUTHORITY=/var/lib/lightdm/.Xauthority
          sleep 25
          xdotool search --onlyvisible --class "chromium" key ctrl+F5
          

          Install PM2 which now complains with the current script with the startup command

          sudo npm install -g pm2
          

          Then add the PM2 sym links

          sudo ln -s /opt/nodejs/bin/pm2 /usr/bin/pm2;
          sudo ln -s /opt/nodejs/bin/pm2 /usr/sbin/pm2;
          sudo ln -s /opt/nodejs/bin/pm2 /sbin/pm2;
          sudo ln -s /opt/nodejs/bin/pm2 /usr/local/bin/pm2
          
          PM2 startup
          

          and that will give you the command for the correct startup so just copy and paste what the startup command tells you, which tells me, prob don’t even need to sym link it.

          sudo env PATH=$PATH:/opt/nodejs/bin /opt/nodejs/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
          

          add the job and save

          pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json
          pm2 save
          

          copy config.js to /MagicMirror/config and sudo reboot.

          I will sort that out as said prob tomoz as actually the install is now far closer to defacto Pi2/3 install.
          I will give you a shout here when complete but the above should get you going.

          [edit] Whoops you need something to autostart chromium
          Configure /home/pi/.Xsession (create new)

          xset s off
          xset -dpms
          xset s noblank
          
          chromium-browser --noerrdialogs --kiosk http://localhost:8080 --incognito --disable-translate --window-size=1920,1080 --window-position=0,0
          

          A final sudo raspi-config and set boot for desktop autologin.

          Job done until I update the git.

          1 Reply Last reply Reply Quote 0
          • S Offline
            stuartiannaylor
            last edited by stuartiannaylor

            https://github.com/StuartIanNaylor/MagicMirror-Install-Guide-Raspberry-0-to-3

            MagicMirror-Install-Guide-Raspberry-0-to-3

            Rather than an install script a guide on how easy it is to install NodeJS and magic mirror works for all Pi and also includes 0 scripts which don’t use the incompatible electron Armv7l package

            Grab you image from raspberrypi.org/downloads/raspbian/

            Its up to you which you use but as in the name Raspbian Raspbian Stretch Lite Latest is the lightest and likely to create the best results.
            For a mirror that will generally be remote and a mirror installing a full desktop is likely pointless.

            Flash the image using Etcher from https://www.balena.io/etcher/
            Boot and then enter your WiFi details as the presumption is you will have a WiFi mirror.

            So our flash is complete and we are going to boot our pi zero and create some settings. All we need is the SSID of your WiFi router (The name it lists up as when you connect) My ssid=“TALKTALKF20CC3” My psk=“VE3JAX5F” (MyWifi password)

            • So we are going to login: login: = pi password = raspberry

            • then type: sudo raspi-config and press enter

            • Choose 2: Network Choose N2: WiFi Select your country. Enter your ssid. Enter your wifi password.

            • Choose 5: Interfaces Choose P2: SSH Yes to enable.

            • Tab to finish and Yes to reboot

            We need a SSH client such as Putty or Bitvise.
            Also Notepad++ is a great little editor that supports Unix & Windows LF/EOF formats.
            If your unsure the sugestions is Bitvise & Notepad++

            When the Pi reboots in the boot console log on screen you should now see a line My IP address is … copy that into the Server Host address and the pi/raspberry login details and login.

            Update your system and install the base packages for MagicMirror

            sudo apt-get update -y
            sudo apt-get upgrade -y
            sudo apt-get dist-upgrade -y
            

            Pi0/1 owners yeap the first boot update/upgrade to get the latest will be a :sleeping: experience with Pi 2/3 owners being slightly less :sleeping:.
            So now we have a completely updated and upgraded Pi and now to install Mirror specific packages.

            sudo apt-get install -y chromium-browser unclutter lightdm git rpd-plym-splash plymouth-x11 xdotool
            

            NodeJS for Pi 0/1 Armv6l is supported but not pakaged due to problems with Chromium compile for electron, this is no problem as the NodeJS NVM NodeVersionManager is excellent and probably should be used for all Pi versions.
            If you have a Pi 2/3 armv7l processor then you can install NodeJS via raspbian packages sudo-apt-get instal… but the NVM gives far better control.
            Read the GitHub ReadMe for a run down of how to use NVM and what it is capable of.
            To install

            curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
            

            As it will tell you close the current SSH console or reboot. So do so and install Node with…

            nvm install --lts
            

            As we will use the latest Long Term Support Version.

            ##Cloning & Installing MagicMirror
            From the MagicMirror site click on repository and copy the url or click the green clone button and copy from there.

            git clone https://github.com/MichMich/MagicMirror.git
            

            Then we will enter the MagicMirror folder and start the install

            cd ~/MagicMirror && npm install
            

            More :sleeping: time.
            So that MagicMirror will autostart and restart on failure we are going to install the NodeJS Process Manager PM2 and if you need further infomation the documentation is great.
            So to install

            npm install pm2@latest -g
            

            Then we are going to ask PM2 for the correct startup command and paste that into the console.

            pm2 startup
            

            Which for me returns, but trust PM2 and not me.

            [PM2] To setup the Startup Script, copy/paste the following command:
            sudo env PATH=$PATH:/home/pi/.nvm/versions/node/v10.15.1/bin /home/pi/.nvm/versions/node/v10.15.1/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
            

            So do as said and copy & paste what PM2 tells you.
            This is where us Pi0/1 and 2/3 owners depart as the need of use of Chromium rather Electron dicates some small changes.
            For Pi 0/1 owners.
            For Pi 2/3 owners the last thing is.

            pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json
            

            Save that for autoboot

            pm2 save
            

            Copy the sample config.js to the config folder

            wget https://raw.githubusercontent.com/StuartIanNaylor/MagicMirror-Install-Guide-Raspberry-0-to-3/master/config.js -O ~/MagicMirror/config/config.js
            

            And we are ready to go with

            DISPLAY=:0 npm start
            

            Thats it unless you wish to read Make things Plymouth pretty and Save my Flash in the above to folders on instructions how to have a MagicMirror splash screen and how to use zram and tools to limit flash writes to a minimium. Apart the last bit about raspi-config and desktop autologin.

            So back to Pi0/1 users.
            The quickest and easiest way is to create a ~/.Xsession file and here is a sample config.

            nano ~/.Xsession
            

            Paste the following

            xset s off
            xset -dpms
            xset s noblank
            sleep 20
            chromium-browser --noerrdialogs --kiosk http://localhost:8080 --incognito --disable-translate --window-size=1920,1080 --window-position=0,0
            

            Then edit run-start.sh

            sed -i 's/electron js\/electron.js /node serveronly /g' ~/MagicMirror/run-start.sh
            

            So it looks like

            if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
            	export DISPLAY=:0 # Set by default display
            fi
            node serveronly $1
            

            So for Desktop Autologin

            sudo raspi-config
            
            • 3 Boot options
            • Desktop/CLI
            • Desktop Autologin

              Then like the P2/3 owners add and save to PM2
            pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json
            

            Save that for autoboot

            pm2 save
            

            Then reboot

            1 Reply Last reply Reply Quote 0
            • garblefluxG Offline
              garbleflux Project Sponsor
              last edited by

              @stuartiannaylor said in YAPi0 Installer Stretch Lite:

              pm2 save

              Great job! I ve got it to work - it runs fine on my Pi0!
              Thank you for your great efforts.
              Michael

              1 Reply Last reply Reply Quote 0
              • S Offline
                stuartiannaylor
                last edited by stuartiannaylor

                What you can do is add a script line to run-start-sh

                Call it xdotool.sh
                so you would have sh xdotool.sh

                after

                if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
                	export DISPLAY=:0 # Set by default display
                	
                fi
                sh xdotool.sh &
                node serveronly $1
                xdotool.sh
                

                xdotool.sh contains

                export DISPLAY=:0
                sleep 25
                xdotool search --onlyvisible --class "chromium" key ctrl+F5
                

                The above will make Chromium refresh on any config.js changes or any restart of the server.

                If have been banging my head against a brick xorg / plymouth combination for no reason than to get a smooth splash screen all the way till the browser displays.
                This seems far more trouble than its worth.
                I included lightdm as thought that might make things easier but might drop it as it seems to make no difference and just adds bloat.

                https://www.semicomplete.com/projects/xdotool/ is excellent for external control just haven’t spent much time with it yet with my plymouth waste of time.

                1 Reply Last reply Reply Quote 0
                • B Offline
                  bdream
                  last edited by

                  @ stuartiannaylor

                  That sounds like exacly what I’m looking for :thumbs_up:

                  I finished my first MagicMirror and looking for tuning options.
                  As exp. I would like to small the case a bit and would be happy to use Rpi0 instead of Rpi3.

                  I followed your instruction “MagicMirror-Install-Guide-Raspberry-0-to-3”

                  I installed a new raspbian “Raspbian Buster with desktop”
                  may this cause my issues not using “Raspbian Buster Lite”?

                  I run in problem with command

                  cd ~/MagicMirror/ && npm install
                  

                  as I got many WARN and ERR messages. I’m not alowed to attach because the file type is .log so I will paste only the WARN and ERR instead of the whole log-file.

                  11359 timing action:extract Completed in 111604ms
                  11360 silly extract lodash@^4.17.13 extracted to /home/pi/MagicMirror/node_modules/.staging/lodash-dee8f977 (111572ms)
                  11361 warn tar ENOENT: no such file or directory, open '/home/pi/MagicMirror/node_modules/.staging/moment-fbf25dd9/min/moment-with-locales.js'
                  11362 warn tar ENOENT: no such file or directory, open '/home/pi/MagicMirror/node_modules/.staging/lodash-20df1054/core.min.js'
                  11363 warn tar ENOENT: no such file or directory, open '/home/pi/MagicMirror/node_modules/.staging/lodash-24d00653/core.min.js'
                  .
                  .
                  .
                  // many similar WARN messages
                  .
                  .
                  .
                  12301 warn tar ENOENT: no such file or directory, open '/home/pi/MagicMirror/node_modules/.staging/rrule-21671673/dist/es5/rrule-tz.js.map'
                  12302 timing stage:rollbackFailedOptional Completed in 170ms
                  12303 timing stage:runTopLevelLifecycles Completed in 545603ms
                  12304 silly saveTree magicmirror@2.8.0
                  12304 silly saveTree ├─┬ chai-as-promised@7.1.1
                  12304 silly saveTree │ └── check-error@1.0.2
                  12304 silly saveTree ├─┬ chai@4.2.0
                  12304 silly saveTree │ ├── assertion-error@1.1.0
                  .
                  .
                  12304 silly saveTree │   ├── parse-ms@1.0.1
                  12304 silly saveTree │   └── plur@1.0.0
                  12304 silly saveTree └── valid-url@1.0.9
                  12305 warn grunt-stylelint@0.11.1 requires a peer of stylelint@^10.0.0 but none is installed. You must install peer dependencies yourself.
                  12306 verbose type system
                  12307 verbose stack FetchError: request to https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443
                  12307 verbose stack     at ClientRequest.req.on.err (/home/pi/.config/versions/node/v10.16.3/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
                  12307 verbose stack     at ClientRequest.emit (events.js:198:13)
                  12307 verbose stack     at TLSSocket.socketErrorListener (_http_client.js:392:9)
                  12307 verbose stack     at TLSSocket.emit (events.js:198:13)
                  12307 verbose stack     at emitErrorNT (internal/streams/destroy.js:91:8)
                  12307 verbose stack     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
                  12307 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)
                  12308 verbose cwd /home/pi/MagicMirror
                  12309 verbose Linux 4.19.66+
                  12310 verbose argv "/home/pi/.config/versions/node/v10.16.3/bin/node" "/home/pi/.config/versions/node/v10.16.3/bin/npm" "install"
                  12311 verbose node v10.16.3
                  12312 verbose npm  v6.9.0
                  12313 error code EAI_AGAIN
                  12314 error errno EAI_AGAIN
                  12315 error request to https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443
                  12316 verbose exit [ 1, true ]
                  
                  

                  Any idea :nerd_face: what to do getting the RasPi0 run?
                  Hold in mind what happen in case of newer MagicMirror software or other updates need to run automaticly.

                  Many thanks, bdream

                  –
                  cheers, bdream

                  S 2 Replies Last reply Reply Quote 0
                  • S Offline
                    sdetweil @bdream
                    last edited by

                    @bdream try my updated installer, I am working to get this to replace the current version…

                    see https://forum.magicmirror.builders/topic/10171/anyone-want-to-try-updated-installer
                    others have reported it works ok on Pi zero

                    rename the MagicMirror folder or remove it before running the installer

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 0
                    • B Offline
                      bdream
                      last edited by

                      ok, many thanks! :grinning_face: I will try it now.
                      Just deleted the MagicMirror folder…

                      If I understand you correctly the new script will replace the old one as:

                      ~~curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash~~
                      
                      bash -c "$(curl -sL https://www.dropbox.com/s/rlh710ng0zwv3vp/raspberry.sh?dl=0)"
                      
                      

                      but all other in your manual will stay. Right?

                      CU, bdream

                      –
                      cheers, bdream

                      S 1 Reply Last reply Reply Quote 0
                      • S Offline
                        sdetweil @bdream
                        last edited by

                        @bdream the installer also fixes pm2 and the screen saver
                        and creates a log of the install process results

                        i don’t think u will need the other steps in the pi0 manual anymore

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 4
                        • 5
                        • 11
                        • 12
                        • 1 / 12
                        • First post
                          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