Moon 236ad0ab43
fix: postuninst & postinst script in Linux (#1295)
* refactor: Postinstall script in linux

* fix: add postuninst script in linux
2025-10-20 07:29:35 +08:00

28 lines
1.1 KiB
Bash

#!/bin/bash
set -e
if type update-alternatives >/dev/null 2>&1; then
# Remove previous link if it doesn't use update-alternatives
if [ -L '/usr/bin/mihomo-party' ] && [ -e '/usr/bin/mihomo-party' ] && [ "$(readlink '/usr/bin/mihomo-party')" != '/etc/alternatives/mihomo-party' ]; then
rm -f '/usr/bin/mihomo-party'
fi
update-alternatives --install '/usr/bin/mihomo-party' 'mihomo-party' '/opt/mihomo-party/mihomo-party' 100 || ln -sf '/opt/mihomo-party/mihomo-party' '/usr/bin/mihomo-party'
else
ln -sf '/opt/mihomo-party/mihomo-party' '/usr/bin/mihomo-party'
fi
chmod 4755 '/opt/mihomo-party/chrome-sandbox' 2>/dev/null || true
chmod +sx /opt/mihomo-party/resources/sidecar/mihomo 2>/dev/null || true
chmod +sx /opt/mihomo-party/resources/sidecar/mihomo-alpha 2>/dev/null || true
chmod +sx /opt/mihomo-party/resources/sidecar/mihomo-smart 2>/dev/null || true
if hash update-mime-database 2>/dev/null; then
update-mime-database /usr/share/mime || true
fi
if hash update-desktop-database 2>/dev/null; then
update-desktop-database /usr/share/applications || true
fi