-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connman): introduce connman support module
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
- Loading branch information
Showing
7 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
|
||
type cm_generate_connections > /dev/null 2>&1 || . /lib/cm-lib.sh | ||
|
||
if [ -n "$netroot" ] || [ -e /tmp/net.ifaces ]; then | ||
echo rd.neednet >> /etc/cmdline.d/connman.conf | ||
fi | ||
|
||
if getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then | ||
if [ -n "$DRACUT_SYSTEMD" ]; then | ||
# Enable tty output if a usable console is found | ||
# shellcheck disable=SC2217 | ||
if [ -w /dev/console ] && (echo < /dev/console) > /dev/null 2> /dev/null; then | ||
mkdir -p /run/systemd/system/cm-initrd.service.d | ||
cat << EOF > /run/systemd/system/cm-initrd.service.d/tty-output.conf | ||
[Service] | ||
StandardOutput=tty | ||
EOF | ||
systemctl --no-block daemon-reload | ||
fi | ||
fi | ||
fi | ||
|
||
cm_generate_connections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
Wants=systemd-udev-trigger.service | ||
After=systemd-udev-trigger.service | ||
After=dracut-cmdline.service | ||
Wants=network.target | ||
Before=network.target | ||
RequiresMountsFor=/var/lib/connman | ||
After=dbus.service | ||
ConditionPathExists=/run/connman/initrd/neednet | ||
|
||
[Service] | ||
Type=dbus | ||
BusName=net.connman | ||
Restart=on-failure | ||
ExecStart=/usr/sbin/connmand -n | ||
StandardOutput=null | ||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_ADMIN | ||
ProtectHome=true | ||
ProtectSystem=full | ||
|
||
[Install] | ||
WantedBy=initrd.target | ||
Also=cm-wait-online-initrd.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
type getcmdline > /dev/null 2>&1 || . /lib/dracut-lib.sh | ||
|
||
cm_generate_connections() { | ||
if getargbool 0 rd.neednet; then | ||
mkdir -p "$hookdir"/initqueue/finished | ||
echo '[ -f /tmp/cm.done ]' > "$hookdir"/initqueue/finished/cm.sh | ||
mkdir -p /run/connman/initrd | ||
: > /run/connman/initrd/neednet # activate ConnMan services | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
type source_hook > /dev/null 2>&1 || . /lib/dracut-lib.sh | ||
|
||
if [ -e /tmp/cm.done ]; then | ||
return | ||
fi | ||
|
||
while read -r _serv; do | ||
ifname=$(connmanctl services "$_serv" | grep Interface= | sed 's/^.*Interface=\([^,]*\).*$/\1/') | ||
source_hook initqueue/online "$ifname" | ||
/sbin/netroot "$ifname" | ||
done < <(connmanctl services | grep -oE '[^ ]+$') | ||
|
||
: > /tmp/cm.done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
Requires=cm-initrd.service | ||
After=cm-initrd.service | ||
Before=network-online.target | ||
Before=dracut-initqueue.service | ||
ConditionPathExists=/run/connman/initrd/neednet | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/sbin/connmand-wait-online | ||
RemainAfterExit=yes | ||
|
||
[Install] | ||
WantedBy=initrd.target | ||
WantedBy=network-online.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
# called by dracut | ||
check() { | ||
require_binaries sed grep connmand connmanctl connmand-wait-online || return 1 | ||
|
||
# do not add this module by default | ||
return 255 | ||
} | ||
|
||
# called by dracut | ||
depends() { | ||
echo dbus systemd bash | ||
return 0 | ||
} | ||
|
||
# called by dracut | ||
installkernel() { | ||
return 0 | ||
} | ||
|
||
# called by dracut | ||
install() { | ||
# We don't need `ip` but having it is *really* useful for people debugging | ||
# in an emergency shell. | ||
inst_multiple ip sed grep | ||
|
||
inst connmand | ||
inst connmanctl | ||
inst connmand-wait-online | ||
inst "$dbussystem"/connman.conf | ||
[[ $hostonly ]] && [[ -f $dracutsysrootdir/etc/connman/main.conf ]] && inst /etc/connman/main.conf | ||
inst_dir /usr/lib/connman/plugins | ||
inst_dir /var/lib/connman | ||
|
||
inst_hook cmdline 99 "$moddir/cm-config.sh" | ||
|
||
inst_simple "$moddir"/cm-initrd.service "$systemdsystemunitdir"/cm-initrd.service | ||
inst_simple "$moddir"/cm-wait-online-initrd.service "$systemdsystemunitdir"/cm-wait-online-initrd.service | ||
|
||
$SYSTEMCTL -q --root "$initdir" enable cm-initrd.service | ||
|
||
inst_hook initqueue/settled 99 "$moddir/cm-run.sh" | ||
|
||
inst_simple "$moddir/cm-lib.sh" "/lib/cm-lib.sh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters