bugfix: re-submit path reset2 (previously approved) (#75)

This commit is contained in:
dman776 2021-03-12 20:02:08 -06:00 committed by GitHub
parent 4b86b4f02a
commit cdf8057f65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 55 additions and 71 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
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
# PKGS_AREDNPACKAGES
checkPath("pkgs_arednpackages", "arednpackages");
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_LUCI
checkPath("pkgs_luci", "luci");
checkPath()
{
uciopt=$1
repo=$2
uci_val=$(/sbin/uci -c /etc/config.mesh get "aredn.@downloads[0].${uciopt}")
default_val=$(eval defaultPackageRepos "${repo}")
# PKGS_PACKAGES
checkPath("pkgs_packages", "packages");
# 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_ROUTING
checkPath("pkgs_routing", "routing");
BUILD_PREFIX=$(eval getReleasePrefix)
# PKGS_TELEPHONY
checkPath("pkgs_telephony", "telephony");
# 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
&uci_commit("aredn");
/sbin/uci commit aredn
cp /etc/config/aredn /etc/config.mesh