54 thoughts on “Installing the Works - The Script

  1. 1) there's no need to use sudo for changing your own password...
    2) you can allow root login with this line, without using nano:
    sudo sed -i -e 's/PermitEmptyPasswords yes/PermitEmptyPasswords no/g' /etc/ssh/sshd_config

    just as you are there, you can make the pause (between entering the username and the request for password via ssh) to 0 while setting UseDNS to no, with this line if the directive is already present:
    sudo sed -i -e 's/UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config
    or with this if it's not:
    sudo bash -c "echo UseDNS no >> /etc/ssh/sshd_config"
    then restart ssh, no need for reboot... only a new kernel needs a reboot on a linux system...:
    sudo /etc/init.d/ssh restart

  2. Hi there.

    Right - in stages - bearing in mind I'm not a Linux guy...

    Yes to not needing sudo for your own password.... I'll update the blog...

    sudo sed -i -e 's/PermitEmptyPasswords yes/PermitEmptyPasswords no/g' /etc/ssh/sshd_config

    Understand above but not sure why that rather than changing "PermitRootLogin" to "yes" - which I know works... not fussy but don't quite understand the change.

    Didn't follow the relevance of changing DNS?? Don't follow that paragraph at all.

    Happy with the SSH restart..

    So basically - it would be nice have the lot in the script.... but I need to understand what I'm doing and why...

    If you have a moment...


    1. So - this is what I would suggest would be the change??

      sudo sed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
      sudo /etc/init.d/ssh restart
      echo "Update your PI password"
      passwd pi
      echo "Update your ROOT password"
      sudo passwd root

      1. shit! this happens when doing 2 things together!
        this is the correct line, but i see in other comment that you are already there... sorry... πŸ™
        sudo sed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config

  3. Hi Pete. Where can I read about your decision on moving from openHAB to Node-Red? I'm still trying to figure out what the best option is. Thanks!

    1. Hi Jose

      Not sure I ever documented it. OpenHab is obviously popular - but for me - it takes quite a bit of setting up and if I'm going to that much trouble - I may as well use Node-Red which, after you get over the usual hump of learning something new is incredibly easy to use and there's not much you cannot do with it. I pair that (as you'll see elsewhere) with Blynk, Node-Red-Contrib-UI and Imperihome as appropriate. Here in Spain for example I'm not using Blynk at all yet, got my RGB lights etc all running on Imperihome and using my BigTimer to control the outside lights etc. I'm sure there are many ways to do this including OpenHab - but I'm happy with and now have a fair understanding of Node-Red and so that is my choice. It isn't the only choice...


  4. Hi i am using openHAB and it is quite dificult to get your head around at first, i got some philips hue lights going quite easily then fumbled my way to getting the temperature and humidity readings from my wifi thermostat (Martin Hariznof IOT one). Then came across Home control 2016, i wish i had found this earlier!
    tried putting it on a WeMos D1...can't get it to go into AP mode to set it up, tried it on a node MCU esp12e-DEV kit...same as WeMos.. Tried it on Electrodragon 2chan relay and it worked 1st time. Its been on a few days now and hasn't dropped out..most reliable ESP thing yet!, i must of tried them all, and had sort of given up on them as i found them a bit flakey. This seems solid, very impressed so far. Anyway back to openhab/node red. i struggled to get open hab to switch the relays, because of the simple fact you cant use a : in the command, some one on the forum showed me a work-around, but, what a bloody faff! So i am going to give NodeRed another go. I did think about running both, as i have spent hours messing with Openhab, but have now decided to read the blog from the start go with Node Red.

    1. Save it in /home/pi as any name you like ending in .sh. So ra3.sh is fine. You then need to change it's permissions to include execute - then merely run ./ra3.sh (as user pi) and every now and then it will ask questions. At the end it will reboot and you are done.

  5. hi i copied and pasted it into notepad then saved as "all files" bash.sh on my windows desktop. i then opened WinSCP and moved it from windows desktop to /home/pi, i then right clicked on it and checked box, 3rd from left "Owner x" i then right clicked again and click open it then opens a terminal window. i then do yes or all and get :--------------------------------------------------------------------------------
    Elapsed Time: 00 hrs 00 mins 01 secs

    Updating repositories then any programs
    bash: sudo: command not found
    bash: sudo: command not found
    bash: sudo: command not found
    bash: sudo: command not found
    Elapsed Time: 00 hrs 00 mins 10 secs

    Enabling PING and SAMBA (to access the hostname externally - and STUFF
    bash: sudo: command not found
    bash: sudo: command not found
    bash: sudo: command not found
    bash: sudo: command not found
    Elapsed Time: 00 hrs 00 mins 10 secs

    Loading Mosquitto and setting up user
    bash: wget: command not found
    bash: sudo: command not found
    bash: cd: /etc/apt/sources.list.d/: No such file or directory
    bash: sudo: command not found
    bash: sudo: command not found
    bash: sudo: command not found
    ======================================= UPdating mosquitto.conf
    bash: sudo: command not found
    bash: sudo: command not found
    Enter desired user (admin for example) for Mosquitto:

    it then asks for passwords several times with lots of command not found / no such file or directory.

    i feel like a real idiot as i must be missing somthing basic, sorry to keep bothering you

    1. Got it going ! i hadn't copied the file as "RAW", copied it to pi with WINscp, changed permissions, ran it on pi directly using keyboard and monitor..bingo. ithink it was not copying it raw.

      thanks Chris.

    1. That os slow - I cannot explain why - it just works normally.... of course if your internet is very slow then that would slow downloads. I'm used to testing with at least 8MPS download....

  6. Peter.
    Brilliant work on these devices.

    I'm wondering if anyone has issues with the latest script.

    It creates errors at line 250-275, and again at line 435.
    It seems that npm is not installed.

    Line 237 curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
    throws an error
    " ## You appear to be running on ARMv6 hardware.
    Unfortunately this is not currently supported by the NodeSource Linux distributions. Please use the 'linux-armv6l' binary tarballs available directly from nodejs.org for Node.js v4 and later. "

    A bit of searching resulted in this

    and these instructions
    wget https://nodejs.org/dist/v4.2.4/node-v4.2.4-linux-armv6l.tar.gz

    sudo mv node-v4.2.4-linux-armv6l.tar.gz /opt

    cd /opt

    sudo tar -xzf node-v4.2.4-linux-armv6l.tar.gz
    sudo mv node-v4.2.4-linux-armv6l nodejs
    sudo rm node-v4.2.4-linux-armv6l.tar.gz
    sudo ln -s /opt/nodejs/bin/node /usr/bin/node
    sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm

    There may be a shorter way
    sudo apt-get update
    sudo apt-get install npm

    After that it was simply a matter of creating a new file with missing bits.
    Yes it's not fast on a Pi2 even with it speed up a bit.


    1. This was my rather crude attempt to completely get rid of the node-red setup that comes with Pi these days and to put the latest Node-Red on there along with the relevant NPN etc- if you have fully tested a better way, then please give me your final suggestion and I'll put a new script up there. Sadly nothing lasts forever πŸ™‚

  7. Peter
    I can assure you that your script was much better than my 'muddling' along.
    It finished (finally RPi2 is slow) so I'll make the small change and send/attach it.

    It seems that npm was part of the distro and now isn't.

    Cheers Mark

  8. Hi Pete, I know you test on Pi 2 and beyond - might be worth a wee note somewhere to say that it will fail on a PI 1 and you need to make your own arrangements for NPM and Node Red as detailed in the Node-Red installation guide. πŸ™‚

  9. Ok, I remembered to set permissions now I get
    run ./pi3.sh
    bash: ./pi3.sh: /bin/pash^M: bad interpreter: No such file or directory.

    I have a new Pi3 fresh load then update and upgrade before I tried it.

    1. James, you either haven't copied the RAW version of Peter's script or you haven't set the transfer to text in winSCP. I made those mistakes and saw a similar error message.

  10. 2016-11-20 19:26:40 (1.57 MB/s) - β€˜/usr/bin/node-red-stop’ saved [226/226]

    moment@2.16.0 node_modules/moment
    node-red-contrib-config@1.0.1 node_modules/node-red-contrib-config
    node-red-contrib-grove@1.0.7 node_modules/node-red-contrib-grove
    node-red-contrib-bigtimer@1.4.4 node_modules/node-red-contrib-bigtimer
    └── suncalc@1.7.0
    node-red-contrib-esplogin@1.1.8 node_modules/node-red-contrib-esplogin
    └── suncalc@1.7.0
    node-red-contrib-timeout@1.0.4 node_modules/node-red-contrib-timeout
    npm WARN deprecated node-uuid@1.4.7: use uuid module instead

    > websocket@1.0.23 install /root/.node-red/node_modules/node-red-node-pushbullet/node_modules/pushbullet/node_modules/websocket
    > (node-gyp rebuild 2> builderror.log) || (exit 0)


    > websocket@1.0.23 install /root/.node-red/node_modules/node-red-node-pushbullet/node_modules/pushbullet/node_modules/websocket
    > (node-gyp rebuild 2> builderror.log) || (exit 0)

    Started running the script manually thinking it was NPM got down to this.
    node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v46-linux-arm.tar.gz

    No longer at that address.
    node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.8 and node@4.6.2 (node-v46 ABI) (falling back to source compile with node-gyp)

    So I need to find the location of the tar file to start with.

    1. those nodes are installed via NPM, so better to tell to the original authors of those packages... there's nothing in Peter's script that could prevent those errors... sometimes happens, developers change something, but it's just a matter of time to wait and redo the npm install to have a working node again...

      1. Thank you for the response. I have been bashing my head over this stuff as I cannot get node-red to talk to a sonoff. The sonoff is online but no Mqtt working. It did tell me it was connecting then disconnecting then connecting. Now nothing is happening in Node-red. I need to run the MQTT stuff again, but the script stops at the start of NPM stuff now.

  11. I am new here and did install the script. I get lots of errors and Warnings(ignore them). When I follow the text it seems the missing or wrong files fall back to making a new build. I cannot check if everything is OK, but a lot is!
    The only problem I can see is the serialport for my Pi3B, it is not recognized in Node-Red(at start it says: "[gpio] Error: Cannot find 'serialport' ". This might be because of the change from Pi2>Pi3 enabling BT to com via this port(see here : http://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/ ). What do we chose, from the options described in the link, for Pete's software to function? I am really a beginner so please keep it simple!

  12. Was having problems with node-red after installing it and trying to use it with sonoff. Just kept saying connecting/disconecting MQTT bit. So I thought I would start from scratch, and reinstall. After working my way through the script, which parts still do not install. Mainly the GPIO Amazon one. I run node-red and all Peter's NPM don't show up now. I tried to reinstall the scripts got these messages.
    npm WARN enoent ENOENT: no such file or directory, open '/home/pi/.node-red/package.json'
    npm WARN .node-red No description
    npm WARN .node-red No repository field.
    npm WARN .node-red No README data
    npm WARN .node-red No license field.
    pi@AmigaPi:~/.node-red $ npm install node-red-contrib-esplogin
    └── node-red-contrib-esplogin@1.1.8
    Is it because node-red is running as well or the repository is missing. Any help would be much appreciated.

  13. All went well. Installed script, flashed some ESP's configured them and then ....
    After some days of experiments with the Node-Red commands, the clock( I already had it constructed, and PetesTerminal suddenly the MQTT broker cannot be reached. I cannot login anymore. There must be some reason why this is happening, but not aware of anything I changed on the Pi. To repair it I need to know how to set the password for the webmin tool which seems to be the same as for the MQTT broker. Anyone who can explain this to me???

    1. Very difficult to tell from a distance - check the broker with something like MQTT-SPY to clarify for sure what is wrong. Without knowing what you were doing in the lead up to going wrong I can't be of much help. Others may have ideas.

    2. Update: I just flashed the firmware again and still no connection until I reentered the mqtt password, mqtt now connected again. Still I cannot login to webmin! Maybe I got confused and the mqtt pw is not the same as the one for webmin. Can I take the install part from the script including the timeupdater and install it again and will I be asked for a username and pw?

      1. I tried an otaupdate and that does not go well completely. It gives me this -

        ESP8266 op breakout/fromesp/otaupdate=Attempting OTA

        E:M 5856

        OTA succeeded to ROM 1
        Then when rebooting it tells me ROM 1 is bad. I think I have a faulty component and screwed up my mqtt pw memory in flash at another occasion before I reflashed it, will forget this part because I cannot otaupdate.

        Still I cannot login to webmin with the same user and pw.

        btw I cannot use {rebootnow}, has this been deprecated?. I use reset now which seems to have the same effect!

        1. Slight mistake in the manual - now fixed. reboot_now does as it says - reboot. reset saves any config changes before rebooting.

          No - you can't log into to webmin with same user and pw - you need to use pi or root.

          If it says ROM1 is bad - either you're not using an ESP12 with 32Mb or you've a bad rom. You cannot OTA the likes of Sonoff without replacing the FLASH chip.

  14. So I am logged in automatically and never use a pw for pi or root. When running your script I choose to use the same username and pw for all questions that came up, but the pi pw must have been defined way before that automatically. So I have to find out how this works in Raspbian after all. Or a small hint from you may speed up the process?

    1. The passwords setup in the script has nothing to do with the password for Webmin now. They changed their script. So you can use your Pi or root password. That's about the only info I can give you.

  15. I have bought one of those cheap OLEDs. Gave it a try with i2c_check. No devices detected??? Checked all connections, OK. Tried again, no result. Why not cross SCL and SDA............ , 1 device detected on address 60. It appears there is another crossover in the description of i2c command! I found GPIO4=SDA abd GPIO5=SCL. Did not took me long to try, can always happen, I was confused with RX/TX when I started too. Now going on to the more interesting stuff like producing some text on the OLED.

  16. Hi,
    I ran the script and everything seemed to install correctly, however I cannot get into any of the web management features apart from System Info and Sqlite.
    I tried to troubleshoot Node-Red specifically. The error message I get is that the module "moment" cannot be found.
    Anyone ran into this?

Leave a Reply

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