mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-06 23:55:56 +02:00
Correct entrypoint
This commit is contained in:
@@ -1,15 +1,44 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "Starting"
|
echo "Starting..."
|
||||||
|
|
||||||
if [ ! -f /data/config.json ]; then
|
###################################
|
||||||
echo "building userdir"
|
# Export all addon options as env #
|
||||||
freqtrade create-userdir --userdir /data
|
###################################
|
||||||
echo "building initial config"
|
|
||||||
freqtrade new-config --config /data/config.json
|
# For all keys in options.json
|
||||||
|
JSONSOURCE="/data/options.json"
|
||||||
|
|
||||||
|
# Export keys as env variables
|
||||||
|
echo "All addon options were exported as variables"
|
||||||
|
mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE})
|
||||||
|
for KEYS in ${arr[@]}; do
|
||||||
|
# export key
|
||||||
|
VALUE=$(jq .$KEYS ${JSONSOURCE})
|
||||||
|
export ${KEYS}=${VALUE//[\"\']/} &>/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
################
|
||||||
|
# Set timezone #
|
||||||
|
################
|
||||||
|
if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then
|
||||||
|
if [ -f /usr/share/zoneinfo/$TZ ]; then
|
||||||
|
echo "Timezone set from $(cat /etc/timezone) to $TZ"
|
||||||
|
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
|
||||||
|
else
|
||||||
|
echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pause 36000000000
|
####################
|
||||||
|
# Starting scripts #
|
||||||
|
####################
|
||||||
|
|
||||||
echo "Starting app"
|
for SCRIPTS in scripts/*; do
|
||||||
freqtrade trade --logfile /data/logs/freqtrade.log --db-url sqlite://///data/tradesv3.sqlite --config /data/config.json --strategy SampleStrategy
|
[ -e "$SCRIPTS" ] || continue
|
||||||
|
echo "$SCRIPTS: executing"
|
||||||
|
chown $(id -u):$(id -g) $SCRIPTS
|
||||||
|
chmod a+x $SCRIPTS
|
||||||
|
sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS || true
|
||||||
|
./$SCRIPTS || echo "$SCRIPTS: exiting $?"
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user