Я использую инструмент vdirsyncer (http://vdirsyncer.pimutils.org/en/stable/index.html) для создания локальной копии моего календаря iCloud, который я использую для его отображения на зеркале magi c. Сам инструмент имеет функцию таймера, которая периодически запускает syn c, но, к сожалению, у меня это не работает. Чтобы обойти это, я создал простой сценарий bash, который хотел запустить как cronjob. Вот один лайнер, вызывающий syn c:
vdirsyncer -vdebug sync
Выполнение вручную через
bash vdirsyncer.sh
отлично работает и доставляет ожидаемый результат.
Crontab выглядит так:
*/15 * * * * bash ~/MagicMirror/modules/calendars/vdirsyncer.sh >> ~/vdirsyncer.log 2>&1
Ниже приведены журналы отладки для руководства и cron.
Руководство:
debug: Using 1 maximal workers.
Syncing iCloud_to_MagicMirror/9*******-****-****-****-**********D
debug: REPORT https://p65-caldav.icloud.com:443/1*******4/calendars/9*******-****-****-****-**********D/
debug: {'User-Agent': 'vdirsyncer/0.16.8', 'Content-Type': 'application/xml; charset=UTF-8', 'Depth': '1'}
debug: b'
<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query
xmlns:D="DAV:"\n
xmlns:C="urn:ietf:params:xml:ns:caldav">
<D:prop>
<D:getcontenttype/>
<D:getetag/>
</D:prop>
<C:filter>
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VEVENT">
<C:time-range start="20200801T105958Z" end="20201001T105958Z"/>
</C:comp-filter>
</C:comp-filter>
</C:filter>
</C:calendar-query>'
debug: Sending request...
debug: 207
debug: {'Server': 'AppleHttpServer/ac9d40131a4d', 'Date': 'Sun, 02 Aug 2020 08:59:58 GMT', 'Content-Type': 'application/xml; charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'X-Apple-Jingle-Correlation-Key': 'FXI2LQV3QFDP3GEPT33CIYZ5HI', 'apple-seq': '0', 'apple-tk': 'false', 'Apple-Originating-System': 'UnknownOriginatingSystem', 'X-Responding-Instance': 'caldavj:46501501:pv48p65ic-ztfb04061901:8501:2013B458:d8e23d82555b', 'X-Apple-API-Version': 'v1', 'content-encoding': 'gzip', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains;', 'via': 'xrail:pv43p00ic-zteu05011101.me.com:8301:19C624:grp40,631194250daa17e24277dea86cf30319:2cff26743aa83c8b9b48ffef19d10f1f:Dusseldorf', 'X-Apple-Request-UUID': '2dd1a5c2-bb81-46fd-988f-9ef624633d3a', 'access-control-expose-headers': 'X-Apple-Request-UUID,Via'}
debug: b'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n
<multistatus
xmlns="DAV:">
<response>
<href>/1*******4/calendars/9*******-****-****-****-**********D/5*******-****-****-****-***********9.ics</href>
<propstat>
<prop>
<getcontenttype
xmlns="DAV:">text/calendar
</getcontenttype>
<getetag
xmlns="DAV:">"C=4613@U=c71884bd-5c39-471a-bb28-a66fe61fa144"
</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/1*******4/calendars/9*******-****-****-****-**********D/B*******-****-****-****-***********7.ics</href>
<propstat>
<prop>
<getcontenttype
xmlns="DAV:">text/calendar
</getcontenttype>
<getetag
xmlns="DAV:">"C=4605@U=c71884bd-5c39-471a-bb28-a66fe61fa144"
</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/1*******4/calendars/9*******-****-****-****-**********D/A*******-****-****-****-***********2.ics</href>
<propstat>
<prop>
<getcontenttype
xmlns="DAV:">text/calendar
</getcontenttype>
<getetag
xmlns="DAV:">"C=4622@U=c71884bd-5c39-471a-bb28-a66fe61fa144"
</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/1*******4/calendars/9*******-****-****-****-**********D/5*******-****-****-****-***********3.ics</href>
<propstat>
<prop>
<getcontenttype
xmlns="DAV:">text/calendar
</getcontenttype>
<getetag
xmlns="DAV:">"C=4618@U=c71884bd-5c39-471a-bb28-a66fe61fa144"
</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/1*******4/calendars/9*******-****-****-****-**********D/4*******-****-****-****-***********B.ics</href>
<propstat>
<prop>
<getcontenttype
xmlns="DAV:">text/calendar
</getcontenttype>
<getetag
xmlns="DAV:">"C=4630@U=c71884bd-5c39-471a-bb28-a66fe61fa144"
</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>\n
</multistatus>'
debug: Already normalized: '/1*******4/calendars/9*******-****-****-****-**********D/5*******-****-****-****-***********9.ics'
debug: Already normalized: '/1*******4/calendars/9*******-****-****-****-**********D/B*******-****-****-****-***********7.ics'
debug: Already normalized: '/1*******4/calendars/9*******-****-****-****-**********D/A*******-****-****-****-***********2.ics'
debug: Already normalized: '/1*******4/calendars/9*******-****-****-****-**********D/5*******-****-****-****-***********3.ics'
debug: Already normalized: '/1*******4/calendars/9*******-****-****-****-**********D/4*******-****-****-****-***********B.ics'
Cron:
Syncing iCloud_to_MagicMirror/9*******-****-****-****-***********D
error: Unknown error occured for iCloud_to_MagicMirror/9*******-****-****-****-***********D: HTTPSConnectionPool(host='p65-caldav.icloud.com', port=443): Max retries exceeded with url: /1********4/calendars/9*******-****-****-****-***********D/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
error: Use `-vdebug` to see the full traceback.
error: 1 out of 2 tasks failed.
debug: Using 1 maximal workers.
Syncing iCloud_to_MagicMirror/9*******-****-****-****-***********D
debug: REPORT https://p65-caldav.icloud.com:443/1********4/calendars/9*******-****-****-****-***********D/
debug: {'User-Agent': 'vdirsyncer/0.16.7', 'Content-Type': 'application/xml; charset=UTF-8', 'Depth': '1'}
debug: <?xml version="1.0" encoding="utf-8" ?>
debug: <C:calendar-query xmlns:D="DAV:"
debug: xmlns:C="urn:ietf:params:xml:ns:caldav">
debug: <D:prop>
debug: <D:getcontenttype/>
debug: <D:getetag/>
debug: </D:prop>
debug: <C:filter>
debug:
debug: <C:comp-filter name="VCALENDAR">
debug: <C:comp-filter name="VEVENT">
debug: <C:time-range start="20200801T104802Z" end="20201001T104802Z"/>
debug: </C:comp-filter>
debug: </C:comp-filter>
debug:
debug: </C:filter>
debug: </C:calendar-query>
debug: Sending request...
error: Unknown error occured for iCloud_to_MagicMirror/9*******-****-****-****-***********D: HTTPSConnectionPool(host='p65-caldav.icloud.com', port=443): Max retries exceeded with url: /1********4/calendars/9*******-****-****-****-***********D/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
error: Use `-vdebug` to see the full traceback.
debug: File "/usr/lib/python3/dist-packages/vdirsyncer/cli/tasks.py", line 69, in sync_collection
debug: partial_sync=pair.partial_sync
debug: File "/usr/lib/python3/dist-packages/vdirsyncer/sync/__init__.py", line 136, in sync
debug: b_nonempty = b_info.prepare_new_status()
debug: File "/usr/lib/python3/dist-packages/vdirsyncer/sync/__init__.py", line 45, in prepare_new_status
debug: for href, etag in self.storage.list():
debug: File "/usr/lib/python3/dist-packages/vdirsyncer/storage/dav.py", line 822, in list
debug: headers=headers)
debug: File "/usr/lib/python3/dist-packages/vdirsyncer/storage/dav.py", line 390, in request
debug: return http.request(method, url, session=self._session, **more)
debug: File "/usr/lib/python3/dist-packages/vdirsyncer/http.py", line 144, in request
debug: r = func(method, url, **kwargs)
debug: File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
debug: resp = self.send(prep, **send_kwargs)
debug: File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
debug: r = adapter.send(request, **kwargs)
debug: File "/usr/lib/python3/dist-packages/requests/adapters.py", line 514, in send
debug: raise SSLError(e, request=request)
error: 1 out of 2 tasks failed.
Я уже мог понять, что при ручном вызове скрипта используется User-Agent 0.16.8, а cronjob - 0.16.7. Кто-нибудь знает, что могло вызвать такое поведение?