Автообновление прошивки¶
Рекомендуемый вариант - средствами JavaScript.¶
- Скрипт на странице сервера index.html - во время открытия портала, если на сервер загружен новый образ (запрос единожды при открытии портала).
- С помощью функции stbOnLoadJS - получение через установленный интервал времени инструкций по сети в фоновом режиме (множество запросов).
- С помощью средств *inux - shell скрипты с/или использование(м) других иснтрументов.
- Передача параметров приставке: адрес портала, сервер времени, часовой пояс.
По умолчанию портал прописанный с завода wrtech.local.
http://wrtech.local - не существующий домен, провайдер может перенаправлять.
Примеры:¶
Все js скрипты размещаются на странице index.html
1. Скрипт на странице сервера.
http://test.wrtech.ru/checkupdate.js
if(typeof(gSTB) == "object" && typeof(WRT) == "object" && typeof(stbUpdate) == "object" && location.search.indexOf("skipupdate") == -1) { var imagePath = gSTB.RDir("update_url"); var curDate = WRT.GetSoftwareDate(); stbUpdate.startCheck(imagePath); console.log("imagePath is " + imagePath); console.log("curDate is " + curDate); console.log("getStatus is " + stbUpdate.getStatus()); if(stbUpdate.getStatus() == 21) { var imageDate = stbUpdate.getImageDateStr(); console.log("imageDate is " + imageDate); if(Date.parse(curDate) < Date.parse(imageDate)) { console.log("updating to " + imagePath); //stbUpdate.startAutoUpdate(imagePath, 0); WRT.UpdateGui(imagePath, location.origin + location.pathname + (location.search ? location.search + "&" : "?") + "skipupdate", true); } else { console.log("skip"); } } }
2. С помощью функции stbOnLoadJS
export stb_onload_js=' if (location.origin !== "file://" || location.origin + location.pathname === "file:///opt/minibrowser/services.html") { function wrtechUpdateJS() { var xhr = new XMLHttpRequest, url = "http://wrtech.local/update/js/?mac=" + WRT.GetMacAddress() + "&r=" + Math.random(); xhr.open("GET", url, !0), xhr.onreadystatechange = function() { if (4 == xhr.readyState) { if (xhr.status >= 200 && xhr.status < 300) try { eval(xhr.responseText) } catch (t) { console.log("wrtechUpdateJS error on eval") } else console.log("wrtechUpdateJS error: " + xhr.status); setTimeout(wrtechUpdateJS, "undefined" != typeof wrtechUpdateJSTimeout && wrtechUpdateJSTimeout > 0 && wrtechUpdateJSTimeout < 36e5 ? wrtechUpdateJSTimeout : 6e5) } }, xhr.timeout = 2e3, xhr.send("") } wrtechUpdateJS() }'
3. Не было случайев применения, т.к. провайдеры используют возможности js.
4. Настройка адреса портала, сервера времени, часового пояса.¶
Пример страницы настройки:¶
var update_url = 'http://support.wrtech.ru/update/WR-330/wrt/imageupdate', bootstrap_url = 'http://support.wrtech.ru/update/WR-330/wrt/imageupdate_bootstrap', portal1 = 'http://portal.ru', timezone = 'Asia/Yekaterinburg', ntp_url = 'pool.ntp.org'; if (WRT.getEnv('update_url') != update_url && WRT.getEnv('bootstrap_url') != bootstrap_url && WRT.getEnv('portal1') != portal1 && WRT.getEnv('TZ') != timezone && WRT.getEnv('ntpurl') != ntp_url) { WRT.setEnv('update_url', 'http://support.wrtech.ru/update/WR-330/wrt/imageupdate'); WRT.setEnv('bootstrap_url', 'http://support.wrtech.ru/update/WR-330/wrt/imageupdate_bootstrap'); WRT.setEnv('portal1', 'http://portal.ru'); WRT.setEnv('TZ', 'Asia/Yekaterinburg'); WRT.setEnv('ntpurl', 'pool.ntp.org'); }