From c6b7a1e4a401c33abae94b164187886fdecbdf03 Mon Sep 17 00:00:00 2001 From: tteckster Date: Wed, 16 Mar 2022 10:03:14 -0400 Subject: [PATCH] Create photoprism-update.sh --- misc/photoprism-update.sh | 108 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 misc/photoprism-update.sh diff --git a/misc/photoprism-update.sh b/misc/photoprism-update.sh new file mode 100644 index 00000000..0c7cda8f --- /dev/null +++ b/misc/photoprism-update.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +set -e +RELEASE=$(curl -s https://api.github.com/repos/photoprism/photoprism/releases/latest \ +| grep "tag_name" \ +| awk '{print substr($2, 2, length($2)-4) }') \ + +YW=`echo "\033[33m"` +BL=`echo "\033[36m"` +RD=`echo "\033[01;31m"` +CM='\xE2\x9C\x94\033' +GN=`echo "\033[1;92m"` +CL=`echo "\033[m"` +PP=`echo "\e[1;35m"` + +while true; do + read -p "Update PhotoPrism LXC. Proceed(y/n)?" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac +done +clear +function header_info { +echo -e "${PP} + _____ _ _ _____ _ + | __ \| | | | | __ \ (_) + | |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___ + | ___/| _ \ / _ \| __/ _ \| ___/ __| / __| _ _ \ + | | | | | | (_) | || (_) | | | | | \__ \ | | | | | + |_| |_| |_|\___/ \__\___/|_| |_| |_|___/_| |_| |_| + ${RD} UPDATE +${CL}" +} + +header_info +show_menu(){ + printf " ${YW} 1)${GN} Release Branch ${CL}\n" + printf " ${YW} 2)${YW} Develop Branch ${CL}\n" + + printf "Please choose a Install Branch and hit enter or ${RD}x${CL} to exit." + read opt +} + +option_picked(){ + message1=${@:-"${CL}Error: No message passed"} + printf " ${YW}${message1}${CL}\n" +} +show_menu +while [ $opt != '' ] + do + if [ $opt = '' ]; then + exit; + else + case $opt in + 1) clear; + header_info; + option_picked "Using Release Branch"; + BR="release" + break; + ;; + 2) clear; + header_info; + option_picked "Using Develop Branch"; + BR="develop" + break; + ;; + + x)exit; + ;; + \n)exit; + ;; + *)clear; + option_picked "Please choose a Install Branch from the menu"; + show_menu; + ;; + esac + fi + done + +echo -en "${GN} Stopping PhotoPrism... " +sudo systemctl stop photoprism +echo -e "${CM}${CL} \r" + +echo -en "${GN} Cloning PhotoPrism ${BR} branch... " +git clone https://github.com/photoprism/photoprism.git &>/dev/null +cd photoprism +git checkout ${BR} &>/dev/null +echo -e "${CM}${CL} \r" + +echo -en "${GN} Building PhotoPrism ${BR} branch... " +sudo make all &>/dev/null +sudo ./scripts/build.sh prod /opt/photoprism/bin/photoprism &>/dev/null +sudo cp -a assets/ /opt/photoprism/assets/ &>/dev/null +echo -e "${CM}${CL} \r" + +echo -en "${GN} Cleaning... " +cd ~ +rm -rf photoprism +echo -e "${CM}${CL} \r" + +echo -en "${GN} Starting PhotoPrism... " +sudo systemctl start photoprism +echo -e "${CM}${CL} \n" + +echo -e "${GN} Finished ${CL} \n " + +