#!/bin/sh

# temporary: please remove when ld.so.cache is used
export LD_LIBRARY_PATH="/opt/gira/lib"

GIRA_BIN="/opt/gira/bin"
MP_USERDATA="/opt/userdata"
USERDATA_FS_TYPE="ext3"
MP_CARD="/opt/card"
EXTPARAM="/opt/extparam"
DS_TEMPLATE_DIR="/opt/gira/etc/devicestack"
# This will fail for commissioning.
UD_BLOCKDEV=$(cat ${EXTPARAM}/userdata_root_blkdev)
# Needed for backward compatability?
FWU_DIR="/opt/fwu"
DEVCFG="${GIRA_BIN}/devcfg"

REBOOT="/sbin/reboot"
MOUNT="/bin/mount"
UMOUNT="/bin/umount"
RESOLV_CONF="/var/etc/resolv.conf"
SERVER_ID="/var/run/eth0_dhcp_serverid"
DEFAULT_HOSTNAME="im"
DHCP_SCRIPT="/etc/dhcp.script"
# This path needs to be the same as in /opt/gira/etc/devicestack/device.config
NETCFGSTATE="/var/run/netcfg.state"
DS_PIDFILE="/var/run/devicestack.pid"
# This path needs to correspond with the setting from devicestackconfig.xml.
# Else the DS_LOGFILE will not be covered by the logrotation and thus fill /var/log/.
# Regrettably this is not true! The filehandle itself is not covered by logrotation.
DS_LOGFILE="/var/log/devicestack"
ETH0_SERVERID_FILE="/var/run/eth0_dhcp_serverid"

UD_MOUNTED_FILE="${MP_USERDATA}/.mounted"
UD_FWU_DIR="${MP_USERDATA}/fwu"
FACTORY_RESET="${GIRA_BIN}/factory-reset"
CONFIGURATION_RESET="${GIRA_BIN}/configuration-reset"
CHK_FACTRSTCOND_TOOL="${GIRA_BIN}/chkfactrst"
GDS_REBOOT="${GIRA_BIN}/gds-reboot.sh"
DEVICESTACK="${GIRA_BIN}/devicestack"
IPC_SEND="${GIRA_BIN}/ipc-send"
NOCARD_FILE="${MP_CARD}/.nocard"

DS_ETC_USERDATA="${MP_USERDATA}/devicestack"
NETLOG="${MP_USERDATA}/net.log"

ENVIRONMENT_SYNC_SCRIPT="${GIRA_BIN}/gds-ubootenv-sync.sh"
SYSTEM_A_BOOTCOUNTER_FILE="${EXTPARAM}/system_A_boot_counter"
SYSTEM_B_BOOTCOUNTER_FILE="${EXTPARAM}/system_B_boot_counter"
BOOTED_SYSTEM_FILE="/var/run/booted_system"
BOOTSYSTEM_FILE="${EXTPARAM}/bootsystem"
MACADDRESS_FILE="${EXTPARAM}/mac_address_0"
FACTORY_RESET_FILE="${EXTPARAM}/factory_reset_condition"
EMERGENCY_FACTORY_RESET_FILE="${MP_CARD}/factory_reset_condition"
CONFIGURATION_RESET_FILE="${EXTPARAM}/configuration_reset_condition"
DEVICE_USER_DIR="${DS_ETC_USERDATA}/users"
DEFAULT_DEVICE_USER_FILE="${DEVICE_USER_DIR}/device"
COMMISSIONED_FILE="${EXTPARAM}/.commissioned"
DUMMY_WATCHDOGFILE="${MP_USERDATA}/.dummy-watchdog-enabled"
OPENVPN_CONFIG_DIR="${MP_USERDATA}/openvpn"
OPENVPN_BRIDGE_CONFIG="${OPENVPN_CONFIG_DIR}/bridge.config"
OPENVPN_ENABLED_FILE="${MP_USERDATA}/.openvpn-enabled"

DS_MANUFACTURER_FILE="${DS_TEMPLATE_DIR}/manufacturer"
DS_MODEL_FILE="${DS_TEMPLATE_DIR}/model"
DS_DEVNAME_FILE="${DS_TEMPLATE_DIR}/device_name"
DS_FWVERSION_FILE="${DS_TEMPLATE_DIR}/firmware_version"
DS_MODULEID_FILE="${DS_TEMPLATE_DIR}/module_id"

### CONFIGURATION FILES WITH TEMPLATES ########################################
NETWORK_CFG_FILE="${DS_ETC_USERDATA}/network.conf"
NETWORK_CFG_FILE_TEMPLATE="${DS_TEMPLATE_DIR}/network.conf.template"
APPCONFIG_FILE="${DS_ETC_USERDATA}/appconfig.xml"
APPCONFIG_FILE_TEMPLATE="${DS_TEMPLATE_DIR}/appconfig.xml.template"
DSCONFIG_FILE="${DS_ETC_USERDATA}/devicestackconfig.xml"
DSCONFIG_FILE_TEMPLATE="${DS_TEMPLATE_DIR}/devicestackconfig.xml.template"
COSTOM_CHANNEL_DIR="${DS_ETC_USERDATA}/definitions/"
COSTOM_CHANNEL_DIR_TEMPLATE="${DS_TEMPLATE_DIR}/definitions.template"
SHADOW_TEMPLATE="${DS_TEMPLATE_DIR}/shadow.template"
SHADOW_USER_TEMPLATE="${MP_USERDATA}/devicestack/shadow.template"
CUSTOM_PROJECT_DEFINITION_DIR="${DS_ETC_USERDATA}/devicedefinition"
CUSTOM_PROJECT_DEFINITION_DIR_TEMPLATE="${DS_TEMPLATE_DIR}/devicedefinition.template"
CONNMAN_CONFIG_DIR="${MP_USERDATA}/connman"
CONNMAN_TEMPLATE_DIR="${DS_TEMPLATE_DIR}/connman.templates"
OPENVPN_TEMPLATE_DIR="${DS_TEMPLATE_DIR}/openvpn.template"
