Skip to content

Commit d30318d

Browse files
committed
handle https-enabled ui during migration
1 parent 1b408e2 commit d30318d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

deb/debian/preinst

+12-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@ if [ "$1" = "install" ]; then
3131
payload=$(echo -n '{"username":"homebridge-apt-pkg","name":"homebridge-apt-pkg","admin":true,"instanceId":"xxxxxxxx"}' | openssl base64 -e -A | sed s/\+/-/g | sed -E s/=+$// | sed 's/\//_/g')
3232
signature=$(echo -n "${header}.${payload}"| openssl dgst -sha256 -hmac $secret -binary | openssl base64 -e -A | sed s/\+/-/g | sed -E s/=+$// | sed 's/\//_/g')
3333
token="${header}.${payload}.${signature}"
34+
3435
# get the list of installed plugins from the running instance of the Homebridge UI
35-
output=$(curl -sfk -H "Authorization: bearer ${token}" http://localhost:${ui_port}/api/plugins 2> /dev/null)
36-
if [ "$?" = "0" ]; then
36+
output=""
37+
getPluginStatus="fail"
38+
for protocol in "http" "https"; do
39+
output=$(curl -sfk -H "Authorization: bearer ${token}" $protocol://localhost:${ui_port}/api/plugins 2> /dev/null)
40+
if [ "$?" = "0" ]; then
41+
getPluginStatus="success"
42+
break
43+
fi
44+
done
45+
46+
if [ "$getPluginStatus" = "success" ]; then
3747
# build a package.json like format containing the list of plugins the user has installed
3848
dependencies=$(echo $output | jq -rM '. | map({(.name) : .installedVersion }) | add | del(."homebridge-config-ui-x") | del(."homebridge")')
3949
packageJson=$(jq ".dependencies += $dependencies" <<< '{ "dependencies": {} }')

0 commit comments

Comments
 (0)