changedetection-install.sh 3.5 KB

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