changedetection-install.sh 3.5 KB

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