From 3b87b1b8f4592461e058f9eafc4c95d920842f10 Mon Sep 17 00:00:00 2001 From: Tobias Mueller Date: Mon, 16 Oct 2023 16:57:42 +0200 Subject: [PATCH] web: offer to shutdown on SIM swap It currently times out when generating an IMEI. I wonder what the timeouts are. --- files/usr/libexec/blue-merle | 5 +++++ files/www/luci-static/resources/view/blue-merle.js | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/files/usr/libexec/blue-merle b/files/usr/libexec/blue-merle index a7e804c..c22f6af 100755 --- a/files/usr/libexec/blue-merle +++ b/files/usr/libexec/blue-merle @@ -30,6 +30,11 @@ elif [ "$1" == "random-imei" ]; then elif [ "$1" == "shutdown-modem" ]; then exec gl_modem AT AT+CFUN=4 +elif [ "$1" == "shutdown" ]; then + echo '{ "msg": "Shutdowing down..." }' > /dev/ttyS0 + halt -d 5 + echo -n "Shutting down" + elif [ "$1" == "write-imei" ]; then new_imei=$2 echo -n { "action": "write" } diff --git a/files/www/luci-static/resources/view/blue-merle.js b/files/www/luci-static/resources/view/blue-merle.js index bd93d33..57bf341 100644 --- a/files/www/luci-static/resources/view/blue-merle.js +++ b/files/www/luci-static/resources/view/blue-merle.js @@ -771,6 +771,11 @@ function handleConfig(ev) }); } +function handleShutdown(ev) +{ + return callBlueMerle("shutdown") +} + function handleRemove(ev) { var name = ev.target.getAttribute('data-package'), @@ -849,10 +854,16 @@ function handleSimSwap(ev) { ), E('p', { 'class': 'text'}, _("Please shutdown the device and go to another place before booting") - ) + ), + E('button', { 'class': 'btn cbi-button-positive', 'click': handleShutdown, 'disabled': isReadonlyView }, [ _('Shutdown…') ]), ' ', } ).catch( function(err) { + dlg.appendChild( + E('p',{'class': 'error'}, + _('Error setting IMEI! ') + err + ) + ) } ); }