Skip to content

Commit

Permalink
Merge pull request #323 from TECH7Fox/fix-restart
Browse files Browse the repository at this point in the history
Fix `/config/asterisk/custom` files being overwritten on restarts
  • Loading branch information
felipecrs committed Apr 21, 2024
2 parents 9044fba + f92e32a commit 9f087f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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

0 comments on commit 9f087f9

Please sign in to comment.