{"action":"created","issue":{"url":"https://api.github.com/repos/ptpd/ptpd/issues/44","repository_url":"https://api.github.com/repos/ptpd/ptpd","labels_url":"https://api.github.com/repos/ptpd/ptpd/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/ptpd/ptpd/issues/44/comments","events_url":"https://api.github.com/repos/ptpd/ptpd/issues/44/events","html_url":"https://github.com/ptpd/ptpd/issues/44","id":301826089,"number":44,"title":"PTPDv2 startup failed because interface eth0 has no IPv4 address set","user":{"login":"lalten","id":11611719,"avatar_url":"https://avatars3.githubusercontent.com/u/11611719?v=4","gravatar_id":"","url":"https://api.github.com/users/lalten","html_url":"https://github.com/lalten","followers_url":"https://api.github.com/users/lalten/followers","following_url":"https://api.github.com/users/lalten/following{/other_user}","gists_url":"https://api.github.com/users/lalten/gists{/gist_id}","starred_url":"https://api.github.com/users/lalten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lalten/subscriptions","organizations_url":"https://api.github.com/users/lalten/orgs","repos_url":"https://api.github.com/users/lalten/repos","events_url":"https://api.github.com/users/lalten/events{/privacy}","received_events_url":"https://api.github.com/users/lalten/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-02T16:31:55Z","updated_at":"2018-04-10T11:43:21Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI want to start a ptp daemon on system start. I set `/etc/default/ptpd` to:\r\n\r\n    # /etc/default/ptpd\r\n    \r\n    # Set to \"yes\" to actually start ptpd automatically\r\n    START_DAEMON=yes\r\n    \r\n    # Add command line options for ptpd\r\n    PTPD_OPTS=\" -i eth0 -M\"\r\n\r\nAfter a reboot, `service ptpd status` tells me\r\n\r\n    ● ptpd.service - LSB: start and stop ptpd\r\n       Loaded: loaded (/etc/init.d/ptpd; bad; vendor preset: enabled)\r\n       Active: active (exited) since Fri 2018-03-02 15:03:21 UTC; 5min ago\r\n         Docs: man:systemd-sysv-generator(8)\r\n      Process: 960 ExecStart=/etc/init.d/ptpd start (code=exited, status=0/SUCCESS)\r\n    \r\n    Mar 02 15:03:20 tegra-ubuntu-1 systemd[1]: Starting LSB: start and stop ptpd...\r\n    Mar 02 15:03:21 tegra-ubuntu-1 ptpd2[1007]: PTPDv2 version 2.3.1 starting\r\n    Mar 02 15:03:21 tegra-ubuntu-1 ptpd2[1007]: Starting ptpd2 daemon with parameters:      /usr/sbin/ptpd -i eth0 -M\r\n    Mar 02 15:03:21 tegra-ubuntu-1 ptpd2[1007]: Checking configuration\r\n    Mar 02 15:03:21 tegra-ubuntu-1 ptpd2[1007]: Configuration OK\r\n    Mar 02 15:03:21 tegra-ubuntu-1 ptpd[960]: Interface eth0 has no IPv4 address set\r\n    Mar 02 15:03:21 tegra-ubuntu-1 ptpd[960]: Error: Cannot use eth0 interface\r\n    Mar 02 15:03:21 tegra-ubuntu-1 ptpd[960]: PTPDv2 startup failed\r\n    Mar 02 15:03:21 tegra-ubuntu-1 systemd[1]: Started LSB: start and stop ptpd.\r\n\r\neth0 uses DHCP so I guess it did not immediately have an IP.\r\n\r\nThis is on Ubuntu 16.04.\r\n\r\nWhat can I do to make this work? Can I have the ptpd wait for eth0 to be ready?"},"comment":{"url":"https://api.github.com/repos/ptpd/ptpd/issues/comments/380069337","html_url":"https://github.com/ptpd/ptpd/issues/44#issuecomment-380069337","issue_url":"https://api.github.com/repos/ptpd/ptpd/issues/44","id":380069337,"user":{"login":"Nathilion","id":1639851,"avatar_url":"https://avatars2.githubusercontent.com/u/1639851?v=4","gravatar_id":"","url":"https://api.github.com/users/Nathilion","html_url":"https://github.com/Nathilion","followers_url":"https://api.github.com/users/Nathilion/followers","following_url":"https://api.github.com/users/Nathilion/following{/other_user}","gists_url":"https://api.github.com/users/Nathilion/gists{/gist_id}","starred_url":"https://api.github.com/users/Nathilion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nathilion/subscriptions","organizations_url":"https://api.github.com/users/Nathilion/orgs","repos_url":"https://api.github.com/users/Nathilion/repos","events_url":"https://api.github.com/users/Nathilion/events{/privacy}","received_events_url":"https://api.github.com/users/Nathilion/received_events","type":"User","site_admin":false},"created_at":"2018-04-10T11:43:21Z","updated_at":"2018-04-10T11:43:21Z","author_association":"NONE","body":"I had a similar issue. I have to wait for a link-local IP address to be assigned to either of the two available interfaces in my computer (we're developing a product which is as idiot proof as possible when it comes to plugging in cables). So, I have to figure out which interface contains the link-local interface. For that I have written a short init script that waits for the proper IP and then starts ptpd2 on the interface that has it. I'll post it here for inspiration and, for example, you could change it so that you detect for the presence of any IP rather than a specific link-local IP range.\r\n\r\nDisclaimer: I repressed what I had to with sed to filter out the interface name. So don't ask me what it does or how it works. :-P You won't need it anyhow as you already know the interface.\r\n\r\n```\r\n#!/bin/sh -e\r\n### BEGIN INIT INFO\r\n# Provides:          scriptname\r\n# Required-Start:    $remote_fs $syslog networking\r\n# Required-Stop:     $remote_fs $syslog\r\n# Default-Start:     2 3 4 5\r\n# Default-Stop:      0 1 6\r\n# Short-Description: Starts ptpd2 on a link-local interface.\r\n# Description:       First waits for a link-local interface to appear and then starts ptpd2 on it.\r\n### END INIT INFO\r\n#\r\n# First grant the script execution rights. Then copy this file to /etc/init.d and then run the following command to install the script:\r\n# sudo update-rc.d ptpd2 start 98 2 3 4 5 . stop 2 0 1 6 .\r\n\r\ncase $1 in\r\n  start)\r\n    a=$( ip addr show to 169.254.0.0/16 | wc -l )\r\n    until [ \"$a\" -gt 0 ]\r\n    do\r\n      a=$( ip addr show to 169.254.0.0/16 | wc -l )\r\n      echo Sleeping\r\n      sleep 1\r\n    done\r\n    #What it does:\r\n    #print all address of ipv4 interfaces | filter out the link-local address(es) | substitute all the remaining information except for the ': if-name ' part. | strip the leading ': ' and trailing ' '.\r\n    #Lastly, the $(...) is called 'command substution' which in this case dumps the output into the variable IF_NAME.\r\n    IF_NAME=$(ip -o -4 addr | grep -e 169.\\254 | sed -n 's/.*\\(: [a-zA-Z0-9]* \\).*/\\1/ p' | sed -n 's/: \\([a-zA-Z0-9]*\\) /\\1/ p')\r\n    /usr/local/sbin/ptpd2 --config-file /etc/ptpd2.conf -i ${IF_NAME}\r\n    #After 75 seconds force all slaves to step to the offset received from the master.\r\n    (sleep 75; killall -s SIGUSR1 ptpd2) &\r\n    ;;\r\n  stop)\r\n    killall ptpd2\r\n    ;;\r\n  *)\r\n   echo \"Usage: {start|stop}\"\r\n    ;;\r\nesac\r\n\r\n```"}}
{"actor":{"display_login":"Nathilion"}}