node: Populate refs db on startup

If the refs database is empty, populate it on startup.
Also includes a script to clear it.
This commit is contained in:
cloudhead
2024-04-05 21:59:58 +02:00
parent 6be77ca9c3
commit ad7ba82e6a
2 changed files with 31 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
set -e
DB="$(rad path)/node/node.db"
if command -v sqlite3 >/dev/null 2>&1; then
if [ -f "$DB" ]; then
echo -n "Clearing 'refs' table from $DB.. "
sqlite3 $DB "DELETE FROM refs;"
echo "done."
else
echo "fatal: database file does not exist"
exit 1
fi
else
echo "fatal: sqlite3 is not installed"
exit 1
fi