@iobroker/create-adapter
Version:
Command line utility to create customized ioBroker adapters
46 lines (39 loc) • 1.08 kB
JavaScript
"use strict";
const templateFunction = answers => {
const devcontainer = answers.tools && answers.tools.includes("devcontainer");
if (!devcontainer) {
return;
}
const template = `
#!/bin/bash
set -e
# Start tailing the iobroker boot log and kill it when the script exits
tail -f -n 100 /opt/iobroker/log/boot.log &
TAIL_PID_BOOT=$!
# Ensure the tail process is killed when the script exits
trap "kill $TAIL_PID_BOOT" EXIT
# wait for ioBroker to become ready
echo "⏳ Waiting for ioBroker to become ready..."
ATTEMPTS=20
SLEEP=0.5
i=1
while [ $i -le $ATTEMPTS ]; do
if iob status > /dev/null 2>&1; then
echo "✅ ioBroker is ready."
break
else
echo "⌛ Attempt $i/$ATTEMPTS: Waiting for ioBroker..."
sleep $SLEEP
i=$((i + 1))
fi
done
if ! iob status > /dev/null 2>&1; then
echo "❌ Timeout: ioBroker did not become ready in time"
exit 1
fi
`;
return template.trim();
};
templateFunction.customPath = ".devcontainer/scripts/wait_for_iobroker.sh";
module.exports = templateFunction;
//# sourceMappingURL=wait_for_iobroker.sh.js.map