Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • firmware/gluon
  • 0x4A6F/gluon
  • patrick/gluon
3 results
Select Git revision
Loading items
Show changes
Showing
with 88 additions and 163 deletions
#!/bin/sh
# shellcheck source=package/gluon-autoupdater/files/lib/gluon/autoupdater/lib.sh
. /lib/gluon/autoupdater/lib.sh
......
#!/bin/sh
# shellcheck source=package/gluon-autoupdater/files/lib/gluon/autoupdater/lib.sh
. /lib/gluon/autoupdater/lib.sh
stop gluon-respondd
......@@ -3,8 +3,6 @@
local uci = require('simple-uci').cursor()
local site = require('gluon.site')
uci:delete('firewall', 'wan_announced')
-- Allow respondd port on WAN to allow resolving neighbours over mesh-on-wan
uci:section('firewall', 'rule', 'wan_respondd', {
name = 'wan_respondd',
......@@ -18,7 +16,7 @@ uci:section('firewall', 'rule', 'wan_respondd', {
-- Allow respondd-access for local clients
uci:section('firewall', 'rule', 'client_respondd', {
name = 'client_respondd',
src = 'local_client',
src = 'loc_client',
src_ip = 'fe80::/64',
dest_port = '1001',
proto = 'udp',
......
/*
Copyright (c) 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SPDX-FileCopyrightText: 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net> */
/* SPDX-License-Identifier: BSD-2-Clause */
#pragma once
......
/*
Copyright (c) 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SPDX-FileCopyrightText: 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net> */
/* SPDX-License-Identifier: BSD-2-Clause */
#include "respondd-common.h"
......@@ -82,18 +60,18 @@ static struct json_object * get_wifi(void) {
struct json_object *ret = json_object_new_object();
struct uci_package *p;
if (uci_load(ctx, "network", &p))
if (uci_load(ctx, "wireless", &p))
goto end;
struct uci_element *e;
uci_foreach_element(&p->sections, e) {
struct uci_section *s = uci_to_section(e);
if (strcmp(s->type, "interface"))
if (strcmp(s->type, "wifi-iface"))
continue;
const char *proto = uci_lookup_option_string(ctx, s, "proto");
if (!proto || strcmp(proto, "gluon_mesh"))
const char *proto = uci_lookup_option_string(ctx, s, "mode");
if (!proto || strcmp(proto, "mesh"))
continue;
const char *ifname = uci_lookup_option_string(ctx, s, "ifname");
......
/*
Copyright (c) 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SPDX-FileCopyrightText: 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net> */
/* SPDX-License-Identifier: BSD-2-Clause */
#include "respondd-common.h"
......@@ -123,6 +101,9 @@ struct json_object * respondd_provider_nodeinfo(void) {
struct json_object *software_firmware = json_object_new_object();
json_object_object_add(software_firmware, "base", gluon_version());
json_object_object_add(software_firmware, "release", gluonutil_wrap_and_free_string(gluonutil_read_line("/lib/gluon/release")));
json_object_object_add(software_firmware, "target", gluonutil_wrap_string(platforminfo_get_target()));
json_object_object_add(software_firmware, "subtarget", gluonutil_wrap_string(platforminfo_get_subtarget()));
json_object_object_add(software_firmware, "image_name", gluonutil_wrap_string(platforminfo_get_image_name()));
json_object_object_add(software, "firmware", software_firmware);
json_object_object_add(ret, "software", software);
......
/*
Copyright (c) 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SPDX-FileCopyrightText: 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net> */
/* SPDX-License-Identifier: BSD-2-Clause */
#include "respondd-common.h"
......@@ -239,7 +217,7 @@ static void count_iface_stations(size_t *wifi24, size_t *wifi5, const char *ifna
}
}
static void count_stations(size_t *wifi24, size_t *wifi5, size_t *owe24, size_t owe5) {
static void count_stations(size_t *wifi24, size_t *wifi5, size_t *owe24, size_t *owe5) {
struct uci_context *ctx = uci_alloc_context();
if (!ctx)
return;
......
/*
Copyright (c) 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SPDX-FileCopyrightText: 2016-2019, Matthias Schiffer <mschiffer@universe-factory.net> */
/* SPDX-License-Identifier: BSD-2-Clause */
#include "respondd-common.h"
......
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-scheduled-domain-switch
PKG_VERSION:=1
include ../gluon.mk
define Package/gluon-scheduled-domain-switch
TITLE:=Allows scheduled migrations between domains
DEPENDS:=+gluon-core @GLUON_MULTIDOMAIN
DEPENDS:=+gluon-core +gluon-state-check @GLUON_MULTIDOMAIN
endef
$(eval $(call BuildPackageGluon,gluon-scheduled-domain-switch))
......@@ -2,5 +2,6 @@ if need_table(in_domain({'domain_switch'}), nil, false) then
need_domain_name(in_domain({'domain_switch', 'target_domain'}))
need_number(in_domain({'domain_switch', 'switch_after_offline_mins'}))
need_number(in_domain({'domain_switch', 'switch_time'}))
need_string_array_match(in_domain({'domain_switch', 'connection_check_targets'}), '^[%x:]+$')
obsolete({'domain_switch', 'connection_check_targets'},
'Connections to NTP servers and gateways are used for this now.')
end
......@@ -60,8 +60,5 @@ if not switch_after_min_reached() and not switch_time_passed() then
os.exit(0)
end
uci:set("gluon", "core", "domain", target_domain)
uci:commit("gluon")
os.execute("gluon-reconfigure")
os.execute("reboot")
local cmd = {[0] = 'gluon-switch-domain', target_domain}
unistd.execp(cmd[0], cmd)
......@@ -14,5 +14,5 @@ end
-- Only in case domain switch is scheduled
local f = io.open(cronfile, "w")
f:write("* * * * * /usr/bin/gluon-check-connection\n")
f:write("*/5 * * * * /usr/bin/gluon-switch-domain\n")
f:write("*/5 * * * * /lib/gluon/scheduled-domain-switch/switch-domain\n")
f:close()
......@@ -5,7 +5,14 @@ local util = require 'gluon.util'
local site = require 'gluon.site'
local offline_flag_file = "/tmp/gluon_offline"
local is_offline = true
local ntp_negative_state_file = "/var/gluon/state/has_lost_ntp_sync"
local function is_offline()
return unistd.access(ntp_negative_state_file)
end
-- Check if domain-switch is scheduled
if site.domain_switch() == nil then
......@@ -13,16 +20,7 @@ if site.domain_switch() == nil then
os.exit(0)
end
-- Check reachability of pre-defined targets
for _, ip in ipairs(site.domain_switch.connection_check_targets()) do
local exit_code = os.execute("ping -c 1 -w 10 " .. ip)
if exit_code == 0 then
is_offline = false
break
end
end
if is_offline then
if is_offline() then
-- Check if we were previously offline
if unistd.access(offline_flag_file) then
os.exit(0)
......
......@@ -4,17 +4,43 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-setup-mode
PKG_VERSION:=1
include ../gluon.mk
define Package/gluon-setup-mode
TITLE:=Setup mode
DEPENDS:=+gluon-core +gluon-lock-password +ubus +dnsmasq
DEPENDS:=+gluon-core +gluon-lock-password +ubus +dnsmasq-full \
+!BUSYBOX_CONFIG_NSENTER:nsenter +!BUSYBOX_CONFIG_UNSHARE:unshare
endef
define Package/gluon-setup-mode/description
Offline mode to perform basic setup in a secure manner.
endef
define Package/gluon-setup-mode/conffiles
/etc/config/gluon-setup-mode
endef
init_links := \
K89log \
K98boot \
K99umount \
S00sysfixtime \
S10boot \
S10gluon-core-reconfigure \
S10system \
S11sysctl \
S12log \
S95done
define Package/gluon-setup-mode/install
$(Gluon/Build/Install)
$(LN) S20network $(1)/lib/gluon/setup-mode/rc.d/K90network
for link in $(init_links); do \
$(LN) "/etc/init.d/$$$${link:3}" "$(1)/lib/gluon/setup-mode/rc.d/$$$${link}"; \
done
endef
$(eval $(call BuildPackageGluon,gluon-setup-mode))
......@@ -6,11 +6,15 @@ wait=3
wait_setup_mode() {
sleep $wait
uci set 'gluon-setup-mode.@setup_mode[0].enabled=1'
uci commit gluon-setup-mode
reboot
gluon-enter-setup-mode
}
# Special case for devices that use capacitive buttons
case "$(board_name)" in
genexis,pulse-ex400)
[ "$BUTTON" = wps ] && exit 0
;;
esac
if [ "$BUTTON" = wps ] || [ "$BUTTON" = reset ] || [ "$BUTTON" = phone ]; then
case "$ACTION" in
......
#!/bin/sh
exec /bin/ash --login
#!/bin/sh
export SHELL=/bin/ash
exec nsenter --target=1 --mount --wd="$PWD" "$SHELL" --login "$@"
#!/bin/sh
exec unshare -m /bin/sh -ec '
mount -t overlay overlay -olowerdir=/lib/gluon/setup-mode/dropbear/etc:/etc /etc
exec /usr/sbin/dropbear "$@"
' - "$@"
root:x:0:0:root:/root:/lib/gluon/setup-mode/dropbear/ash