mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
Reporting: Unbound DNS - modify pre-upgrade export hook, output when skipped or processed and transfer ownership to unbound
This commit is contained in:
parent
74b8f028f5
commit
6f48712a7d
@ -25,10 +25,20 @@
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
import glob
|
||||
sys.path.insert(0, "/usr/local/opnsense/site-python")
|
||||
from duckdb_helper import DbConnection
|
||||
|
||||
# export database in case the new storage version doesn't match
|
||||
with DbConnection('/var/unbound/data/unbound.duckdb', read_only=True) as db:
|
||||
if db.connection is not None:
|
||||
os.makedirs('/var/cache/unbound.duckdb', mode=0o750, exist_ok=True)
|
||||
shutil.chown('/var/cache/unbound.duckdb', 'unbound', 'unbound')
|
||||
db.connection.execute("EXPORT DATABASE '/var/cache/unbound.duckdb';")
|
||||
for filename in glob.glob('/var/cache/unbound.duckdb/*'):
|
||||
shutil.chown(filename, 'unbound', 'unbound')
|
||||
print('database exported.')
|
||||
else:
|
||||
print('skip: no database found')
|
||||
Loading…
x
Reference in New Issue
Block a user