photoprism-install.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 curl
  15. $STD apt-get install -y sudo
  16. $STD apt-get install -y mc
  17. $STD apt-get install -y gcc
  18. $STD apt-get install -y g++
  19. $STD apt-get install -y git
  20. $STD apt-get install -y gnupg
  21. $STD apt-get install -y make
  22. $STD apt-get install -y zip
  23. $STD apt-get install -y exiftool
  24. $STD apt-get install -y ffmpeg
  25. msg_ok "Installed Dependencies"
  26. msg_info "Setting up Node.js Repository"
  27. $STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x)
  28. msg_ok "Set up Node.js Repository"
  29. msg_info "Installing Node.js"
  30. $STD apt-get -y install nodejs
  31. msg_ok "Installed Node.js"
  32. msg_info "Installing Golang"
  33. set +o pipefail
  34. RELEASE=$(curl -s https://go.dev/dl/ | grep -o "go.*\linux-amd64.tar.gz" | head -n 1)
  35. wget -q https://golang.org/dl/$RELEASE
  36. $STD tar -xzf $RELEASE -C /usr/local
  37. $STD ln -s /usr/local/go/bin/go /usr/local/bin/go
  38. msg_ok "Installed Golang"
  39. msg_info "Installing Go Dependencies"
  40. $STD go install github.com/tianon/gosu@latest
  41. $STD go install golang.org/x/tools/cmd/goimports@latest
  42. $STD go install github.com/psampaz/go-mod-outdated@latest
  43. $STD go install github.com/dsoprea/go-exif/v3/command/exif-read-tool@latest
  44. $STD go install github.com/mikefarah/yq/v4@latest
  45. $STD go install github.com/kyoh86/richgo@latest
  46. cp /root/go/bin/* /usr/local/go/bin/
  47. cp /usr/local/go/bin/richgo /usr/local/bin/richgo
  48. cp /usr/local/go/bin/gosu /usr/local/sbin/gosu
  49. chown root:root /usr/local/sbin/gosu
  50. chmod 755 /usr/local/sbin/gosu
  51. msg_ok "Installed Go Dependencies"
  52. msg_info "Installing Tensorflow"
  53. if grep -q avx2 /proc/cpuinfo; then
  54. suffix="avx2-"
  55. elif grep -q avx /proc/cpuinfo; then
  56. suffix="avx-"
  57. else
  58. suffix="1"
  59. fi
  60. version=$(curl -s https://dl.photoprism.org/tensorflow/amd64/ | grep -o "libtensorflow-amd64-$suffix.*\\.tar.gz" | head -n 1)
  61. wget -q https://dl.photoprism.org/tensorflow/amd64/$version
  62. tar -C /usr/local -xzf $version
  63. ldconfig
  64. set -o pipefail
  65. msg_ok "Installed Tensorflow"
  66. msg_info "Cloning PhotoPrism"
  67. mkdir -p /opt/photoprism/bin
  68. mkdir -p /var/lib/photoprism/storage
  69. $STD git clone https://github.com/photoprism/photoprism.git
  70. cd photoprism
  71. $STD git checkout release
  72. msg_ok "Cloned PhotoPrism"
  73. msg_info "Building PhotoPrism (Patience)"
  74. $STD make -B
  75. $STD ./scripts/build.sh prod /opt/photoprism/bin/photoprism
  76. $STD cp -r assets/ /opt/photoprism/
  77. msg_ok "Built PhotoPrism"
  78. env_path="/var/lib/photoprism/.env"
  79. echo "
  80. PHOTOPRISM_AUTH_MODE='password'
  81. PHOTOPRISM_ADMIN_PASSWORD='changeme'
  82. PHOTOPRISM_HTTP_HOST='0.0.0.0'
  83. PHOTOPRISM_HTTP_PORT='2342'
  84. PHOTOPRISM_SITE_CAPTION='https://tteck.github.io/Proxmox/'
  85. PHOTOPRISM_STORAGE_PATH='/var/lib/photoprism/storage'
  86. PHOTOPRISM_ORIGINALS_PATH='/var/lib/photoprism/photos/Originals'
  87. PHOTOPRISM_IMPORT_PATH='/var/lib/photoprism/photos/Import'
  88. " >$env_path
  89. msg_info "Creating Service"
  90. service_path="/etc/systemd/system/photoprism.service"
  91. echo "[Unit]
  92. Description=PhotoPrism service
  93. After=network.target
  94. [Service]
  95. Type=forking
  96. User=root
  97. WorkingDirectory=/opt/photoprism
  98. EnvironmentFile=/var/lib/photoprism/.env
  99. ExecStart=/opt/photoprism/bin/photoprism up -d
  100. ExecStop=/opt/photoprism/bin/photoprism down
  101. [Install]
  102. WantedBy=multi-user.target" >$service_path
  103. msg_ok "Created Service"
  104. motd_ssh
  105. customize
  106. msg_info "Cleaning up"
  107. $STD apt-get autoremove
  108. $STD apt-get autoclean
  109. rm -rf /var/{cache,log}/* \
  110. /photoprism \
  111. /$RELEASE \
  112. /$version
  113. msg_ok "Cleaned"
  114. msg_info "Starting PhotoPrism"
  115. systemctl enable -q --now photoprism
  116. msg_ok "Started PhotoPrism"