From 741377532b88c4e9c16304e91593632751f8cae7 Mon Sep 17 00:00:00 2001 From: Christian W Date: Thu, 18 Feb 2021 17:42:27 +0100 Subject: [PATCH] Update raspberry.sh If you start the installation with ./raspberry.sh -a you will not be asked if you want to configure MM auto start or disable the screensaver. This will all be done without asking. Useful for unattended installation. (I use a local Gitlab instance to store my configurations and Ansible to push them to the MM installation afterwards.) For complete unattended installation do the following with a Raspberry Pi 3 (in my case) and Raspberry Pi OS: 1. burn Raspberry Pi OS (32bit) on a SD card 2. copy a blank ssh file into the SD root (for enabled ssh.service) 3. copy a file wpa_supplicant.conf with the following content also onto the SD card (for configured and enabled wifi): ## WPA/WPA2 secured network={ ssid="INSERT_YOUR_SSID" scan_ssid=1 psk="INSERT_YOUR_PASS" key_mgmt=WPA-PSK } #country=GB # United Kingdom #country=CA # Canada country=DE # Germany #country=FR # France #country=US # United States ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 4. Insert the SD card into your Pi, boot and wait with some coffee. --- raspberry.sh | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/raspberry.sh b/raspberry.sh index 6f2a6ec..973193c 100755 --- a/raspberry.sh +++ b/raspberry.sh @@ -33,6 +33,21 @@ PM2_FILE=pm2_MagicMirror.json forced_arch= pm2setup=$false +# Ask for unattended install flag -a (automated) +automated=$false +while getopts "ha" opt; do + case "$opt" in + h) + echo "If you use the flag '-a' then the installation will configure MM auto start and disable the screensaver." + exit 0 + ;; + a) + echo -e "*** '-a' flag detected. Starting the installation with configured MM auto start and disabled screensaver. ***\n" + automated=$true + ;; + esac +done + trim() { local var="$*" # remove leading whitespace characters @@ -402,8 +417,14 @@ else fi # Use pm2 control like a service MagicMirror -read -p "Do you want use pm2 for auto starting of your MagicMirror (y/N)?" choice -choice="${choice:-N}" + +if [[ $automated -eq $false ]]; then + read -p "Do you want use pm2 for auto starting of your MagicMirror (y/N)?" choice + choice="${choice:-N}" +else + choice="Y" +fi + if [[ $choice =~ ^[Yy]$ ]]; then echo install and setup pm2 | tee -a $logfile # assume pm2 will be found on the path @@ -535,8 +556,13 @@ if [[ $choice =~ ^[Yy]$ ]]; then fi # Disable Screensaver -read -p "Do you want to disable the screen saver? (y/N)?" choice -choice="${choice:-Y}" +if [[ $automated -eq $false ]]; then + read -p "Do you want to disable the screen saver? (y/N)?" choice + choice="${choice:-Y}" +else + choice="Y" +fi + if [[ $choice =~ ^[Yy]$ ]]; then # if this is a mac if [ $mac == 'Darwin' ]; then