mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-02-05 03:14:54 +01:00
Dev version
This commit is contained in:
41
enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh
Normal file
41
enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
###################################
|
||||
# Export all addon options as env #
|
||||
###################################
|
||||
|
||||
# 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
|
||||
|
||||
############
|
||||
# Set user #
|
||||
############
|
||||
|
||||
if [ ! -z "PUID" ] && [ ! -z "GUID" ]; then
|
||||
echo "Custom user defined : $PUID:$GUID"
|
||||
PUID=${PUID:-911}
|
||||
PGID=${PGID:-911}
|
||||
groupmod -o -g "$PGID" abc
|
||||
usermod -o -u "$PUID" abc
|
||||
fi
|
||||
Reference in New Issue
Block a user