Skip to content

Commit

Permalink
cover more situations in rename.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Mory <[email protected]>
  • Loading branch information
morytyann committed Feb 9, 2025
1 parent 29057ae commit d6a1492
Showing 1 changed file with 46 additions and 17 deletions.
63 changes: 46 additions & 17 deletions rename.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
#!/bin/sh

# uninstall mihomo
# Rename from MihomoTProxy to Nikki

# if mihomo is installed, uninstall it
# if nikki is not installed, install it
# if config and files exists, migrate it
# if mihomo feed is configured, remove it and add nikki feed

migrate() {
if [ -f "/etc/config/mihomo" ]; then
cp -f /etc/config/mihomo /etc/config/nikki
rm -f /etc/config/mihomo
fi
if [ -d "/etc/mihomo" ]; then
mkdir -p /etc/nikki
cp -r /etc/mihomo/. /etc/nikki
rm -rf /etc/mihomo
fi
service nikki restart
}

if [ -x "/bin/opkg" ]; then
opkg remove luci-i18n-mihomo-zh-cn
opkg remove luci-app-mihomo
opkg remove mihomo
if (opkg list-installed | grep -q mihomo); then
opkg remove luci-i18n-mihomo-zh-cn
opkg remove luci-app-mihomo
opkg remove mihomo
fi
if (! opkg list-installed | grep -q nikki); then
curl -s -L https://github.com/nikkinikki-org/OpenWrt-nikki/raw/refs/heads/main/install.sh | ash
fi
migrate
if (grep -q mihomo /etc/opkg/customfeeds.conf); then
sed -i '/mihomo/d' /etc/opkg/customfeeds.conf
curl -s -L https://github.com/nikkinikki-org/OpenWrt-nikki/raw/refs/heads/main/feed.sh | ash
fi
elif [ -x "/usr/bin/apk" ]; then
apk del luci-i18n-mihomo-zh-cn
apk del luci-app-mihomo
apk del mihomo
if (apk list -I | grep -q mihomo); then
apk del luci-i18n-mihomo-zh-cn
apk del luci-app-mihomo
apk del mihomo
fi
if (apk list -I | grep -q nikki); then
curl -s -L https://github.com/nikkinikki-org/OpenWrt-nikki/raw/refs/heads/main/install.sh | ash
fi
migrate
if (grep -q mihomo /etc/apk/repositories.d/customfeeds.list); then
sed -i '/mihomo/d' /etc/apk/repositories.d/customfeeds.list
curl -s -L https://github.com/nikkinikki-org/OpenWrt-nikki/raw/refs/heads/main/feed.sh | ash
fi
fi
# copy config from mihomo to nikki
cp -f /etc/config/mihomo /etc/config/nikki
# copy files from mihomo to nikki
cp -rf /etc/nikki /etc/mihomo
# remove mihomo config
rm -f /etc/config/mihomo
# remove mihomo files
rm -rf /etc/mihomo
# reload nikki service
service nikki reload

0 comments on commit d6a1492

Please sign in to comment.