Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate AppDaemon config out of Home Assistant config folder #285

Merged
merged 1 commit into from
Nov 10, 2023
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
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