Skip to content

Commit

Permalink
✨ Add option to reset database (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairpaul authored Sep 23, 2020
1 parent dd144e0 commit df7573d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions proxy-manager/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ more severe level, e.g., `debug` also shows `info` messages. By default,
the `log_level` is set to `info`, which is the recommended setting unless
you are troubleshooting.

### Option: `reset_database`

By setting to `true` provides the option to delete and recreate the database. As
the data is held within the MariaDB addon, it is not removed on an uninstall.

**Note**: _Once the database is reset the configuration for the addon will be
cleared automatically_

## Known issues and limitations

- The original NGinx Proxy Manager has support for forwarding TCP/UDP streams,
Expand Down
3 changes: 2 additions & 1 deletion proxy-manager/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"map": ["ssl:rw", "backup:rw"],
"options": {},
"schema": {
"log_level": "list(trace|debug|info|notice|warning|error|fatal)?"
"log_level": "list(trace|debug|info|notice|warning|error|fatal)?",
"reset_database": "bool?"
}
}
10 changes: 10 additions & 0 deletions proxy-manager/rootfs/etc/cont-init.d/mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ password=$(bashio::services "mysql" "password")
port=$(bashio::services "mysql" "port")
username=$(bashio::services "mysql" "username")

#Drop database based on config flag
if bashio::config.true 'reset_database'; then
bashio::log.warning 'Recreating database'
echo "DROP DATABASE IF EXISTS nginxproxymanager;" \
| mysql -h "${host}" -P "${port}" -u "${username}" -p"${password}"

#Reset addon options to null
bashio::api.supervisor POST "/addons/self/options" '{"options": {}}'
fi

# Create database if not exists
echo "CREATE DATABASE IF NOT EXISTS nginxproxymanager;" \
| mysql -h "${host}" -P "${port}" -u "${username}" -p"${password}"
Expand Down

0 comments on commit df7573d

Please sign in to comment.