magicmirror-install.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
  7. color
  8. verb_ip6
  9. catch_errors
  10. setting_up_container
  11. network_check
  12. update_os
  13. msg_info "Installing Dependencies"
  14. $STD apt-get install -y curl
  15. $STD apt-get install -y sudo
  16. $STD apt-get install -y mc
  17. $STD apt-get install -y git
  18. msg_ok "Installed Dependencies"
  19. msg_info "Setting up Node.js Repository"
  20. $STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x)
  21. msg_ok "Set up Node.js Repository"
  22. msg_info "Installing Node.js"
  23. $STD apt-get install -y nodejs
  24. msg_ok "Installed Node.js"
  25. msg_info "Setting up MagicMirror Repository"
  26. $STD git clone https://github.com/MichMich/MagicMirror /opt/magicmirror
  27. msg_ok "Set up MagicMirror Repository"
  28. msg_info "Installing MagicMirror"
  29. cd /opt/magicmirror
  30. $STD npm install --only=prod --omit=dev
  31. cat <<EOF >/opt/magicmirror/config/config.js
  32. let config = {
  33. address: "0.0.0.0",
  34. port: 8080,
  35. basePath: "/",
  36. ipWhitelist: [],
  37. useHttps: false,
  38. httpsPrivateKey: "",
  39. httpsCertificate: "",
  40. language: "en",
  41. locale: "en-US",
  42. logLevel: ["INFO", "LOG", "WARN", "ERROR"],
  43. timeFormat: 24,
  44. units: "metric",
  45. serverOnly: true,
  46. modules: [
  47. {
  48. module: "alert",
  49. },
  50. {
  51. module: "updatenotification",
  52. position: "top_bar"
  53. },
  54. {
  55. module: "clock",
  56. position: "top_left"
  57. },
  58. {
  59. module: "calendar",
  60. header: "US Holidays",
  61. position: "top_left",
  62. config: {
  63. calendars: [
  64. {
  65. symbol: "calendar-check",
  66. url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"
  67. }
  68. ]
  69. }
  70. },
  71. {
  72. module: "compliments",
  73. position: "lower_third"
  74. },
  75. {
  76. module: "weather",
  77. position: "top_right",
  78. config: {
  79. weatherProvider: "openweathermap",
  80. type: "current",
  81. location: "New York",
  82. locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
  83. apiKey: "YOUR_OPENWEATHER_API_KEY"
  84. }
  85. },
  86. {
  87. module: "weather",
  88. position: "top_right",
  89. header: "Weather Forecast",
  90. config: {
  91. weatherProvider: "openweathermap",
  92. type: "forecast",
  93. location: "New York",
  94. locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
  95. apiKey: "YOUR_OPENWEATHER_API_KEY"
  96. }
  97. },
  98. {
  99. module: "newsfeed",
  100. position: "bottom_bar",
  101. config: {
  102. feeds: [
  103. {
  104. title: "New York Times",
  105. url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml"
  106. }
  107. ],
  108. showSourceTitle: true,
  109. showPublishDate: true,
  110. broadcastNewsFeeds: true,
  111. broadcastNewsUpdates: true
  112. }
  113. },
  114. ]
  115. };
  116. /*************** DO NOT EDIT THE LINE BELOW ***************/
  117. if (typeof module !== "undefined") {module.exports = config;}
  118. EOF
  119. msg_ok "Installed MagicMirror"
  120. msg_info "Creating Service"
  121. service_path="/etc/systemd/system/magicmirror.service"
  122. echo "[Unit]
  123. Description=Magic Mirror
  124. After=network.target
  125. StartLimitIntervalSec=0
  126. [Service]
  127. Type=simple
  128. Restart=always
  129. RestartSec=1
  130. User=root
  131. WorkingDirectory=/opt/magicmirror/
  132. ExecStart=/usr/bin/node serveronly
  133. [Install]
  134. WantedBy=multi-user.target" >$service_path
  135. $STD systemctl enable --now magicmirror
  136. msg_ok "Created Service"
  137. motd_ssh
  138. customize
  139. msg_info "Cleaning up"
  140. $STD apt-get autoremove
  141. $STD apt-get autoclean
  142. msg_ok "Cleaned"