Skip to content

Commit

Permalink
Update project folder variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
asherw committed Jul 13, 2020
1 parent 303e793 commit cd4b573
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"HOMEASSISTANT__TOKEN": "${localEnv:HOMEASSISTANT__TOKEN}",
"HOMEASSISTANT__HOST": "${localEnv:HOMEASSISTANT__HOST}",
"HOMEASSISTANT__PORT": "${localEnv:HOMEASSISTANT__PORT}",
"HASS_LOGLEVEL": "${localEnv:HASS_LOGLEVEL}",
"LOGGING__MINIMUMLEVEL": "${localEnv:LOGGING__MINIMUMLEVEL}",
"NETDAEMON__GENERATEENTITIES": "${localEnv:NETDAEMON__GENERATEENTITIES}",
"NETDAEMON__SOURCEFOLDER": "${localEnv:NETDAEMON__SOURCEFOLDER}"
},
Expand Down
4 changes: 2 additions & 2 deletions Docker/rootfs/etc/services.d/NetDaemon/run
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ set -e
declare runtype="Service"
declare daemondir="/daemon"

cd "${HASS_RUN_PROJECT_FOLDER}" || echo -e "\\033[31mCould not change directory to run project\\033[0m" >&2
cd "${NETDAEMON__PROJECTFOLDER}" || echo -e "\\033[31mCould not change directory to run project\\033[0m" >&2

if [[ "${PWD}" != "${HASS_RUN_PROJECT_FOLDER}" ]]; then
if [[ "${PWD}" != "${NETDAEMON__PROJECTFOLDER}" ]]; then
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY ./Docker/rootfs/etc/services.d/NetDaemon/run /rundaemon
ENV \
DOTNET_NOLOGO=true \
DOTNET_CLI_TELEMETRY_OPTOUT=true \
HASS_RUN_PROJECT_FOLDER=/usr/src/Service \
NETDAEMON__PROJECTFOLDER=/usr/src/Service \
HOMEASSISTANT__HOST=localhost \
HOMEASSISTANT__PORT=8123 \
HOMEASSISTANT__TOKEN=NOT_SET \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public class NetDaemonSettings
{
public bool? GenerateEntities { get; set; } = false;
public string? SourceFolder { get; set; } = null;
public string? ProjectFolder { get; set; } = string.Empty;
}
}
6 changes: 3 additions & 3 deletions src/Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ private static async Task ReadHassioConfig()
SerilogConfigurator.SetMinimumLogLevel(hassAddOnSettings.LogLevel);

if (hassAddOnSettings.GenerateEntitiesOnStart is object)
Environment.SetEnvironmentVariable("NetDaemon__GenerateEntities", hassAddOnSettings.GenerateEntitiesOnStart.ToString());
Environment.SetEnvironmentVariable("NETDAEMON__GENERATEENTITIES", hassAddOnSettings.GenerateEntitiesOnStart.ToString());

if (hassAddOnSettings.LogMessages is object && hassAddOnSettings.LogMessages == true)
Environment.SetEnvironmentVariable("HASSCLIENT_MSGLOGLEVEL", "Default");

if (hassAddOnSettings.ProjectFolder is object && string.IsNullOrEmpty(hassAddOnSettings.ProjectFolder) == false)
Environment.SetEnvironmentVariable("HASS_RUN_PROJECT_FOLDER", hassAddOnSettings.ProjectFolder);
Environment.SetEnvironmentVariable("NETDAEMON__PROJECTFOLDER", hassAddOnSettings.ProjectFolder);

// We are in Hassio so hard code the path
Environment.SetEnvironmentVariable("NetDaemon__AppFolder", "/config/netdaemon");
Environment.SetEnvironmentVariable("NETDAEMON__APPFOLDER", "/config/netdaemon");
}
catch (Exception e)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Service/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"NetDaemon": {
"SourceFolder": "",
"GenerateEntities": false
"GenerateEntities": false,
"ProjectFolder": ""
}
}

0 comments on commit cd4b573

Please sign in to comment.