Regular reader will know about the script that Aidan Ruff and I originally developed to put Node-Red and several other packages onto the Raspberry Pi for our own home control purposes.
WELL - there is a new version of the script, modified to include logging and work to handle Raspbian Stretch (tested on Raspberry Pi 2 and 3). The script also runs well with several other boards running Debian, Ubuntu and more. See right hand side of the above image for what it does. Read on…
Originally designed to run under Debian – reader Antonio and I have also made the script compatible with Xenial. So now Raspbian, DietPi (Debian) and the Armbian versions of Debian and Xenial (Ubuntu) as well as the DietPi VM.
One issue I have occasionally with new boards is lack of remote root access to install the script. For example on a Banana Pi 3 I had this.. there was pi access for the likes of WinSCP but not root access. This was easily solved as user Pi - after using "sudo passwd root" to ensure I had a know root password.
sudo sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config
sudo systemctl restart sshd
That won’t work in all cases but I’m parking that here for reference.
The easiest way to get the script – as ROOT user, in your ROOT directory is:
wget --no-check-certificate http://bit.do/the-script
Before I begin... no, we’re not a support shop – you may or may not end up having to tweak things for your system but please don’t write in to say “I tried this on a Mac and it doesn’t work”).
The level of interaction after the beginning is now zero thanks to a new menu-driven approach and many improvements including using a VM (virtual machine) to test the whole thing at accelerated speeds. We continue to add/modify features as appropriate.
What is this about?
What we have here is an explanation of how to get Xenial running in a VM – the purpose of this is merely as a base to test the new script mentioned below which will install somewhat more than the original script (designed originally for Raspberry Pi but now working on several Debian-based devices and now Xenial) – namely:
- Node-Red at port 1880 and lots of useful NODES
- Mosquitto (MQTT) with Websockets
- Webmin at port 10000
- Apache at port 80
- HA-Bridge at port 82 (suitable for Amazon Alexa)
- SQLite and PHPLiteAdmin
- MC File manager and editor
- Grafana with InfluxDB (only tested on a few setups – so OFF by default)
- Lots more – see the menu screen
Typically this setup would be used as the basis of a nerve-centre to control and monitor home control gadgets such as the ESP8266 units we discuss in this blog, Sonoff controllers and much more. Armed with this software, controlling the home is easy – and more importantly can be done YOUR WAY.
The Virtual Machine
Let’s take a look at what we did to get this running on a VM – you can of course duplicate all of this as you go along. We used the excellent VMware of VirtualBox on Windows PCs. This explanation covers VMware.
So – first things first – as I’ve done a video of the Virtualbox installation complete with sample use of Node-Red, here we’ll discuss the VMWARE version. Both of these were done as test mechanisms before using the script on real devices such as the Orange Pi Zero, Raspberry Pi, Odroid and other devices discussed at length in the blog.
We loaded up a copy of VMware (I used VirtualBox but the procedure is similar – VMware player is free of you can use the full commercial workstation) and made sure it works. That much is up to you. There is a wizard for creating new virtual machines - we chose a CUSTOM machine. Steps from that point on were:
NEXT - NEXT – “I will install the operating system later” – NEXT
Linux / Ubuntu 64-bit – NEXT – d:\test - NEXT
Number of processors – 1 - number of cores – 1 – NEXT
Memory for this machine – 1024MB – NEXT
Use Bridged Connection - NEXT
I/O Controller type LSI Logic - NEXT
Disk Type SCSI - NEXT
Create a new virtual Disk - NEXT
12GB (I used 16GB – 8GB would have done) – Store virtual disk as a single file - NEXT
At this point we gave the file a name – in our case d:\test\Ubuntu 640bit.vmdk - NEXT – FINISH
Under settings – hardware – CD/DVD we ticked “Use ISO image file” and selected the file we loaded from the Ubuntu website – “Ubuntu-16.04.1-server-amd64.iso” – OK.
At this point you’ll note reference to AMD64 – that had me as well but it works a treat on INTEL hardware.
Start off the VM – you get asked which language to use (ENGLISH) and various options will come up – the first being “Install Ubuntu Server” – that’s the one.
Once again you’ll get a language question – English. Location – in my case “United Kingdom” – if you don’t fit into the rules use “Other”.
Time Zone in my case – EUROPE and then country. Locale – in my case United Kingdom.
Hostname – we went with the default “Ubuntu” – but call it whatever you want.
At this point you get asked to create a user – it is important you make a user “pi”. Enter password also (though the new script will create user PI if it does not exist).
Partitioning – “use entire disk” (remember this is a virtual disk – not your real disk). You are then asked to confirm erasing disk – go with that. You then get asked to confirm AGAIN. YES.
HTTP Proxy just leave blank – CONTINUE.
Install security updates automatically.
Add OpenSSH server and CONTINUE (important for remote access)
Install GRUB bootloader – YES.
Installation is complete – CONTINUE. Let it run.
And voilà – one working copy of Ubuntu.
When run, the script will generate a Pi user if it does not exist - will make that user part of the correct groups and will ask you to restart the script as user Pi.
The BASH Script
This part is about running the script and the easiest way is to start in a terminal as user ROOT in the root directory.
do the WGET shown above and you will end up with a script file called “the-script”.
At this point BACK EVERYTHING UP to avoid disappointment – no, REALLY.
The script will if necessary create the Pi user but either way will now ask you to log in as user pi and repeat the procedure.
The point of this is to avoid another way which would be to create a file, load in the script contents ensuring you’re using Linux LF only format – then run the script after setting up permissions – this way you don’t have to do any of that.
In the end you will see a menu which will vary slightly depending on which system you are using – you won’t be asked about GPIO on a Raspberry Pi for example.
For the VM we left everything as you see here and tabbed to OK.
At this point you will be asked for a USER and ADMIN names (which can be user and admin if you like) and corresponding passwords. From there on – everything should happen with no user interaction.
After maybe 15 minutes – or an hour - ore a lot longer on a Raspberry Pi Zero WIFI – you’ll see an invite to REBOOT – so REBOOT. When the board/VM boots up you will find hopefully a working system.
Assuming you've installed everything:
- Node-Red runs at port 1880
- Webmin at port 10000 (Webmin needs Pi or ROOT username and pass until we figure out how to add in the ADMIN user).
- Apache runs at port 80
- HA-BRIDGE will run at port 82 – It seems that Amazon Echo is quite happy with this but the Google product wants port 80!
Node-Red should include MQTT which will need admin username and password as will Node-Red itself. USER name and password is used by Node-Red Dashboard.
There is also the excellent MC – a file manager and editor.
I hope this brief introduction sets you off in the right direction and of course no doubt there will be discussing in the notes below.
Update 05 Jan 2017: At the time of writing I'm having issues with PIXEL in VirtualBox and DEBIAN on VirtualBox in terms of Apache not loading.. I'm sure we'll sort that - meantime some useful links. Debian may not some with SUDO depending on which installation - here's a fix link that worked for me in my VirtualBox image.. If SSH setup won't allow remote access using passwords, here's a link that helped me. Pixel of course will run in VirtualBox but by default it runs of a virtual DVD which is about as much use as an ashtray on a motorbike as nothing gets saved. Once running however it is a breeze to move over to the Virtual hard disk - you'll find that part way down the comments in this link. So right now I have VirtualBox running Xenial, Pixel and Debian and the only issues I have are with Pixel and Debian - Apache - watch this space. I’ve also improved the input for user and admin.
Important: Whatever you are using should have the SUDO command built in – it may not be obvious but Debian often does NOT have this installed by default – sort this FIRST. You should also make sure you have Pi user with SUDO group privilege – PI already has this of course and you may have added a user Pi – if not..
su -c "bash makepi"
Or, Here’s a useful link – takes seconds and is easy… basically – as root you can do - apt-get install –y sudo….. and you should make sure that your PI user is part of the sudo group.
Update March 31, 2017: the new version of the script "the script" works with the brand new NanoPi NEO2 and the NanoPi M1+ and features temperature monitoring and other improvements.
If doing this as a non-Pi user – i.e. ROOT on a machine with no Pi user – follow instructions above OR a slightly easier way…
Having uploaded the script and given permissions… as ROOT
as before – but when it has completed and wants you to log in as PI – stay where you are and:
su - pi -c /home/pi/script.sh
That might save you a little hassle.
Update 19 Aug 2017: Script updated to handle Raspbian Stretch on Raspberry Pi – tested on RPi 3. Also added code to help with non-root access to GPIO using ONOFF library. See blog entry on GPIO.