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:
CvH 2021-01-06 21:01:02 +01:00 committed by GitHub
commit 844c2fa76e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 9 deletions

View File

@ -3,8 +3,8 @@
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv) # Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="LibreELEC-settings" PKG_NAME="LibreELEC-settings"
PKG_VERSION="e7559693978aa2adc9854f968bf955eeeab62de4" PKG_VERSION="248e7874586966ed1f7177dc8f85e3b3eec95a7a"
PKG_SHA256="3135fecfcd78f0fc7760735eff17ebdffe603de7ba4f1c3230633c11a3237d3a" PKG_SHA256="a64a187dc61dc1c5c127b21549a1e548fbe3acada616f23b35a7a7a260357870"
PKG_LICENSE="GPL" PKG_LICENSE="GPL"
PKG_SITE="https://libreelec.tv" PKG_SITE="https://libreelec.tv"
PKG_URL="https://github.com/LibreELEC/service.libreelec.settings/archive/${PKG_VERSION}.tar.gz" PKG_URL="https://github.com/LibreELEC/service.libreelec.settings/archive/${PKG_VERSION}.tar.gz"

View File

@ -0,0 +1,3 @@
WAIT_NETWORK="true"
WAIT_NETWORK_TIME="10"
WAIT_NETWORK_DEFAULT="true"

View File

@ -315,6 +315,9 @@ post_makeinstall_target() {
$PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/appliance.xml \ $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/appliance.xml \
> $INSTALL/usr/share/kodi/system/settings/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 # update addon manifest
ADDON_MANIFEST=$INSTALL/usr/share/kodi/system/addon-manifest.xml ADDON_MANIFEST=$INSTALL/usr/share/kodi/system/addon-manifest.xml
xmlstarlet ed -L -d "/addons/addon[text()='service.xbmc.versioncheck']" $ADDON_MANIFEST xmlstarlet ed -L -d "/addons/addon[text()='service.xbmc.versioncheck']" $ADDON_MANIFEST

View File

@ -4,13 +4,13 @@ After=connman.service
Before=network-online.target Before=network-online.target
DefaultDependencies=no DefaultDependencies=no
Conflicts=shutdown.target Conflicts=shutdown.target
ConditionPathExists=/storage/.cache/libreelec/network_wait ConditionFileNotEmpty=/storage/.cache/libreelec/network_wait
ConditionPathExists=!/dev/.kernel_ipconfig ConditionPathExists=!/dev/.kernel_ipconfig
ConditionPathExists=/storage/.kodi/userdata/addon_data/service.libreelec.settings/oe_settings.xml
[Service] [Service]
Type=oneshot Type=oneshot
EnvironmentFile=/storage/.cache/libreelec/network_wait 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} ExecStart=/usr/sbin/connmand-wait-online --timeout=${WAIT_NETWORK_TIME}
StandardOutput=tty StandardOutput=tty
RemainAfterExit=yes RemainAfterExit=yes

View File

@ -2,22 +2,53 @@
/* Copyright (C) 2020-present Team LibreELEC (https://libreelec.tv) */ /* Copyright (C) 2020-present Team LibreELEC (https://libreelec.tv) */
#include <sys/timex.h> #include <sys/timex.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#include <errno.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 = {}; struct timex tx = {};
rc = adjtimex(&tx); rc = adjtimex(&tx);
if (rc != TIME_ERROR) if (rc != TIME_ERROR)
break; break;
usleep(1000000U/3); usleep(1000000U / POLL_FREQ);
} }
return rc == -1 ? errno : 0; return rc == -1 ? errno : !timeout;
} }