Last active
May 3, 2024 13:16
-
-
Save CSpyridakis/601cfeff25f4801e44e31eb918baf81a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash/ | |
| # Run like this: | |
| # bash <(curl -sL https://gist.githubusercontent.com/CSpyridakis/601cfeff25f4801e44e31eb918baf81a/raw/c54d1cecd7aad3c07cb89ef5ffd71aec024a32eb/install-magic-mirror2.sh) | |
| # Instructions based on this: | |
| # https://docs.magicmirror.builders/getting-started/installation.html#usage | |
| # 1. Download and install the latest Node.js | |
| curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - | |
| sudo apt-get install -y nodejs | |
| # 2. Clone the repository and check out the master branch | |
| git clone https://github.com/MagicMirrorOrg/MagicMirror | |
| # 3. Enter the repository | |
| cd MagicMirror/ | |
| # 4. Install the application | |
| npm run install-mm | |
| # 5. Make a copy of the config sample file | |
| cp config/config.js.sample config/config.js | |
| # 6. Start the application | |
| npm run server | |
| # ================================================= | |
| # 1. Create service file | |
| export USER_USED=${USER} | |
| sudo bash -c 'echo " | |
| [Unit] | |
| Description=MagicMirror | |
| After=network.target | |
| StartLimitIntervalSec=0 | |
| [Service] | |
| Type=simple | |
| Restart=always | |
| RestartSec=1 | |
| User=${USER_USED} | |
| WorkingDirectory=/home/${USER_USED}/MagicMirror/ | |
| ExecStart=/usr/bin/node serveronly | |
| [Install] | |
| WantedBy=multi-user.target | |
| " > /etc/systemd/system/magicmirror.service' | |
| # 2. Start MM with systemctl | |
| sudo systemctl start magicmirror.service | |
| # 3. Allow autostart MagicMirror² on boot | |
| sudo systemctl enable magicmirror.service | |
| # 4. Autostart browser for server mode | |
| ## 4a. Create file /home/server/.config/lxsession/LXDE-pi/autostart with the following contents | |
| echo "@lxpanel --profile LXDE-pi | |
| @pcmanfm --desktop --profile LXDE-pi | |
| @xscreensaver -no-splash | |
| @point-rpi | |
| @sh /home/${USER}/bin/start-chromium.sh | |
| " > /home/${USER}/.config/lxsession/LXDE-pi/autostart | |
| ## 4b. Create file /home/server/bin/start-chromium.sh with the following contents | |
| mkdir -p /home/${USER}/bin/ | |
| echo "#!/bin/sh | |
| # Set mouse to not visible position if visible | |
| xdotool mousemove 0 0 | |
| set -e | |
| CHROMIUM_TEMP=~/tmp/chromium | |
| rm -Rf ~/.config/chromium/ | |
| rm -Rf $CHROMIUM_TEMP | |
| mkdir -p \$CHROMIUM_TEMP | |
| chromium-browser \ | |
| --disable \ | |
| --disable-translate \ | |
| --disable-infobars \ | |
| --disable-suggestions-service \ | |
| --disable-save-password-bubble \ | |
| --disk-cache-dir=\$CHROMIUM_TEMP/cache/ \ | |
| --user-data-dir=\$CHROMIUM_TEMP/user_data/ \ | |
| --start-maximized \ | |
| --kiosk http://localhost:8080 & | |
| " > /home/${USER}/bin/start-chromium.sh && chmod +x /home/${USER}/bin/start-chromium.sh | |
| # ====================================================== | |
| # To reload webpage after config updates | |
| # Based on https://forums.raspberrypi.com/viewtopic.php?t=52613 | |
| sudo apt install xdotool | |
| echo "export DISPLAY=\":0\"" >> ~/.bashrc | |
| echo "WID=$(xdotool search --onlyvisible --class chromium|head -1) && xdotool windowactivate ${WID}" >> ~/.bashrc | |
| echo 'alias reload_magicmirror_ui="xdotool key ctrl+F5"' >> ~/.bashrc | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment