mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
Merge pull request #4802 from mglae/le10_waitonnetwork_4sec
kodi-waitonnetwork: enabled by default with 10 sec timeout / use NTP for Online Status
This commit is contained in:
commit
844c2fa76e
@ -3,8 +3,8 @@
|
||||
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="LibreELEC-settings"
|
||||
PKG_VERSION="e7559693978aa2adc9854f968bf955eeeab62de4"
|
||||
PKG_SHA256="3135fecfcd78f0fc7760735eff17ebdffe603de7ba4f1c3230633c11a3237d3a"
|
||||
PKG_VERSION="248e7874586966ed1f7177dc8f85e3b3eec95a7a"
|
||||
PKG_SHA256="a64a187dc61dc1c5c127b21549a1e548fbe3acada616f23b35a7a7a260357870"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE="https://libreelec.tv"
|
||||
PKG_URL="https://github.com/LibreELEC/service.libreelec.settings/archive/${PKG_VERSION}.tar.gz"
|
||||
|
3
packages/mediacenter/kodi/config/network_wait
Normal file
3
packages/mediacenter/kodi/config/network_wait
Normal file
@ -0,0 +1,3 @@
|
||||
WAIT_NETWORK="true"
|
||||
WAIT_NETWORK_TIME="10"
|
||||
WAIT_NETWORK_DEFAULT="true"
|
@ -315,6 +315,9 @@ post_makeinstall_target() {
|
||||
$PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/appliance.xml \
|
||||
> $INSTALL/usr/share/kodi/system/settings/appliance.xml
|
||||
|
||||
mkdir -p $INSTALL/usr/cache/libreelec
|
||||
cp $PKG_DIR/config/network_wait $INSTALL/usr/cache/libreelec
|
||||
|
||||
# update addon manifest
|
||||
ADDON_MANIFEST=$INSTALL/usr/share/kodi/system/addon-manifest.xml
|
||||
xmlstarlet ed -L -d "/addons/addon[text()='service.xbmc.versioncheck']" $ADDON_MANIFEST
|
||||
|
@ -4,13 +4,13 @@ After=connman.service
|
||||
Before=network-online.target
|
||||
DefaultDependencies=no
|
||||
Conflicts=shutdown.target
|
||||
ConditionPathExists=/storage/.cache/libreelec/network_wait
|
||||
ConditionFileNotEmpty=/storage/.cache/libreelec/network_wait
|
||||
ConditionPathExists=!/dev/.kernel_ipconfig
|
||||
ConditionPathExists=/storage/.kodi/userdata/addon_data/service.libreelec.settings/oe_settings.xml
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
EnvironmentFile=/storage/.cache/libreelec/network_wait
|
||||
ExecStartPre=/bin/sh -c 'echo "waiting on Network to come online ... (max. $WAIT_NETWORK_TIME sec.)"'
|
||||
ExecStart=/usr/sbin/connmand-wait-online --timeout=${WAIT_NETWORK_TIME}
|
||||
StandardOutput=tty
|
||||
RemainAfterExit=yes
|
||||
|
@ -2,22 +2,53 @@
|
||||
/* Copyright (C) 2020-present Team LibreELEC (https://libreelec.tv) */
|
||||
|
||||
#include <sys/timex.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
int main()
|
||||
#define POLL_FREQ 10
|
||||
|
||||
void usage(char *name)
|
||||
{
|
||||
int rc;
|
||||
if (!name)
|
||||
name = "wait-time-sync";
|
||||
|
||||
for (;;)
|
||||
printf("Usage: %s [-t seconds | --timeout seconds]\n", name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
unsigned timeout = UINT_MAX;
|
||||
int rc = 0;
|
||||
|
||||
if (argc == 3)
|
||||
{
|
||||
unsigned long val;
|
||||
char *p;
|
||||
|
||||
if (strcmp(argv[1], "-t") && strcmp(argv[1], "--timeout"))
|
||||
usage(argv[0]);
|
||||
val = strtoul(argv[2], &p, 0);
|
||||
if (*p || val == 0 || val >= UINT_MAX / POLL_FREQ)
|
||||
usage(argv[0]);
|
||||
timeout = (unsigned)val * POLL_FREQ;
|
||||
}
|
||||
else if (argc != 1)
|
||||
usage(argv[0]);
|
||||
|
||||
for ( ; timeout; --timeout)
|
||||
{
|
||||
struct timex tx = {};
|
||||
|
||||
rc = adjtimex(&tx);
|
||||
if (rc != TIME_ERROR)
|
||||
break;
|
||||
usleep(1000000U/3);
|
||||
usleep(1000000U / POLL_FREQ);
|
||||
}
|
||||
|
||||
return rc == -1 ? errno : 0;
|
||||
return rc == -1 ? errno : !timeout;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user