The Script Step By Step

I thought it might be useful for beginners to go through the installation of Raspberry Pi 2 Jessie (July 2017) and “the script” – so here goes… I’m also doing this to help a friend who had issues installing the script on a Pi late last night, most likely due to network issues….  short answer is - this works…. read on…

JessieFor latest updates on "the script" which now supports Raspbian "Stretch" - here's the main article.

Using this download link to the official Raspberry Pi site, grab the zip file for Raspbian Jessie with Desktop. This is a huge file at 1.54GB so it may take some time depending on your connection.

Meanwhile, also grab “the script” from the link above.  I recommend a good quality SD – something like a Samsung or Sandisk and I usually use 16GB microSDs from one or the other of those two.

Everyone has their favourite tools, on Windows 10 I use SDFormatter to ensure the disk is formatted, then Win32DiskImager to do the actual copying of the image file onto SD.

So while waiting for the file to download – let me remind you what the script does:

Firstly it installs a bunch of prerequisites – so that it can then install or make sure is installed (further options are available):

Apache with PHP
Mosquitto MQTT and clients
NodeJS
Node-Red (and many NODES including my own BigTimer and others)
SQLITE 3
Webmin
MPG123
MC
HaBridge

These tools can be used for many purposes but essentially this was put together to support a DIY home control setup of the kind often discussed on this blog.

On installing and powering up Jessie I noted that with an HDMI adaptor connected and an Ethernet cable connected, the Pi was fully connected to the outside world but would NOT SCP from Windows. A shame as many other boards will do that right from the start, allowing headless connection. However.. I attached a mouse to the Pi and went off to check out the Configuration utility. I enabled SSH in the utility at the press of a mouse -  and now without rebooting, could use WinSCP to connect to the Pi as user pi password raspberry.

Now I was where I wanted to be! In the WinSCP window – and in the PI directory I created a new file called script.sh, copied the script across – and saved the file – ensuring it was in Linux (not PC) format as regards CRLF. I use Microsoft Visual Studio Code for editing such files and on the bottom you can click on CRLF and set that to LF mode – which simply strips the CR from each line as Linux prefers. Notepad++ has such an option hidden away in the edit menu. Normally I have to add execute permissions for the script but it seems that in this case, that is the default for the PI directory.

I opened a terminal (Putty) in WinSCP and noted the temperature at 48c. I started off the script as “./script.sh” without the quotes. Within a minute, the menu came up and I left as defaults except to add HABRIDGE at the bottom… and to remove the incredibly space-wasting WolfRAM and Office as I had no need for them. I selected ok, gave the board a name (pi) and filled in the request for user and admin passwords and left the software to run. How long absolutely depends on the board and the Internet connection but it is not worth looking in until after at least half an hour has transpired. I noted after a few minutes that the temperature was up to 54c. By comparison The little NEO Air generally does the script at 38c but I’ve seen boards as high as 70c.  In this case I have the tiniest heatsink on the Pi2 main processor – same size as the chip.

After 1 hour and 3 minutes and with core temperature at 52c, the process finished. A quick look back through the Putty screen showed no problems at all.

The next step was to use “sudo reboot” to set everything into place.

After a minute I popped up a browser…

http://pi  - showed a simple web page I use as a test
http://pi:82 – showed the HA-Bridge installation
http://pi:1880 – showed Node-Red with all the nodes I’d expect – and dropping an MQTT node into the default flow – giving it 127.0.0.1 as the address and admin username and pass as set up when running the script showed MQTT to be running perfectly. Attempts to run the serial port in Node-Red showed not connected. To fix this required root access and so I went into the terminal as pi and changed the root password to a useful one. I then SCP’d into the terminal as root so I could access files without restriction.

I went into raspi-config, disabled the shell monitoring and enabled the serial port. The board insisted on a reboot at this point. After reboot I found that the serial port worked in Node-Red as expected with a green “connected”.

http://pi:10000 should have shown webmin but did not work.

At this point – a quick look in the /home/pi directory showed a log file which the script had made… in this instance called script.sh-2017-07-24_08h29m.log – there are some warnings in there which are not relevant – the only ERROR as such was to do with WEBMIN – this happens from time to time as whatever they use as a server isn’t 100% reliable. I ran the script again – unticking everything except Webmin… I ran the script… it installed no problem – quick reboot – running.

All done.  The script which WAS marked “experimental” is now called “the script” – and the original how has “old” added to it. Next stop… the new FriendlyArm NanoPi Neo Plus2…

Facebooktwittergoogle_pluspinterestlinkedin

76 thoughts on “The Script Step By Step

  1. Hi Peter,

    I've just run THE script in a new Pi and everything worked fine. Thank you!

    One hint just in case you don't have a HDMI and mouse at hand (like me). Once the Jessie OS image is created in the SD card, create an empty file called ssh.txt. Then move the card to the raspi and it will allow SSH connections and you can use winSCP.

    Then you can connect by ssh and type "sudo raspi-config" and make several adjustments like, users, passwords, activate interfaces, etc.

      1. Pi3 full raspbian jessie.

        Btw, I read some time again you were porting your ESP code to Arduino IDE. Is that progressing?
        I'm quite familiar with Arduino IDE, but Eclipse is a new (big) world for me...

        Regards from Spain!

        1. There is very little programming difference... Eclipse is just an editor - granted, Makefiles are not easy but there are many projects already done that you can take as a base.

      2. AFAIK, the file should be named just "ssh", no extension, is in standard raspbian docs: https://www.raspberrypi.org/documentation/remote-access/ssh/README.md

        3. ENABLE SSH ON A HEADLESS RASPBERRY PI

        For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled, and the file is deleted. The content of the file does not matter: it could contain text, or nothing at all.

    1. Hi it is possible as I've not tested the I2c on a Pi3 (recent addition) that there is something peculiar about the Pi3 and I2c).

      In the /home/pi/.node-red/.settings.js there are TWO lines that refer to i2c - just comment them out...

      Pete.

  2. from now on, everyone please upload the logs somewhere when you ask for help... i added their generation to let you have a better help and we go less blind in the dark without needed info... more will be added, testing going on...

    p.s.: the script can even be run without actual making it executable, by just running it as "bash script.sh"

    1. Hi, I ran the script as instructed but when it's time for node-red to install it will not proceed.
      I inserted my log for you.
      thanks for your help.

  3. an other good tip, in case of Raspberry Pi 0 and 0W, is their setup via usb networking... practically they will use the pc connectivity via an emulated network adapter on the OTG microusb socket, so even the PI 0 (NO connectivity AT ALL...) can go on the net...
    https://www.youtube.com/watch?v=O4oVIsZJDs4
    https://www.youtube.com/watch?v=aL1pWI2K60w

    and of course you can then run The Script, but be prepared to a 2 or 3 hours run: they're equivalent to the RPi1...

    1. If you put a "wpa_supplicant.conf" into boot partition, this will be copied to the right directory (/etc/wpa_supplicant/) at boot.

      Example:

      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      country=DE

      network={
      ssid="myssid"
      psk="mypassword"
      key_mgmt=WPA-PSK
      }

      Change ssid/psk as your needs but dont remove the ->"<-.

      Including the "ssh"-file you are able to completely configure the Pi headless.

  4. One good thing about external antennas is longer range. I have an application that was juuuust out of reach of my WiFi base station, and an external antenna solved the problem.

  5. Hi,
    I can't make that script finish on my Orange Pi Zero. It freezes mstlu during or after installing node red or nodes. I'm running it on a fresh system. Updated or not. Should i make some additional preparations?
    I'm using Armbian Debian Jessie. 32GB Samsung Evo SD Card.

    1. Hi,
      Same problem with me.
      Have made a screenshot with the last line...
      You can also see that the script obviously cannot write the logfile...
      Thanks for advice how to solve this.

        1. how did you run the script?

          from what folder?
          Pi home
          which user?
          Pi
          which command line?
          script.sh

          i see /home/pi//home/pi which is WRONG...
          Then what would be right?

          Thanks from a linux newbie!

              1. no, you did not run script.sh as it's impossible to run a script as such unless you added the current folder to the path, never to be done on unix... nor you run ./script.sh, or bash script.sh... you run /home/pi/script.sh, and that's why you get that double /home/pi//home/pi
                please run the script as it's supposed and advertised to be run...

            1. It's working now! Started script again with

              bash script.sh

              Don't know what this user/pi/user/pi thing was about...
              Now I have to know where (with complete path) the user credentials including passwords are located since I must change these data...
              Thanks for hints!

              1. why didn't you changed them during script running?
                anyway, open script, look for the relevant part (example, the node-red setup), and you'll find where are the files, how credentials are generated, etc... you can't just rerun the script to change them, as this works only first time, for the way they are generated by the various services...

  6. Hi,
    I am new in this mater (this is my first time with MQTT).
    I just install the ubunto in VM and run the scrpits, every thing run very well thank you.
    The Node-Red use for MQTT the localhost (127.0.0.1) work also very well.
    Now I want to use a sonoff but sonoff cannot see this IP, I don't know where and how should this name defined.
    Can you please help me.
    Thanks

      1. Hi Pete,

        Thank you very much for quick answer.
        I am using the Sonoff-Tasmota and I am getting the following messages:

        18:47:51 mDNS: Query done with 0 mqtt services found
        18:47:57 MQTT: Connect FAILED to 127.0.0.1:1883, rc -2. Retry in 10 seconds
        18:48:08 MQTT: Attempting connection...
        18:48:09 mDNS: Query done with 0 mqtt services found
        18:48:15 MQTT: Connect FAILED to 127.0.0.1:1883, rc -2. Retry in 10 seconds

            1. first of all: are you able to identify the ip address of the vm? Login as whatever you want, then do just:
              ifconfig
              and look for the ip address associated to the interface which is NOT "lo"...
              then put THAT ip in your sonoff mqtt configuration, nothing else...

              second: check with whatever virtualization hypervisor you're using and see if the virtual network switch to which is connected the virtual interface associated with the vm is BRIDGED to the physical one, or is NATted... if it's nat, you can only enter in it via your pc and your vm can access it and surf the net, period... in worst scenario, you have a HOST ONLY networking interface, which allows strictly and only communication between host and vm, the vm cannot even surf...

          1. Now I give for the sonoff the user "admin" then I got the communication with the MQTT. I thought that no admin user should be assigned to the sonoff.
            Thanks, I it is great.

  7. Peter I am trying to run xginx with the script. I tried moving the apache server to port 8080. Which worked and did work. I now have your page on 192.168.0.10:8080 and on:80 as well.
    Help please. I am trying to get xginx which will not start to recieve thing for dataplicity which are send from iFTTT. Thanks in advance, and much appreicated.

    1. I usually try to avoid commenting on things I know nothing about - and nginx as an alternative to Apache is one of them. Dataplicity is another and I've only briefly looked at IFTTT. I'll leave further comments to others.

  8. Hi Peter. Ran the script multiple times on a pi3 with raspbian stretch. Script finishes and then after reboot, node-red works for a bit and then stops. When trying to run from cmd line, i get the following:

    Starting as a systemd service.
    Started Node-RED graphical event wiring tool..
    Error loading settings file: /home/pi/.node-red/settings.js
    Error: Cannot find module 'i2c-bus'

    Any ideas?

      1. Thanks MrShark. I did this and then was prompted with a similar message that indicated 'Moment' was missing. I then installed 'npm install moment' and node-red started but all of the additional nodes the script had installed were now missing. btw, I do have the latest version of the script.

        I've just noticed Peter seemed to have commented on this although oddly his response is way up in the thread (out of chronological order). He mentioned to comment out two lines related to i2c in the settings.js file. I'll try that next.

    1. Thanks for the added detail Peter. I'm definitely using the latest version of the script (confirmed twice). Just a quick recap of what i'm doing to see if something stands out.

      Burn Raspbian Stretch image to disk
      Start it on Pi3 and log into Desktop
      Set Wifi password and enable SSH via Raspi Config (also set locale, keyboard, Timezone)
      Reboot
      Set password on PI user due to warning after enabling SSH
      From PC:
      Connect to Pi directory via WinSCP (PI Creds)
      Create 'script.sh' at root of Pi directory
      Open it via notepad++ and pasted in raw script
      Set the EOL to Unix then Save
      Edit properties and grant execute to 'Owner'
      SSH into the PI
      start the script './script.sh'
      Wait...
      Reboot
      Node-Red console and dashboard work.
      Install additional node - works
      All looks good.
      Then, I open Webmin portal and almost immediately Node-Red stops.
      I realized that in each of the times i've tried it, that's what happens. I'm not completely certain that it has something to do with launching Webmin but it does look like there's a correlation.

      Ring any bells?

      1. Ok, I think it's not webmin related now. I'm adding the node-red-contrib-alexa-home-skill node. After installation, I import a flow from my clipboard that was previously working on an past PI. When I deploy, I get an error that the server has lost connection. At that point, it appears that node-red has crashed and I get the same error codes when trying to start it seen in my previous posts. I'll continue investigating. I've snapped an image of my PI (post script run but just before the problem) so I can repeat the situation fairly quickly. I may shift over and try this on a VM to see if I can repeat. That might make it much easier to troubleshoot.

  9. ok, i've now installed the script on a VM of Ubuntu following exactly the steps outlined in your earlier video. All installed, All runs including node-red. I've taken snapshots with VirtualBox so I can repeat the issue. I've now narrowed it down to this. If I install any additional node whether by cmd line (npm install ...) or by the 'Manage Palette' feature, then stop NR and try to restart or reboot, I'm back to the same error (below). Prior to installing any additional nodes, i can build flows, deploy them and they run fine. I can reboot, no problem. I'm completely stumped. I've tried turning logging up to trace but no that has provided no clues. At least nothing obvious. Any other suggestions?

    Starting as a systemd service.
    Started Node-RED graphical event wiring tool..
    Error loading settings file: /home/pi/.node-red/settings.js
    Error: Cannot find module 'i2c-bus'

    1. already answered: install that module or remove that line...
      publish your node-red logs somewhere so we can take a look, anyway...
      but could be just a bogus module recently updated that's causing the error... script always try to install latest...

      1. Thanks for the help MrShark. I was probably unclear in my last message. On both the PI and on my VM the script finishes and all appears to run fine. I can stop/start NR without issue. I can reboot without issue. But as soon as I install ANY net new node, node-red won't restart. (i've tried at least 5 different times by restoring the VM snapshot to a known running state and installing any different node)

        Here are the script logs from my RPI3 install and Ubuntu install. Thanks again.

        RP3
        https://pastebin.com/MEjTKTU4
        Ubuntu
        https://pastebin.com/CMnMQ8ac

        1. on both i see NPM version 5.4.2, while it's clearly advertised at script beginning to NOT update it...

          DON'T SELECT NPM UPDATE FOR NOW - NODE-RED WON'T START UP with NPM 5.0 and NODE 8.0

          and there's a bug in java install on raspbian stretch, we'll take a look...

          1. Antonio is right - big notice at the top of the script not to select that update. I've removed the NPM update option from the menu for now - I've never felt the need to use it anyway. As for Java and Raspbian Stretch... for now I'm at a loss as my notes say 10/08/2017 I installed the script on a new Stretch-equipped Pi3 without a single error.

  10. Gentlemen, thank you so much. Terribly sorry I missed the the message up front in the script. I ran again today without the npm update and it works like a charm. Again thanks for your valuable time.

    1. Further information: the DietPi image I used is based on Stretch. I have since been provided a DietPi v6 image based on Jessie, but I haven't had the chance to try it yet. In looking at my log file, it appears the script thinks I'm running Raspbian.

      -Ben

      1. started from latest dietpi-vm, and it self updated to latest version, it rebooted a few times... swapped dropbear for openssh in dietpi menu, entered with putty and ran THE SCRIPT...

        downloaded latest script: wget https://bitbucket.org/api/2.0/snippets/scargill/ekon6o/master/files/script.sh ran it as root: bash script.sh

        then logged in as pi and run again: bash script.sh
        it asked the usual stuff, i only UNchecked the QUIET option to see what was going on, and checked webmin, grafana and habridge... after 10 minutes, setup was complete, i rebooted: sudo reboot

        there are some problems, indeed...
        1) nodered refused to start: opened logs, i saw that it was the i2c-bus, i had to manually reinstall it:
        cd .node-red ; npm install i2c-bus
        2) webmin changed its repository signing key and actually site is unavailable...
        3) grafana install works only on SBC, i have to check for the url in case of an X86 install
        4) there are problems with sqlite node, it gives some warnings:
        [node-red-node-sqlite/sqlite] Error: Cannot find module '/home/pi/.node-red/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node' (line:5)

    2. unfortunately they changed A LOT of stuff in version 6.X... we need to test everything again... i'll start in a virtual machine as soon as i can, then we'll see...

      p.s.: DON'T update a previous version to version 6.x, you'll break things... dietpi guys say to start from scratch...

  11. Hi Peter,

    I've just run your latest script on a Pi 3 B+ and I'm facing problem with Mosquitto, it won't start on reboot. Any ideas?

    Filip

    1. I have just done an install on a pi 3b+ and whilst I don't get a problem with mosquito on reboot there does seem to be a problem with the node red mqtt node forgetting admin credentials on reboot - mqtt node refuses to connect until they are re-entered.

      1. i've no rpi3b+ to test, but both issues seem not related to script, but to something changed in nodered or on the linux of that specific board... the only way to test it is that who has it does more tests and gives logs back... buy some spare sdcard and let us know...

        1. Apologies if you thought my comment was related to the script - I was merely offering feedback that may have been of assistance to the previous poster with his issues re mosquitto.

        1. exactly... it happened with other nodes and services in the past... we test script on ACTUAL systems, but has happened just a week ago, an updated node-red broke something and we had to fix it... maybe something new is out in these days...

  12. Good evening, as per my question earlier I tried again just now, after reboot tested Node-Red with mqtt flow, I notice doesn't work, try started manually, I have got the following:

    pi@raspberrypi:~ $ mosquitto
    1527284273: mosquitto version 1.4.10 (build date Fri, 22 Dec 2017 08:19:25 +0000) starting
    1527284273: Using default config.
    1527284273: Opening ipv4 listen socket on port 1883.
    1527284273: Error: Address already in use
    pi@raspberrypi:~ $

    Not working, then pre install Mosquitto and after creating config file and password (from: https://www.rs-online.com/designspark/building-distributed-node-red-applications-with-mqtt), started manually and I have got following:

    pi@raspberrypi:~ $ mosquitto
    1527285239: mosquitto version 1.4.10 (build date Fri, 22 Dec 2017 08:19:25 +0000 ) starting
    1527285239: Using default config.
    1527285239: Opening ipv4 listen socket on port 1883.
    1527285239: Opening ipv6 listen socket on port 1883.
    1527285242: New connection from 192.168.1.171 on port 1883.
    1527285242: New client connected from 192.168.1.171 as ESP8266Client (c1, k15).
    1527285245: New connection from 127.0.0.1 on port 1883.
    1527285245: New client connected from 127.0.0.1 as mqtt_83d69502.e66968 (c1, k60 ).
    And Mosquito start working but after reboot again doesn't.

    Filip

  13. Here's my problem...

    Last year (maybe earlier) I installed via The Script and everything worked like a charm.

    A couple of months ago I was forced into a house move that also forced a change from my original (ADSL-based) ISP to a 'RF via dish' ISP.

    Everything was originally set up to run on a 192.168.1.xx network with the Node-Red server on a static IP Address of 192.168.1.100. Unfortunately, the new ISP's system reserves the 192.168.1.xx system for their own use, so I need to change to 192.168.2.xx (although the system has also shown once as 192.168.0.xx).

    No matter what I do from the command line in the Pi, changing /etc/network/interfaces or /etc/dhcpcd.conf. everything gets written back to the original values on rebooting.

    Due to a stroke, a few years ago, I have very bad short term memory and I have no idea if the network settings and the static IP were set as part of the configuration for The Script, or how it was done and, of course, I have no idea where on the Pi that configuration is being stored.

    What do I need to do the make the changes and have them remain after a reboot - i.e. to actually become the necessary configuration?

    This has been driving me mad for weeks - even the cat is missing things happening automatically...

    1. These local addresses are usually assigned by a DHCP server which is normally part of the router/modem functionality. Look for a config option in the router setup that refers to LAN configuration. There will usually be an option to use router for DHCP and what range of addresses to use - in your case 192.168.2.0 to 192.168.2.256.. If you have set fixed ip addresses in /etc/dhcpcd.conf and they are being lost on reboot I would suspect a faulty sd card where changes are not being written back from cache.

      1. I'm certainly no expert on these things, but how could the router set the Pi when it's on a completely different network?

        The DHCP range of the router is set to use 128 to 254.

        I don't think it's an SD-Card problem. If I 'CTRL+O' then CTRL+X' from the nano editor, the changes seem to have been written,

        I think that, if there was some network setup involved when The Script was first run, then that's taking precedence on bootup and rewriting everything to the previously entered values.

        Nothing has been done to the router and everything is exactly as it was with the original (ADSL) setup - the IP address of 100 is as per my schedule of fixed IPs for various devices.

        I can happily change the values for the NAS Hard Drive (at an IP address of 110 - using /etc/network/interfaces), so that would also tend to rule out the router doing anything strange.

          1. OK Peter, you wrote The Script, so I'll accept that, But surely, at some point there must have been an option to enter network details, otherwise it would be impossible to get to the 'Opening page' or to Node-RED.

            My memory problem means that I can't even remember running The Script (but I know I did) so I have absolutely no recollection of anything else that may have been done before I was happily playing with Node-RED at a static IP of 192.168.1.100:1880.

            The IP Address is most definitely static but the only way I knew how to set a static IP on Raspberry Pi was to add lines to /etc/network/interfaces - and everything there is being set to 'manual' which, until this problem reared its head, was an option that I'd never heard of - so it's getting set by something else ('manual' being an option that 'allows credentials to be set by an external program'). and it's that something else, that external program, that I need to track down - but I'm seriously outside my comfort zone and way beyond my understanding.

  14. A simple test for the SD card would be to create a file in your home directory and then do a reboot - if the new file is not there after the reboot then your changes are not being flushed from the cache to the SD card usually because the card will not accept writes - there is a long discussion about this elsewhere on the blog with the concensus being that the cause of failure is often due to poor power supplies or cables.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.