magicmirror-install.sh 5.3 KB

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