Merge pull request #4659 from lrusak/connman-wait-online

Thanks all. Let's get some wider feedback :)
This commit is contained in:
Christian Hewitt 2016-02-07 06:39:19 +04:00
commit a0187579f7
8 changed files with 23 additions and 45 deletions

View File

@ -1,7 +1,7 @@
[Unit] [Unit]
Description=Kodi user autostart script Description=Kodi user autostart script
Before=kodi.service Before=kodi.service
After=graphical.target After=network-online.target graphical.target
ConditionPathExists=/storage/.config/autostart.sh ConditionPathExists=/storage/.config/autostart.sh
[Service] [Service]

View File

@ -1,16 +1,19 @@
[Unit] [Unit]
Description=Wait on network Description=Wait on network
Requisite=connman.service
After=connman.service After=connman.service
Before=kodi-autostart.service kodi.service Before=network-online.target
DefaultDependencies=no
Conflicts=shutdown.target
ConditionPathExists=/storage/.cache/openelec/network_wait ConditionPathExists=/storage/.cache/openelec/network_wait
[Service] [Service]
Type=oneshot Type=oneshot
EnvironmentFile=/storage/.cache/openelec/network_wait EnvironmentFile=/storage/.cache/openelec/network_wait
ExecStartPre=/bin/sh -c 'echo "waiting on Network to come online ... (max. $WAIT_NETWORK_TIME sec.)"' ExecStartPre=/bin/sh -c 'echo "waiting on Network to come online ... (max. $WAIT_NETWORK_TIME sec.)"'
ExecStart=/usr/bin/cm-online ${WAIT_NETWORK_TIME} ExecStart=/usr/sbin/connmand-wait-online --timeout=${WAIT_NETWORK_TIME}
StandardOutput=tty StandardOutput=tty
RemainAfterExit=yes RemainAfterExit=yes
[Install] [Install]
WantedBy=kodi.service WantedBy=network-online.target

View File

@ -1,7 +1,8 @@
[Unit] [Unit]
Description=Kodi Media Center Description=Kodi Media Center
After=graphical.target After=network-online.target graphical.target
Requires=graphical.target Requires=graphical.target
Wants=network-online.target
[Service] [Service]
Environment=DISPLAY=:0.0 Environment=DISPLAY=:0.0

View File

@ -1,7 +1,8 @@
[Unit] [Unit]
Description=Kodi Mediacenter Interface Description=Kodi Mediacenter Interface
Requires=multi-user.target graphical.target Requires=multi-user.target graphical.target network-online.target
After=graphical.target After=network-online.target graphical.target
Wants=network-online.target
Conflicts=rescue.target Conflicts=rescue.target
AllowIsolate=yes AllowIsolate=yes

View File

@ -76,7 +76,6 @@ post_makeinstall_target() {
mkdir -p $INSTALL/usr/bin mkdir -p $INSTALL/usr/bin
cp -P client/connmanctl $INSTALL/usr/bin cp -P client/connmanctl $INSTALL/usr/bin
cp -P $PKG_DIR/scripts/cm-online $INSTALL/usr/bin
mkdir -p $INSTALL/usr/lib/connman mkdir -p $INSTALL/usr/lib/connman
cp -P $PKG_DIR/scripts/connman-setup $INSTALL/usr/lib/connman cp -P $PKG_DIR/scripts/connman-setup $INSTALL/usr/lib/connman

View File

@ -1,29 +0,0 @@
#!/bin/sh
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
#
# OpenELEC 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, either version 2 of the License, or
# (at your option) any later version.
#
# OpenELEC 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 OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
# Wait for the network to come up and exit after timeout or if network is online
# default 30sec
[ ! -z $1 ] && TIMEOUT=$1 || TIMEOUT=30
for i in $(seq 1 $TIMEOUT) ; do
STATUS=$(ifconfig | sed -e '/inet addr:/!d' -e '/127.0.0.1/d' |wc -l)
[ "$STATUS" -gt 0 ] && break
usleep 1000000
done

View File

@ -1,8 +1,9 @@
[Unit] [Unit]
Description=Connection service Description=Connection service
Requires=dbus.socket DefaultDependencies=false
After=dbus.socket Conflicts=shutdown.target
Before=network.target Before=network.target multi-user.target shutdown.target
After=dbus.service
Wants=network.target Wants=network.target
[Service] [Service]
@ -15,8 +16,6 @@ ExecStartPre=-/bin/sh -c "cat /storage/.cache/hostname > /proc/sys/kernel/hostna
ExecStartPre=-/bin/sh -c "cat /storage/.config/hosts.conf > /etc/hosts" ExecStartPre=-/bin/sh -c "cat /storage/.config/hosts.conf > /etc/hosts"
ExecStartPre=/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up ExecStartPre=/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up
ExecStart=/bin/sh -c ". /usr/lib/connman/connman-setup; exec /usr/sbin/connmand -nr $CONNMAN_MAIN $CONNMAN_DEBUG" ExecStart=/bin/sh -c ". /usr/lib/connman/connman-setup; exec /usr/sbin/connmand -nr $CONNMAN_MAIN $CONNMAN_DEBUG"
# send SIGKILL on stop to keep ip configuration
KillSignal=SIGKILL
StandardOutput=null StandardOutput=null
RestartSec=2 RestartSec=2
StartLimitInterval=0 StartLimitInterval=0

View File

@ -1,13 +1,17 @@
[Unit] [Unit]
Description=Connection Manager Wait Online Description=Wait for network to be configured by ConnMan
Requisite=connman.service Requisite=connman.service
After=connman.service After=connman.service
Before=network-online.target
DefaultDependencies=no
Conflicts=shutdown.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStartPre=/bin/sh -c 'echo "waiting on Network to come online ..."' ExecStartPre=/bin/sh -c 'echo "waiting on Network to come online ..."'
ExecStart=/usr/bin/cm-online 30 ExecStart=/usr/sbin/connmand-wait-online --timeout=30
StandardOutput=tty StandardOutput=tty
RemainAfterExit=yes
[Install] [Install]
WantedBy=multi-user.target WantedBy=network-online.target