Skip to content

Commit

Permalink
Migrate AppDaemon config out of Home Assistant config folder
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck committed Nov 10, 2023
1 parent 14b3ba2 commit 74a5020
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions appdaemon/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ single time this add-on starts.
This add-on does not configure the AppDaemon or HADashboard for you.
It does, however, create some sample files to get you started on the first run.

The configuration of the AppDaemon can be found in the `/config/appdaemon`
directory.
The configuration of the AppDaemon can be found in the add-on configuration
folder of this add-on.

For more information about configuring AppDaemon, please refer to the
extensive documentation they offer:
Expand Down
5 changes: 3 additions & 2 deletions appdaemon/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ ports:
ports_description:
5050/tcp: AppDaemon
map:
- config:rw
- share:rw
- addon_config:rw
- homeassistant_config:rw
- media:rw
- share:rw
- ssl
options:
system_packages: []
Expand Down
2 changes: 1 addition & 1 deletion appdaemon/rootfs/etc/s6-overlay/s6-rc.d/appdaemon/run
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ if bashio::config.has_value 'log_level'; then
fi

# Run the AppDaemon
exec appdaemon -c /config/appdaemon -D "${log_level}"
exec appdaemon -c /config -D "${log_level}"
27 changes: 11 additions & 16 deletions appdaemon/rootfs/etc/s6-overlay/s6-rc.d/init-appdaemon/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@
# Configures AppDaemon
# ==============================================================================

# Creates initial AppDaemon configuration in case it is non-existing
if ! bashio::fs.directory_exists '/config/appdaemon'; then
cp -R /root/appdaemon /config/appdaemon \
|| bashio::exit.nok 'Failed to create initial AppDaemon configuration'
# Migrate add-on data from the Home Assistant config folder,
# to the add-on configuration folder.
if ! bashio::fs.directory_exists '/config/appdaemon.yaml' \
&& bashio::fs.file_exists '/homeassistant/appdaemon/appdaemon.yaml'; then
shopt -s dotglob
mv /homeassistant/appdaemon/* /config/ \
|| bashio::exit.nok "Failed to migrate AppDaemon configuration"
fi

# Raise warning if the directory exists, but the appdaemon config is missing.
if ! bashio::fs.file_exists '/config/appdaemon/appdaemon.yaml'; then
bashio::log.fatal
bashio::log.fatal "Seems like the /config/appdaemon folder exists,"
bashio::log.fatal "however appdaemon.yaml wasn't found."
bashio::log.fatal
bashio::log.fatal "Remove or rename the /config/appdaemon folder"
bashio::log.fatal "and the add-on will create a new and fresh one"
bashio::log.fatal "for you."
bashio::log.fatal

bashio::exit.nok
# Creates initial AppDaemon configuration in case it is non-existing
if ! bashio::fs.directory_exists '/config/appdaemon.yaml'; then
cp -R /root/appdaemon/* /config/ \
|| bashio::exit.nok 'Failed to create initial AppDaemon configuration'
fi

# Install user configured/requested packages
Expand Down

0 comments on commit 74a5020

Please sign in to comment.