openwrt_helloworld/mihomo/files/uci-defaults/init.sh
gitea-action 5feeddd3d9 mihomo: sync upstream
last commit: f188fce1cc
2024-11-22 19:30:24 +08:00

25 lines
555 B
Bash

#!/bin/sh
. "$IPKG_INSTROOT/etc/mihomo/scripts/include.sh"
# check mihomo.config.init
init=$(uci -q get mihomo.config.init); [ -z "$init" ] && return
# generate random string for api secret and authentication password
random=$(awk 'BEGIN{srand(); print int(rand() * 1000000)}')
# set mihomo.mixin.api_secret
uci set mihomo.mixin.api_secret="$random"
# set mihomo.@authentication[0].password
uci set mihomo.@authentication[0].password="$random"
# remove mihomo.config.init
uci del mihomo.config.init
# commit
uci commit mihomo
# exit with 0
exit 0