From cdf8057f65d81f3e4b50b68dc447228609af54df Mon Sep 17 00:00:00 2001 From: dman776 Date: Fri, 12 Mar 2021 20:02:08 -0600 Subject: [PATCH] bugfix: re-submit path reset2 (previously approved) (#75) --- files/etc/uci-defaults/45_aredn_reset_paths | 126 +++++++++----------- 1 file changed, 55 insertions(+), 71 deletions(-) diff --git a/files/etc/uci-defaults/45_aredn_reset_paths b/files/etc/uci-defaults/45_aredn_reset_paths index 58ed4b43..71fafa6f 100755 --- a/files/etc/uci-defaults/45_aredn_reset_paths +++ b/files/etc/uci-defaults/45_aredn_reset_paths @@ -1,81 +1,65 @@ -#!/usr/bin/perl -=for comment +#!/bin/sh - Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks - Copyright (C) 2021 - Darryl Quinn - See Contributors file for additional contributors +#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/' - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation version 3 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - Additional Terms: - - Additional use restrictions exist on the AREDN(TM) trademark and logo. - See AREDNLicense.txt for more info. - - Attributions to the AREDN Project must be retained in the source code. - If importing this code into a new or existing project attribution - to the AREDN project must be added to the source code. - - You must not misrepresent the origin of the material contained within. - - Modified versions must be modified to attribute to the original source - and be marked in reasonable ways as differentiate it from the original - version. - -=cut - -BEGIN {push @INC, '/www/cgi-bin'}; -use perlfunc; -use ucifunc; - -$debug = 0; -$| = 1; - -sub checkPath { - my $uciopt = $_[0]; - my $repo = $_[1]; - my ($rc, $uci_val) = &uci_get_indexed_option("aredn", "downloads", "0", $uciopt); - my $default_val = &defaultPackageRepos($repo); - # is the current value different than the default? - if($uci_val ne $default_val) - { - # does the non-standard value START with downloads.arednmesh.org? if so, change it, if NOT, leave it. - if($uci_val =~ m/^http:\/\/downloads.arednmesh.org\/*./) - { - &uci_set_indexed_option("aredn", "downloads", "0", $uciopt, $default_val); - } - } +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 } -#PKGS_CORE -checkPath("pkgs_core", "aredn_core"); -# PKGS_BASE -checkPath("pkgs_base", "base"); +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 +} -# PKGS_AREDNPACKAGES -checkPath("pkgs_arednpackages", "arednpackages"); +checkPath() +{ + uciopt=$1 + repo=$2 + uci_val=$(/sbin/uci -c /etc/config.mesh get "aredn.@downloads[0].${uciopt}") + default_val=$(eval defaultPackageRepos "${repo}") -# PKGS_LUCI -checkPath("pkgs_luci", "luci"); + # 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 +} -# PKGS_PACKAGES -checkPath("pkgs_packages", "packages"); +BUILD_PREFIX=$(eval getReleasePrefix) -# PKGS_ROUTING -checkPath("pkgs_routing", "routing"); +# 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 -# PKGS_TELEPHONY -checkPath("pkgs_telephony", "telephony"); - -&uci_commit("aredn"); +/sbin/uci commit aredn +cp /etc/config/aredn /etc/config.mesh