aredn/files/etc/uci-defaults/45_aredn_reset_paths

66 lines
1.8 KiB
Plaintext
Raw Normal View History

#!/bin/sh
#check for modified path values and update if needed
#will not change existing custom entries
DISTRIB_TARGET=$(grep DISTRIB_TARGET /etc/openwrt_release|cut -d'=' -f2|tr -d "'")
DISTRIB_RELEASE=$(grep DISTRIB_RELEASE /etc/openwrt_release|cut -d'=' -f2|tr -d "'")
SERVER_PREFIX='http://downloads.arednmesh.org/'
SNAPSHOT_PREFIX='snapshots/trunk/'
getReleasePrefix()
{
local PREFIX=""
ccount=`expr "${DISTRIB_RELEASE}" : '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'`
if [ "$ccount" -ne 0 ]; then
v1=$(echo ${DISTRIB_RELEASE} | cut -d'.' -f1)
v2=$(echo ${DISTRIB_RELEASE} | cut -d'.' -f2)
PREFIX="releases/${v1}/${v2}/${DISTRIB_RELEASE}/"
else
PREFIX="${SNAPSHOT_PREFIX}"
fi
echo $PREFIX
}
defaultPackageRepos()
{
repo=$1
if [ "$repo" == "core" ]; then
echo "${SERVER_PREFIX}${BUILD_PREFIX}targets/${DISTRIB_TARGET}/packages"
else
echo "${SERVER_PREFIX}${BUILD_PREFIX}packages/mips_24kc/${repo}"
fi
}
checkPath()
{
uciopt=$1
repo=$2
uci_val=$(/sbin/uci -c /etc/config.mesh get "aredn.@downloads[0].${uciopt}")
default_val=$(eval defaultPackageRepos "${repo}")
# is the current value different than the default?
if [ "${uci_val}" != "${default_val}" ]; then
# does the non-standard value START with downloads.arednmesh.org? if so, change it, if NOT, leave it.
count=$(expr "${uci_val}" : "http:\\/\\/downloads.arednmesh.org\\/.*")
if [ "${count}" -gt 0 ]; then #starts with default server
/sbin/uci set "aredn.@downloads[0].${uciopt}=${default_val}"
fi
fi
}
BUILD_PREFIX=$(eval getReleasePrefix)
# set
checkPath pkgs_core core
checkPath pkgs_base base
checkPath pkgs_arednpackages arednpackages
checkPath pkgs_luci luci
checkPath pkgs_packages packages
checkPath pkgs_routing routing
checkPath pkgs_telephony telephony
/sbin/uci commit aredn
cp /etc/config/aredn /etc/config.mesh