2022-11-23 21:25:26 -06:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-11-23 21:27:17 -06:00
|
|
|
# This is to update all apps installed on my server using lure
|
|
|
|
# The regular upgrade function of lure doesn't suffice since
|
|
|
|
# I use automatically updating version names in my install scripts
|
|
|
|
|
2023-01-27 14:30:37 -06:00
|
|
|
GREEN='\033[0;32m'
|
|
|
|
NC='\033[0m'
|
|
|
|
|
2022-12-03 03:09:23 -06:00
|
|
|
! command -v lure>/dev/null && echo "lure is not installed" && exit
|
|
|
|
! [ -f "$1" ] && echo "Please pass location of a list with github repo names" && exit
|
|
|
|
|
|
|
|
lure_list=$(lure list --installed 2>/dev/null | grep -v 'INF')
|
2022-11-23 21:25:26 -06:00
|
|
|
|
|
|
|
for f in $(cat "$1" | tr '\n' ' ')
|
|
|
|
do
|
|
|
|
pkg="$(echo $f | cut -d '/' -f 2)"
|
2022-12-03 03:09:23 -06:00
|
|
|
version_new=$(lure info $pkg 2>/dev/null | grep version | awk '{printf $2}' | sed 's/[a-zA-Z]*//g')
|
2022-11-23 21:25:26 -06:00
|
|
|
[ "$version_new" == "" ] && version_new="$(curl -sL "https://api.github.com/repos/${f}/releases/latest" | jq -r '.tag_name' | sed 's/[a-zA-Z]*//g')"
|
2022-12-03 03:09:23 -06:00
|
|
|
version_present=$(echo "$lure_list" | grep $pkg | cut -d' ' -f2 | cut -d- -f1 | sed 's/[a-zA-Z]*//g')
|
2022-11-23 21:25:26 -06:00
|
|
|
[ "$version_present" == "" ] && echo "$pkg isn't installed, skipping" && continue
|
|
|
|
if [ $(echo $version_present$'\n'$version_new | sort -V | tail -n1) != $version_present ]; then
|
2022-12-03 03:09:23 -06:00
|
|
|
echo "Upgrading $pkg ($version_present -> $version_new)"
|
2022-11-23 21:25:26 -06:00
|
|
|
lure install $pkg
|
|
|
|
else
|
2023-01-27 14:30:37 -06:00
|
|
|
echo -e "$pkg is ${GREEN}up-to-date${NC}"
|
2022-11-23 21:25:26 -06:00
|
|
|
fi
|
|
|
|
done
|