source: trunk/package/comgt/files/3g.usb @ 26816

Last change on this file since 26816 was 26816, checked in by jow, 6 years ago

[package] comgt: add tty hotplug remove handling, only iterate each tty once (#9211)

File size: 791 bytes
Line 
1#!/bin/sh
2
3. /etc/functions.sh
4
5log() {
6        logger -t 3g-hotplug "$@"
7}
8
9find_3g_iface() {
10        local cfg="$1"
11        local tty="$2"
12
13        local proto
14        config_get proto "$cfg" proto
15        [ "$proto" = 3g ] || return 0
16
17        local auto
18        config_get_bool auto "$cfg" auto 1
19        [ "$auto" = 1 ] || [ "$ACTION" = remove ] || return 0
20
21        local dev
22        config_get dev "$cfg" device
23
24        if [ "${dev##*/}" = "${tty##*/}" ]; then
25                if [ "$ACTION" = add ]; then
26                        log "Starting interface $cfg for device ${dev##*/}"
27                        ( sleep 1; /sbin/ifup "$cfg" ) &
28                else
29                        log "Stopping interface $cfg for device ${dev##*/}"
30                        /sbin/ifdown "$cfg" &
31                fi
32        fi
33}
34
35case "$DEVICENAME" in
36        tty*)
37                [ -e "/dev/$DEVICENAME" ] || [ "$ACTION" = remove ] || exit 0
38                config_load network
39                config_foreach find_3g_iface interface "/dev/$DEVICENAME"
40        ;;
41esac
42
Note: See TracBrowser for help on using the repository browser.