Hotplug Information
From SynCE-Wiki
Contents |
Debian
Note: This information is for Debian GNU/Linux and Ubuntu.
Since Windows Mobile 2005 devices connect to Linux PCs using the usb-rndis driver and are handled through the normal networking subsystem, it is possible to leverage the ifup/ifdown mechanism to automatically connect to the phone for sync.
First and foremost, follow the directions in Building SynCE with Windows Mobile 2005 support from Subversion to establish that you are able to connect to your device via USB. After the initial connection is established, you will want to make an entry in /etc/network/interfaces for your phone. On my system, the phone comes up on eth2 (this can be verified in dmesg), so I inserted the following to my interfaces file:
auto eth2 iface eth2 inet dhcp post-up /etc/network/if-up.d/phone-add down /etc/network/if-down.d/phone-remove
The post-up and down directives instruct the operating system to run the scripts specified when the device is plugged in and has its interface up and after it has been removed, respectively. As expected, these scripts will need to be owned by root and chmod +x to function. Now, let's have a look.
/etc/network/if-up.d/phone-add:
#!/bin/sh start-stop-daemon --start --background --make-pidfile --pidfile /var/run/vdccm.pid --chuid user:user --exec /usr/local/bin/vdccm -- -f -s 40 triggerconnection 169.254.2.1
Be sure to replace "user:user" with your uid and gid! This is necessary to prevent vdccm from running with root privileges.
/etc/network/if-down.d/phone-remove:
#!/bin/sh start-stop-daemon --stop --pidfile /var/run/vdccm.pid
In the phone-add script, we use Debian's start-stop-daemon to launch vdccm using the default keepalive settings and then trigger the connection using the default device IP address.
In the phone-remove script, we simply call to start-stop-daemon again to clean up the vdccm process.
Gentoo
When plugging in your phone under latest Gentoo (with baselayout 1.12.9), udev will try to automatically call
/etc/init.d/net.<your-net-iface> start
In order to let Gentoo setup your phone now, you have to adjust the following files:
/etc/init.d/net.eth1
Create a symlink for your interface (in my case eth1) to net.lo
cd /etc/init.d ln -s net.lo net.eth1
/etc/conf.d/net
Add a new module into the network configuration:
modules=( "dhclient" ) config_eth1=( "dhcp" "triggerconnection" ) modules_eth1=( "dhclient") modules_eth1=( "triggerconnection" ) dhclient_eth1=" "
triggerconnection module
I've written a module called triggerconnection, which will automatically trigger the connection to your phone right after 'dhcp' was successful. You have to add the following into /lib/rcscripts/net/triggerconnection.sh
# Trigger connection with PDA
# Module for Gentoo Baselayout 1.12.9
# Send comments to Marcel Selhorst <synce@selhorst.net>
triggerconnection_depend() {
after dhcp
provide triggerconnection
}
triggerconnection_start() {
local iface="$1"
einfo "Triggerconnection module, checking interface ${iface}"
INTERFACE_IP="$(/sbin/ifconfig ${iface} | grep inet | sed 's/.*:\(.*.*\) .*/\1/' | cut -d'.' -f1-3)"
INTERFACE_IP="${INTERFACE_IP}.1"
einfo "Triggering connection on IP $INTERFACE_IP"
/usr/local/bin/triggerconnection $INTERFACE_IP
return $?
}
triggerconnection_stop() {
return 0
}
triggerconnection_check_installed() {
[[ -x /usr/local/bin/triggerconnection ]] && return 0
${1:-false} && eerror "Please install 'triggerconnection' first! See SynCE-Wiki!"
return 1
}
# vim: set ts=4 :
Note: Make sure, to adjust the path to your triggerconnection-binary in the above sourcecode.
