Add admin account when running init_sqlite.sh
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SQLITE=sqlite3
|
||||
PYTHON=python3
|
||||
|
||||
set -e
|
||||
|
||||
@@ -10,7 +11,19 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$SQLITE $1 -init schema.txt "insert into config (
|
||||
if [ -e "$1" ]
|
||||
then
|
||||
echo "Database '$1' already exists" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -p 'Admin username: ' username
|
||||
read -sp 'Admin password: ' password
|
||||
|
||||
password=$($PYTHON tool.py password "$password")
|
||||
time=$($PYTHON -c 'import time; print(time.time_ns())')
|
||||
|
||||
$SQLITE "$1" -init schema.txt "insert into config (
|
||||
version,
|
||||
name,
|
||||
description,
|
||||
@@ -25,4 +38,10 @@ values (
|
||||
'$(head -c 30 /dev/urandom | base64)',
|
||||
'$(head -c 30 /dev/urandom | base64)',
|
||||
0
|
||||
);"
|
||||
);
|
||||
|
||||
insert into users (name, password, role, join_time)
|
||||
values (lower('$username'), '$password', 2, $time);
|
||||
"
|
||||
|
||||
echo "Database '$1' created" >&2
|
||||
|
||||
Reference in New Issue
Block a user