Initial commit. Included are scripts to initialize the mariaDB or Neo4J databases, the entrypoint and backup for the web version, and the podman compose.yaml file.
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
ARGS_COUNT=$#
|
||||
help () {
|
||||
echo "CLI Tool used to initialize the database for vintagecoding.net."
|
||||
echo "With no arguments, it creates the application user in MariaDB,"
|
||||
echo "and creates the following tables:"
|
||||
echo "- roles (populated);"
|
||||
echo "- tags (populated);"
|
||||
echo "- user;"
|
||||
echo "- articles;"
|
||||
echo "- article_tags;"
|
||||
echo ""
|
||||
echo "The following flags are accepted:"
|
||||
echo " init_db.sh { --help | -h }"
|
||||
echo " init_db.sh { --delete | -d } { --verbose | -v }"
|
||||
}
|
||||
|
||||
if [[ $ARGS_COUNT > 0 ]]; then
|
||||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
||||
help
|
||||
exit
|
||||
fi
|
||||
|
||||
# Delete the existing database and start over.
|
||||
if [[ "$1" == "--delete" || "$1" == "-d" ]]; then
|
||||
if [[ "$2" == "--verbose" || "$2" == "-v" ]]; then
|
||||
echo "Deleting the existing database vintagecoding..."
|
||||
fi
|
||||
echo "vintage user pw"
|
||||
mariadb -u vintage -p -e "DROP DATABASE vintagecoding;"
|
||||
|
||||
if [[ "$2" == "--verbose" || "$2" == "-v" ]]; then
|
||||
echo "Deleting the vintage user..."
|
||||
fi
|
||||
echo "root user pw"
|
||||
mariadb -u root -p -e "DROP USER vintage@localhost;"
|
||||
|
||||
if [[ "$2" == "--verbose" || "$2" == "-v" ]]; then
|
||||
echo "Creating the vintage user..."
|
||||
fi
|
||||
echo "root user pw"
|
||||
mariadb -u root -p < setup.sql;
|
||||
|
||||
if [[ "$2" == "--verbose" || "$2" == "-v" ]]; then
|
||||
echo "Creating (and populating enum/static data) tables..."
|
||||
fi
|
||||
echo "vintage user pw"
|
||||
mariadb -u vintage -p < init.sql;
|
||||
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
#mariadb -u root -p < setup.sql;
|
||||
mariadb -u vintage -p < init.sql;
|
||||
Reference in New Issue
Block a user