changedetection-install.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. $STD python3 -m pip install dnspython==2.2.1
  64. msg_ok "Installed Change Detection"
  65. msg_info "Installing Browserless & Playwright"
  66. mkdir /opt/browserless
  67. $STD python3 -m pip install playwright
  68. $STD git clone https://github.com/browserless/chrome /opt/browserless
  69. $STD npm install --prefix /opt/browserless
  70. $STD npm run build --prefix /opt/browserless
  71. $STD npm prune production --prefix /opt/browserless
  72. msg_ok "Installed Browserless & Playwright"
  73. msg_info "Installing Font Packages"
  74. $STD apt-get install -y \
  75. fontconfig \
  76. libfontconfig1 \
  77. fonts-freefont-ttf \
  78. fonts-gfs-neohellenic \
  79. fonts-indic fonts-ipafont-gothic \
  80. fonts-kacst fonts-liberation \
  81. fonts-noto-cjk \
  82. fonts-noto-color-emoji \
  83. msttcorefonts \
  84. fonts-roboto \
  85. fonts-thai-tlwg \
  86. fonts-wqy-zenhei
  87. msg_ok "Installed Font Packages"
  88. msg_info "Installing X11 Packages"
  89. $STD apt-get install -y \
  90. libx11-6 \
  91. libx11-xcb1 \
  92. libxcb1 \
  93. libxcomposite1 \
  94. libxcursor1 \
  95. libxdamage1 \
  96. libxext6 \
  97. libxfixes3 \
  98. libxi6 \
  99. libxrandr2 \
  100. libxrender1 \
  101. libxss1 \
  102. libxtst6
  103. msg_ok "Installed X11 Packages"
  104. msg_info "Creating Services"
  105. cat <<EOF >/etc/systemd/system/changedetection.service
  106. [Unit]
  107. Description=Change Detection
  108. After=network-online.target
  109. After=network.target browserless.service
  110. Wants=browserless.service
  111. [Service]
  112. Type=simple
  113. WorkingDirectory=/opt/changedetection
  114. Environment="WEBDRIVER_URL=http://127.0.0.1:4444/wd/hub"
  115. Environment="PLAYWRIGHT_DRIVER_URL=ws://127.0.0.1:3000/?stealth=1&--disable-web-security=true"
  116. ExecStart=changedetection.io -d /opt/changedetection -p 5000
  117. [Install]
  118. WantedBy=multi-user.target
  119. EOF
  120. cat <<EOF >/etc/systemd/system/browserless.service
  121. [Unit]
  122. Description=browserless service
  123. After=network.target
  124. [Service]
  125. Environment=APP_DIR=/opt/browserless
  126. Environment=PLAYWRIGHT_BROWSERS_PATH=/opt/browserless
  127. Environment=CONNECTION_TIMEOUT=60000
  128. Environment=HOST=127.0.0.1
  129. Environment=LANG="C.UTF-8"
  130. Environment=NODE_ENV=production
  131. Environment=PORT=3000
  132. Environment=WORKSPACE_DIR=/opt/browserless/workspace
  133. WorkingDirectory=/opt/browserless
  134. ExecStart=/opt/browserless/start.sh
  135. SyslogIdentifier=browserless
  136. [Install]
  137. WantedBy=default.target
  138. EOF
  139. systemctl enable -q --now browserless
  140. systemctl enable -q --now changedetection
  141. msg_ok "Created Services"
  142. motd_ssh
  143. customize
  144. msg_info "Cleaning up"
  145. $STD apt-get autoremove
  146. $STD apt-get autoclean
  147. msg_ok "Cleaned"