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

Fix /config/asterisk/custom files being overwritten on restarts #323

Merged
merged 2 commits into from
Apr 21, 2024
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
8 changes: 8 additions & 0 deletions asterisk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

# Changelog

## 4.2.1

### Bug Fixes

- Use `friendly_name` instead of `id` as caller id (by @OnFreund at #322)
- Fix `/config/asterisk/custom` files being overwritten on container restart (by @felipecrs at #323, fixes #309)
- PS: this bug did not affect people running the add-on with Home Assistant Supervisor, only for people running the add-on as a standalone docker container.

## 4.2.0

### New Features
Expand Down
2 changes: 1 addition & 1 deletion asterisk/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Asterisk

Check warning on line 1 in asterisk/config.yaml

View workflow job for this annotation

GitHub Actions / Lint add-on asterisk

'map' contains the 'config' folder, which has been replaced by 'homeassistant_config'. See: https://developers.home-assistant.io/blog/2023/11/06/public-addon-config
version: 4.2.0
version: 4.2.1
slug: asterisk
description: PBX server for SIP devices like doorbells and phones
url: https://github.com/TECH7Fox/asterisk-hass-addons
Expand Down
8 changes: 8 additions & 0 deletions asterisk/rootfs/etc/cont-init.d/asterisk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,23 @@ if bashio::config.is_empty 'ami_password'; then
bashio::exit.nok "'ami_password' must be set"
fi

# deleting the target before writing to it ensures we don't write to a
# symlinked file, like when the container is restarted
rm -f "${etc_asterisk}/manager.conf"
bashio::var.json \
password "$(bashio::config 'ami_password')" |
tempio \
-template "${tempio_dir}/manager.conf.gtpl" \
-out "${etc_asterisk}/manager.conf"

rm -f "${etc_asterisk}/logger.conf"
bashio::var.json \
log_level "$(bashio::config 'log_level')" |
tempio \
-template "${tempio_dir}/logger.conf.gtpl" \
-out "${etc_asterisk}/logger.conf"

rm -f "${etc_asterisk}/http.conf"
bashio::var.json \
certfile "${target_certfile}" \
keyfile "${target_keyfile}" |
Expand Down Expand Up @@ -152,6 +157,7 @@ else
persons=[]
fi

rm -f "${etc_asterisk}/pjsip_default.conf"
bashio::var.json \
auto_add "^${auto_add}" \
auto_add_secret "${auto_add_secret}" \
Expand All @@ -161,6 +167,7 @@ bashio::var.json \
-template "${tempio_dir}/pjsip_default.conf.gtpl" \
-out "${etc_asterisk}/pjsip_default.conf"

rm -f "${etc_asterisk}/sip_default.conf"
bashio::var.json \
auto_add "^${auto_add}" \
auto_add_secret "${auto_add_secret}" \
Expand All @@ -170,6 +177,7 @@ bashio::var.json \
-template "${tempio_dir}/sip_default.conf.gtpl" \
-out "${etc_asterisk}/sip_default.conf"

rm -f "${etc_asterisk}/asterisk_mbox.ini"
bashio::var.json \
port "$(bashio::config 'mailbox_port')" \
password "$(bashio::config 'mailbox_password')" \
Expand Down