The Bodaciously Excellent Blog of Doctorwhen

MagicMirror Automated Installation and Configuration

I’ve been playing with the MagicMirror project for a few weeks now and discovered it is convenient to be able to quickly and easily reinstall and start over. This is partly because the system, although ingenious and delightful, is prone to destabilization since there are hundreds of user contributed modules and their interaction is untested and can be fragile. Also, I just like starting over after having learned something and having figured out I’d like to do it a bit differently.

Unfortunately, there is quite a bit of installation and configuration that goes on in building a MagicMirror. It’s not easy to start over and the process can be very time consuming. One way to go is to create a backup image of your SD card at some initial installation and configuration that you would be happy to return to. This is probably a good idea regardless.

Download Raspbian Buster with desktop and recommended software from:
https://www.raspberrypi.org/downloads/raspbian/

I’m using a 32GB SD card. For info on SD card sizes, see:
https://www.raspberrypi.org/documentation/installation/sd-cards.md

Insert the micro SD card into an SD adapter and insert the SD card
into an SD slot on the computer where the Raspbian image resides.

On a Mac you can erase any current data and formatting on the micro SD card with the following commands:
diskutil unmountDisk ${DEVICE}
sudo diskutil eraseDisk FAT32 RASPBIAN MBRFormat ${DEVICE}

where ${DEVICE} is the device node on which the card is mounted
(e.g. “/dev/rdisk3”). Use “sudo fdisk -l” on Linux, “diskutil list” or the
Disk Utility application on a Mac to discover the device node. On a Mac the following command can provide the name(s) of any Windows_FAT_32 type formatted disks on your system:
diskutil list | grep Windows_FAT_32 | awk ‘ { print $6 } ‘ | cut -c 1-5

Using balenaEtcher write the Raspbian image to a micro SD card. You can download balenaEtcher for your system at:

https://www.balena.io/etcher/

See operating system installation instructions at:
https://www.raspberrypi.org/documentation/installation/installing-images/README.md

For the initial setup on my Raspberry Pi I connect it to the network with an ethernet cable. It is possible to use wifi but we are going to be downloading quite a lot so I want the fastest Internet connection I can use.

For this step I also connect a monitor and USB keyboard/mouse to the Pi.

Eject the SD card from the card reader slot on your computer and remove the micro SD card from the adapter. Insert the micro SD card into the Raspberry Pi. Connect power, monitor, keyboard, mouse, and network cable to the Raspberry Pi. Power ON.

On initital boot the Raspbian operating system runs a system setup process that is described in detail elsewhere. It’s pretty straight forward – select your language, timezone, and so on. If you have connected to the network with an ethernet cable then you can skip the wireless network setup. Otherwise you need to configure a wireless network in order to download any updates or proceed later with the MagicMirror installation. Wireless network setup can be accomplished later by executing the following commands:

$ wpa_passphrase "" \
"<Your wireless network password" \
| sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf
$ wpa_cli -i wlan0 reconfigure

After completing the initial system load and configuration, click “Restart” and you should be presented with the Raspbian desktop. In the upper left corner of the screen is a terminal icon – click this to bring up a terminal window with a shell prompt. Execute the following commands in the terminal window:

$ mkdir src
$ cd src
$ git clone https://gitlab.com/doctorfree/Scripts.git
$ cd Scripts/MagicMirror
$ ./install_magicmirror.sh

The install_magicmirror.sh script will install MagicMirror and several of the
MagicMirror 3rd Party modules. This step is not only a convenience to easily and quickly install my MagicMirror setup but performs several system changes and security checks. You can install MagicMirror without running this script by following the MagicMirror installation guide at:
https://docs.magicmirror.builders/getting-started/installation.html#manual-installation
You may also wish to examine the script to manually perform some of the
additional system configuration and modifications it makes.

The install_magicmirror.sh script performs most of its actions without the need for user input. However, there are three prompts to allow the user to select or skip configuration of Apple iCal calendar synchronization, SSH, and MagicMirror screen orientation.

The install_magicmirror.sh script does the following:
– Installs MMPM, the MagicMirror Package Manager, and its dependencies
– Installs MagicMirror and its dependencies
– Installs the following MagicMirror modules:
MMM-AssistantMk2
MMM-BackgroundSlideshow
MMM-DarkSkyForecast
mmm-hue-lights
MMM-iFrame
MMM-ModuleScheduler

MMM-NetworkScanner
        MMM-RAIN-RADAR
        MMM-Remote-Control
        MMM-Solar
        MMM-stocks
        MMM-SystemStats
        MMM-TelegramBot
        MMM-Tools
        MMM-YouTube
- Audits and repairs any discovered vulnerabilities in MagicMirror
  and its modules
- Installs MagicMirror convenience scripts I have written including
  a MagicMirror management utility: /usr/local/bin/mirror
- Installs the jq JSON parsing utility to provide improved readability
  of the 'mirror' script output
- Installs the Duplicity backup utility and convenience scripts to perform
  backup, verification, and restore of the pi user's home directory
- Installs fswebcam utility
- Configures the default MagicMirror config.js using the sample config
- Installs pm2, a production process manager for Node.js applications
- Enables and starts the SSH service if default password is not used
    - Configures and saves a pm2 'MagicMirror' process
    - Disables the X11 screensaver
    - Installs Vim GUI, exuberant-ctags, and Vim Runtime packages
    - Installs the vdirsyncer service and dependencies to provide support
      for syncing Apple iCal calendars in the MagicMirror calendar module
    - Removes unused packages
    - Provides a dialog to select whether to rotate the screen 90 degrees
      left or 90 degrees right or leave as-is
    - Lists files that need further configuration with private keys, etc
    - Starts MagicMirror

Additional Raspberry Pi configuration steps can be found at:
  https://github.com/MichMich/MagicMirror/wiki/Configuring-the-Raspberry-Pi
NOTE: Some information at the above web page on Raspberry Pi configuration
      is out of date. Exercise caution and backup before making changes.
      Most of the safe correct changes have already been performed for you
      by the install_magicmirror.sh script. Examine that script to determine
      what further changes you may wish to manually perform.

Leave a Reply

Your email address will not be published.