changedetection-install.sh 3.8 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 (Patience)"
  14. $STD apt-get install -y \
  15. curl \
  16. sudo \
  17. mc \
  18. git \
  19. build-essential \
  20. dumb-init \
  21. gconf-service \
  22. libatk-bridge2.0-0 \
  23. libasound2 \
  24. libatk1.0-0 \
  25. libcairo2 \
  26. libcups2 \
  27. libdbus-1-3 \
  28. libexpat1 \
  29. libgbm-dev \
  30. libgbm1 \
  31. libgconf-2-4 \
  32. libgdk-pixbuf2.0-0 \
  33. libglib2.0-0 \
  34. libgtk-3-0 \
  35. libnspr4 \
  36. libnss3 \
  37. libpango-1.0-0 \
  38. libpangocairo-1.0-0 \
  39. qpdf \
  40. xdg-utils \
  41. xvfb \
  42. ca-certificates \
  43. gnupg
  44. msg_ok "Installed Dependencies"
  45. msg_info "Updating Python3"
  46. $STD apt-get install -y \
  47. python3 \
  48. python3-dev \
  49. python3-pip
  50. msg_ok "Updated Python3"
  51. msg_info "Setting up Node.js Repository"
  52. mkdir -p /etc/apt/keyrings
  53. curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
  54. echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
  55. msg_ok "Set up Node.js Repository"
  56. msg_info "Installing Node.js"
  57. $STD apt-get update
  58. $STD apt-get install -y nodejs
  59. msg_ok "Installed Node.js"
  60. msg_info "Installing Change Detection"
  61. mkdir /opt/changedetection
  62. $STD pip3 install changedetection.io
  63. msg_ok "Installed Change Detection"
  64. msg_info "Installing Browserless & Playwright"
  65. mkdir /opt/browserless
  66. $STD python3 -m pip install playwright
  67. $STD git clone https://github.com/browserless/chrome /opt/browserless
  68. $STD npm install --prefix /opt/browserless
  69. $STD npm run build --prefix /opt/browserless
  70. $STD npm prune production --prefix /opt/browserless
  71. msg_ok "Installed Browserless & Playwright"
  72. msg_info "Installing Font Packages"
  73. $STD apt-get install -y \
  74. fontconfig \
  75. libfontconfig1 \
  76. fonts-freefont-ttf \
  77. fonts-gfs-neohellenic \
  78. fonts-indic fonts-ipafont-gothic \
  79. fonts-kacst fonts-liberation \
  80. fonts-noto-cjk \
  81. fonts-noto-color-emoji \
  82. msttcorefonts \
  83. fonts-roboto \
  84. fonts-thai-tlwg \
  85. fonts-wqy-zenhei
  86. msg_ok "Installed Font Packages"
  87. msg_info "Installing X11 Packages"
  88. $STD apt-get install -y \
  89. libx11-6 \
  90. libx11-xcb1 \
  91. libxcb1 \
  92. libxcomposite1 \
  93. libxcursor1 \
  94. libxdamage1 \
  95. libxext6 \
  96. libxfixes3 \
  97. libxi6 \
  98. libxrandr2 \
  99. libxrender1 \
  100. libxss1 \
  101. libxtst6
  102. msg_ok "Installed X11 Packages"
  103. msg_info "Creating Services"
  104. cat <<EOF >/etc/systemd/system/changedetection.service
  105. [Unit]
  106. Description=Change Detection
  107. After=network-online.target
  108. After=network.target browserless.service
  109. Wants=browserless.service
  110. [Service]
  111. Type=simple
  112. WorkingDirectory=/opt/changedetection
  113. Environment="WEBDRIVER_URL=http://127.0.0.1:4444/wd/hub"
  114. Environment="PLAYWRIGHT_DRIVER_URL=ws://127.0.0.1:3000/?stealth=1&--disable-web-security=true"
  115. ExecStart=changedetection.io -d /opt/changedetection -p 5000
  116. [Install]
  117. WantedBy=multi-user.target
  118. EOF
  119. cat <<EOF >/etc/systemd/system/browserless.service
  120. [Unit]
  121. Description=browserless service
  122. After=network.target
  123. [Service]
  124. Environment=APP_DIR=/opt/browserless
  125. Environment=PLAYWRIGHT_BROWSERS_PATH=/opt/browserless
  126. Environment=CONNECTION_TIMEOUT=60000
  127. Environment=HOST=127.0.0.1
  128. Environment=LANG="C.UTF-8"
  129. Environment=NODE_ENV=production
  130. Environment=PORT=3000
  131. Environment=WORKSPACE_DIR=/opt/browserless/workspace
  132. WorkingDirectory=/opt/browserless
  133. ExecStart=/opt/browserless/start.sh
  134. SyslogIdentifier=browserless
  135. [Install]
  136. WantedBy=default.target
  137. EOF
  138. systemctl enable -q --now browserless
  139. systemctl enable -q --now changedetection
  140. msg_ok "Created Services"
  141. motd_ssh
  142. customize
  143. msg_info "Cleaning up"
  144. $STD apt-get autoremove
  145. $STD apt-get autoclean
  146. msg_ok "Cleaned"