2022-03-16 15:03:14 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2022-10-30 02:04:45 +01:00
|
|
|
RELEASE=$(curl -s https://api.github.com/repos/photoprism/photoprism/releases/latest |
|
|
|
|
grep "tag_name" |
|
|
|
|
awk '{print substr($2, 2, length($2)-4) }')
|
2022-03-16 15:03:14 +01:00
|
|
|
|
2022-10-30 02:04:45 +01:00
|
|
|
YW=$(echo "\033[33m")
|
|
|
|
BL=$(echo "\033[36m")
|
|
|
|
RD=$(echo "\033[01;31m")
|
2022-03-16 15:03:14 +01:00
|
|
|
CM='\xE2\x9C\x94\033'
|
2022-10-30 02:04:45 +01:00
|
|
|
GN=$(echo "\033[1;92m")
|
|
|
|
CL=$(echo "\033[m")
|
|
|
|
PP=$(echo "\e[1;35m")
|
2022-03-16 15:03:14 +01:00
|
|
|
|
|
|
|
while true; do
|
|
|
|
read -p "Update PhotoPrism LXC. Proceed(y/n)?" yn
|
|
|
|
case $yn in
|
2022-10-30 02:04:45 +01:00
|
|
|
[Yy]*) break ;;
|
|
|
|
[Nn]*) exit ;;
|
|
|
|
*) echo "Please answer yes or no." ;;
|
2022-03-16 15:03:14 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
clear
|
|
|
|
function header_info {
|
2022-10-30 02:04:45 +01:00
|
|
|
echo -e "${PP}
|
2022-03-16 15:03:14 +01:00
|
|
|
_____ _ _ _____ _
|
|
|
|
| __ \| | | | | __ \ (_)
|
|
|
|
| |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___
|
|
|
|
| ___/| _ \ / _ \| __/ _ \| ___/ __| / __| _ _ \
|
|
|
|
| | | | | | (_) | || (_) | | | | | \__ \ | | | | |
|
|
|
|
|_| |_| |_|\___/ \__\___/|_| |_| |_|___/_| |_| |_|
|
|
|
|
${RD} UPDATE
|
|
|
|
${CL}"
|
|
|
|
}
|
|
|
|
|
|
|
|
header_info
|
2022-10-30 02:04:45 +01:00
|
|
|
show_menu() {
|
2022-03-16 15:03:14 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-10-30 02:04:45 +01:00
|
|
|
option_picked() {
|
2022-03-16 15:03:14 +01:00
|
|
|
message1=${@:-"${CL}Error: No message passed"}
|
|
|
|
printf " ${YW}${message1}${CL}\n"
|
|
|
|
}
|
|
|
|
show_menu
|
2022-10-30 02:04:45 +01:00
|
|
|
while [ "$opt" != " " ]; do
|
|
|
|
case $opt in
|
|
|
|
1)
|
|
|
|
clear
|
|
|
|
header_info
|
|
|
|
option_picked "Using Release Branch"
|
|
|
|
BR="release"
|
|
|
|
break
|
2022-03-16 15:03:14 +01:00
|
|
|
;;
|
2022-10-30 02:04:45 +01:00
|
|
|
2)
|
|
|
|
clear
|
|
|
|
header_info
|
|
|
|
option_picked "Using Develop Branch"
|
|
|
|
BR="develop"
|
|
|
|
break
|
2022-03-16 15:03:14 +01:00
|
|
|
;;
|
|
|
|
|
2022-10-30 02:04:45 +01:00
|
|
|
x)
|
|
|
|
exit
|
2022-03-16 15:03:14 +01:00
|
|
|
;;
|
2022-10-30 02:04:45 +01:00
|
|
|
\n)
|
|
|
|
exit
|
2022-03-16 15:03:14 +01:00
|
|
|
;;
|
2022-10-30 02:04:45 +01:00
|
|
|
*)
|
|
|
|
clear
|
|
|
|
option_picked "Please choose a Install Branch from the menu"
|
|
|
|
show_menu
|
2022-03-16 15:03:14 +01:00
|
|
|
;;
|
2022-10-30 02:04:45 +01:00
|
|
|
esac
|
|
|
|
done
|
2022-03-16 15:03:14 +01:00
|
|
|
|
|
|
|
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
|
2022-11-05 13:27:36 +01:00
|
|
|
sudo rm -rf /opt/photoprism/assets
|
|
|
|
sudo cp -r assets/ /opt/photoprism/ &>/dev/null
|
2022-03-16 15:03:14 +01:00
|
|
|
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 "
|