In principle, Obsidian can self-update by downloading the new version into your home .config folder. Instead, I suggest disabling the self-update and use the script to build a new xzm module, similar to how you stop your web browser's self-update on porteus because it's unable to update the xzm module.
Code: Select all
#!/usr/bin/bash
# When Obsidian reports a new version
# close it and run this script instead
URL=https://api.github.com/repos/obsidianmd/obsidian-releases/releases/latest
cd $MODDIR
xzm=$(find . -name obsidian*.xzm)
#assuming e.g. obsidian_1.8.9_amd64.xzm
current=$(basename $xzm | cut -d _ -f 2)
url=$(curl -s $URL | grep -oP '"browser_download_url": "\K.*?\.deb(?=")')
latest=$(basename $url | cut -d _ -f 2)
echo "$latest > $current"
#the following comparison is lexicographical so 1.8.10<1.8.9
#if [[ $latest > $current ]]; then
if [[ $(printf '%s\n' "$current" "$latest" | sort -V | tail -n1) != "$current" ]]; then
echo "Upgrading from $current to $latest"
deactivate $xzm -q
mv $xzm ${xzm%?}_
#xzm=${xzm%?}_
wget -Nq --show-progress $url
deb2xzm -z $(basename $url)
activate $(basename $url .deb).xzm -q
fi
xzmDEL=$(find . -name obsidian*.xz_)
debDEL=$(find . -name obsidian*.deb)
if [[ -n "$xzmDEL" || -n "$debDEL" ]]; then
echo "$(tput setaf 2) These can be deleted:" #green
ls $xzmDEL $debDEL
echo "$(tput bold) "
read -t 10 -n 1 -r -p "Delete them now? [y/N] " response
if [[ $response == [yY] ]]; then
rm $xzmDEL $debDEL
fi
echo "$(tput sgr0)"
fi
# test run under root:
#obsidian --no-sandbox
#/opt/Obsidian/obsidian --no-sandbox
Code: Select all
!/root/.config/obsidian/*Cache