Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 37 additions & 50 deletions Docker/rootfs/etc/services.d/NetDaemonAddOnApp/run
Original file line number Diff line number Diff line change
@@ -1,74 +1,61 @@
#!/usr/bin/with-contenv bash
echo "Starting NetDaemon Runner"
#!/usr/bin/with-contenv /usr/bin/bashio

# Set configuration values to environment variables
export HomeAssistant__Host="supervisor"
export HomeAssistant__WebsocketPath="core/websocket"
export HomeAssistant__Port=80
export HomeAssistant__Token=$SUPERVISOR_TOKEN

export NetDaemon__ApplicationAssembly=$(bashio::config 'app_assembly')
export Logging__Loglevel__Default=$(bashio::config 'log_level')
export NetDaemon__ApplicationConfigurationFolder=$(bashio::config 'app_config_folder')

declare daemondir="/daemon"
declare is_custom_app_source=false

if [ ! -d "/data" ]; then
echo -e "\\033[31mMissing mapping to apps, please map '/data' to your apps folder\\033[0m" >&2
exit 1
bashio::exit.nok "Missing mapping to apps, please map '/data' to your apps folder"
fi

if [ ! -f "/data/options.json" ]; then
echo -e "\\033[31mThis container only supports running as Home Assistant add-on!\\033[0m" >&2
exit 1
fi

# Get the settings for application source
export NETDAEMON__APPLICATION_ASSEMBLY=$( jq -r .app_assembly /data/options.json )

if [[ "${NETDAEMON__APPLICATION_ASSEMBLY}" == *.csproj ]];
then
echo -e "\\033[31mcsproj deployments are not supported in v3, use compiled option instead!\\033[0m" >&2
exit 1
bashio::exit.nok "This container only supports running as Home Assistant add-on!"
fi

if [[ "${NETDAEMON__APPLICATION_ASSEMBLY}" == *.csproj ]];
if ! bashio::config.has_value "app_assembly"
then
echo -e "\\033[31mcsproj deployments are not supported in v3, use compiled option instead!\\033[0m" >&2
exit 1
fi

if [[ ! -z "${NETDAEMON__APPLICATION_ASSEMBLY}" ]] && [[ "${NETDAEMON__APPLICATION_ASSEMBLY}" != *".dll" ]];
then
echo -e "\\033[31mAssembly needs to point to a .dll file!\\033[0m" >&2
exit 1
fi
bashio::log.info "Starting NetDaemon V3 Runtime ..."
cd "${daemondir}"
exec dotnet NetDaemon.Host.Default.dll
else
# We have provided an application assembly setting
if [[ "${Netdaemon__ApplicationAssembly}" == *.csproj ]];
then
bashio::exit.nok "csproj deployments are not supported in v3, use compiled option instead!"
fi

if [[ "${NETDAEMON__APPLICATION_ASSEMBLY}" == *.dll ]];
then
is_custom_app_source=true
if [[ "${Netdaemon__ApplicationAssembly}" != *".dll" ]];
then
bashio::exit.nok "Assembly needs to point to a .dll file!"
fi

# make path relative to data folder (/config/netdaemon if addon)
# if the path is a relative path
if [[ "${NETDAEMON__APPLICATION_ASSEMBLY}" != /* ]];
if [[ "${Netdaemon__ApplicationAssembly}" != /* ]];
then
export NETDAEMON__APPLICATION_ASSEMBLY="/config/netdaemon3/${NETDAEMON__APPLICATION_ASSEMBLY}"
export Netdaemon__ApplicationAssembly="/config/netdaemon3/${Netdaemon__ApplicationAssembly}"
fi

# The provided application source is ether a project or pre-compiled .Net application
if [ ! -f ${NETDAEMON__APPLICATION_ASSEMBLY} ];
if ! bashio::fs.file_exists "${Netdaemon__ApplicationAssembly}";
then

echo -e "\\033[31mThe assembly ${NETDAEMON__APPLICATION_ASSEMBLY} cannot be found. Please check the settings.\\033[0m" >&2
exit 1
bashio::exit.nok "The assembly ${Netdaemon__ApplicationAssembly} cannot be found. Please check the settings."
fi
fi

if [[ $is_custom_app_source == false ]]; then
echo -e "\\033[32mRunning NetDaemon at ${daemondir}...\\033[0m" >&2
cd "${daemondir}"
exec dotnet NetDaemon.Host.AddOn.dll
else
# This is a pre-built deamon
echo -e "\\033[32mRunning the pre-built NetDaemon at ${NETDAEMON__APPLICATION_ASSEMBLY}...\\033[0m" >&2
cd "$(dirname "${NETDAEMON__APPLICATION_ASSEMBLY}")" || echo -e "\\033[31mCould not change directory to run project\\033[0m" >&2

bashio::log.info "Starting NetDaemon V3 pre-built Runtime using assembly ${Netdaemon__ApplicationAssembly}..."
cd "$(dirname "${Netdaemon__ApplicationAssembly}")" || bashio::exit.nok "Could not change directory to run project"

if [[ "${PWD}" != "$(dirname "${NETDAEMON__APPLICATION_ASSEMBLY}")" ]]; then
echo -e "\\033[31mCould not change directory to run custom project\\033[0m" >&2
exit 1
if [[ "${PWD}" != "$(dirname "${Netdaemon__ApplicationAssembly}")" ]]; then
bashio::exit.nok "Could not change directory to run custom project"
fi
runme="$(basename "${NETDAEMON__APPLICATION_ASSEMBLY}")"
runme="$(basename "${Netdaemon__ApplicationAssembly}")"
exec dotnet $runme
fi

6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ COPY ./Docker/rootfs/etc/services.d/NetDaemonApp /etc/services.d/NetDaemonApp
# COPY --from=builder /admin /admin
COPY --from=netbuilder /daemon /daemon

ENV NETDAEMON__APPLICATION_CONFIGURATION_FOLDER=/data
ENV \
HomeAssistant__Host=localhost \
HomeAssistant__Port=8123 \
HomeAssistant__Token=NOT_SET \
NetDaemon__ApplicationConfigurationFolder=/data

18 changes: 1 addition & 17 deletions Dockerfile.AddOn
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
# No admin support yet, we need to build the websocket API

# # Build the NetDaemon Admin with build container
# FROM ludeeus/container:frontend as builder

# RUN \
# apk add make \
# \
# && git clone https://github.com/net-daemon/admin.git /admin \
# && cd /admin \
# && git checkout tags/1.3.5 \
# && make deploy \
# \
# && rm -fr /var/lib/apt/lists/* \
# && rm -fr /tmp/* /var/{cache,log}/*

# Pre-build .NET NetDaemon core project
FROM mcr.microsoft.com/dotnet/sdk:6.0.100-bullseye-slim-amd64 as netbuilder
ARG TARGETPLATFORM
Expand All @@ -25,13 +10,12 @@ RUN echo "building for $TARGETPLATFORM"
RUN export TARGETPLATFORM=$TARGETPLATFORM
# Copy the source to docker container
COPY ./src /usr/src
RUN dotnet publish /usr/src/Host/NetDaemon.Host.AddOn/NetDaemon.Host.AddOn.csproj -o "/daemon"
RUN dotnet publish /usr/src/Host/NetDaemon.Host.Default/NetDaemon.Host.Default.csproj -o "/daemon"

# Final stage, create the runtime container
FROM ghcr.io/net-daemon/netdaemon_addonbase

# # Install S6 and the Admin site
# COPY ./Docker/rootfs/etc/services.d/NetDaemonAdmin /etc/services.d/NetDaemonAdmin
COPY ./Docker/rootfs/etc/services.d/NetDaemonAddOnApp /etc/services.d/NetDaemonAddOnApp

# COPY admin
Expand Down
15 changes: 0 additions & 15 deletions NetDaemon.sln
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debug", "Debug", "{E15D4280
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugHost", "dev\DebugHost\DebugHost.csproj", "{898966EA-F814-4B7B-9A3D-5E78C38174B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDaemon.Host.AddOn", "src\Host\NetDaemon.Host.AddOn\NetDaemon.Host.AddOn.csproj", "{55F0B65B-BA59-4E90-963E-7D661374511D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDaemon.Extensions.Logging", "src\Extensions\NetDaemon.Extensions.Logging\NetDaemon.Extensions.Logging.csproj", "{00333EBA-DB52-4D56-ADF7-940FB533E530}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDaemon.Extensions.Tts", "src\Extensions\NetDaemon.Extensions.Tts\NetDaemon.Extensions.Tts.csproj", "{F4B29B77-9B92-4037-A884-288CA5EF0B78}"
Expand Down Expand Up @@ -247,18 +245,6 @@ Global
{898966EA-F814-4B7B-9A3D-5E78C38174B2}.Release|x64.Build.0 = Release|Any CPU
{898966EA-F814-4B7B-9A3D-5E78C38174B2}.Release|x86.ActiveCfg = Release|Any CPU
{898966EA-F814-4B7B-9A3D-5E78C38174B2}.Release|x86.Build.0 = Release|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Debug|x64.ActiveCfg = Debug|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Debug|x64.Build.0 = Debug|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Debug|x86.ActiveCfg = Debug|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Debug|x86.Build.0 = Debug|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Release|Any CPU.Build.0 = Release|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Release|x64.ActiveCfg = Release|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Release|x64.Build.0 = Release|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Release|x86.ActiveCfg = Release|Any CPU
{55F0B65B-BA59-4E90-963E-7D661374511D}.Release|x86.Build.0 = Release|Any CPU
{00333EBA-DB52-4D56-ADF7-940FB533E530}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00333EBA-DB52-4D56-ADF7-940FB533E530}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00333EBA-DB52-4D56-ADF7-940FB533E530}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -304,7 +290,6 @@ Global
{DA86C13F-E31D-412E-94E6-B59F4AC0465D} = {A6D03AB9-6C8E-42BE-ACF6-7FA6A1C539C2}
{966C5143-7667-4E85-B7E3-336F7C28549F} = {8F8846B8-BD99-4855-96EA-392E012C4421}
{898966EA-F814-4B7B-9A3D-5E78C38174B2} = {E15D4280-7FFC-4F8B-9B8C-CF9AF2BF838C}
{55F0B65B-BA59-4E90-963E-7D661374511D} = {A6D03AB9-6C8E-42BE-ACF6-7FA6A1C539C2}
{00333EBA-DB52-4D56-ADF7-940FB533E530} = {DFF3E7AA-7A50-4A1E-B3F8-EC01531FB83D}
{F4B29B77-9B92-4037-A884-288CA5EF0B78} = {DFF3E7AA-7A50-4A1E-B3F8-EC01531FB83D}
EndGlobalSection
Expand Down
30 changes: 0 additions & 30 deletions src/Host/NetDaemon.Host.AddOn/Internal/Config/PluginConfig.cs

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions src/Host/NetDaemon.Host.AddOn/Internal/Helpers/LogLevelParser.cs

This file was deleted.

38 changes: 0 additions & 38 deletions src/Host/NetDaemon.Host.AddOn/NetDaemon.Host.AddOn.csproj

This file was deleted.

19 changes: 0 additions & 19 deletions src/Host/NetDaemon.Host.AddOn/Program.cs

This file was deleted.

Loading