Update photoprism-v5-install.sh

code refactoring
This commit is contained in:
tteckster 2023-02-17 16:58:54 -05:00 committed by GitHub
parent 0d1131ff6d
commit e4b01b02a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,6 @@
if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi
silent() { "$@" > /dev/null 2>&1; } silent() { "$@" > /dev/null 2>&1; }
if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi
AVX=$(grep -o -m1 'avx[^ ]*' /proc/cpuinfo)
YW=$(echo "\033[33m") YW=$(echo "\033[33m")
RD=$(echo "\033[01;31m") RD=$(echo "\033[01;31m")
BL=$(echo "\033[36m") BL=$(echo "\033[36m")
@ -106,10 +105,15 @@ msg_info "Installing Node.js"
$STD apt-get -y install nodejs $STD apt-get -y install nodejs
msg_ok "Installed Node.js" msg_ok "Installed Node.js"
msg_info "Installing Golang (Patience)" msg_info "Installing Golang"
$STD wget https://golang.org/dl/go1.20.1.linux-amd64.tar.gz set +o pipefail
$STD tar -xzf go1.20.1.linux-amd64.tar.gz -C /usr/local RELEASE=$(curl -s https://go.dev/dl/ | grep -o "go.*\linux-amd64.tar.gz" | head -n 1)
wget -q https://golang.org/dl/$RELEASE
$STD tar -xzf $RELEASE -C /usr/local
$STD ln -s /usr/local/go/bin/go /usr/local/bin/go $STD ln -s /usr/local/go/bin/go /usr/local/bin/go
msg_ok "Installed Golang"
msg_info "Installing Go Dependencies"
$STD go install github.com/tianon/gosu@latest $STD go install github.com/tianon/gosu@latest
$STD go install golang.org/x/tools/cmd/goimports@latest $STD go install golang.org/x/tools/cmd/goimports@latest
$STD go install github.com/psampaz/go-mod-outdated@latest $STD go install github.com/psampaz/go-mod-outdated@latest
@ -121,20 +125,21 @@ cp /usr/local/go/bin/richgo /usr/local/bin/richgo
cp /usr/local/go/bin/gosu /usr/local/sbin/gosu cp /usr/local/go/bin/gosu /usr/local/sbin/gosu
chown root:root /usr/local/sbin/gosu chown root:root /usr/local/sbin/gosu
chmod 755 /usr/local/sbin/gosu chmod 755 /usr/local/sbin/gosu
msg_ok "Installed Golang" msg_ok "Installed Go Dependencies"
msg_info "Installing Tensorflow" msg_info "Installing Tensorflow"
if [[ "$AVX" =~ avx2 ]]; then if grep -q avx2 /proc/cpuinfo; then
$STD wget https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-avx2-1.15.2.tar.gz suffix="avx2-"
$STD tar -C /usr/local -xzf libtensorflow-linux-avx2-1.15.2.tar.gz elif grep -q avx /proc/cpuinfo; then
elif [[ "$AVX" =~ avx ]]; then suffix="avx-"
$STD wget https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-avx-1.15.2.tar.gz
$STD tar -C /usr/local -xzf libtensorflow-linux-avx-1.15.2.tar.gz
else else
$STD wget https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-cpu-1.15.2.tar.gz suffix=""
$STD tar -C /usr/local -xzf libtensorflow-linux-cpu-1.15.2.tar.gz
fi fi
$STD ldconfig version=$(curl -s https://dl.photoprism.org/tensorflow/amd64/ | grep -o "libtensorflow-amd64-$suffix.*\\.tar.gz" | head -n 1)
wget -q https://dl.photoprism.org/tensorflow/amd64/$version
tar -C /usr/local -xzf $version
ldconfig
set -o pipefail
msg_ok "Installed Tensorflow" msg_ok "Installed Tensorflow"
msg_info "Cloning PhotoPrism" msg_info "Cloning PhotoPrism"
@ -205,12 +210,10 @@ $STD apt-get autoremove
$STD apt-get autoclean $STD apt-get autoclean
rm -rf /var/{cache,log}/* \ rm -rf /var/{cache,log}/* \
/photoprism \ /photoprism \
/go1.20.1.linux-amd64.tar.gz \ /$RELEASE \
/libtensorflow-linux-avx2-1.15.2.tar.gz \ /$version
/libtensorflow-linux-avx-1.15.2.tar.gz \
/libtensorflow-linux-cpu-1.15.2.tar.gz
msg_ok "Cleaned" msg_ok "Cleaned"
msg_info "Starting PhotoPrism" msg_info "Starting PhotoPrism"
$STD systemctl enable --now photoprism systemctl enable -q --now photoprism
msg_ok "Started PhotoPrism" msg_ok "Started PhotoPrism"