openwrt_helloworld/mihomo/files/uci-defaults/init.sh
gitea-action 75d53d73fe mihomo: sync upstream
last commit: d641bfc31c
2024-09-30 11:00:48 +08:00

25 lines
557 B
Bash

#!/bin/sh
. "$IPKG_INSTROOT/etc/mihomo/scripts/constants.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