bbj/setup.sh

40 lines
789 B
Bash
Raw Normal View History

2022-01-16 03:54:16 +00:00
#!/bin/sh
2017-04-02 07:35:58 +00:00
2022-01-16 03:54:16 +00:00
create_db() {
sqlite3 data.sqlite < schema.sql
chmod 600 data.sqlite
}
2017-04-02 07:35:58 +00:00
2017-04-02 14:53:55 +00:00
case $1 in
2022-01-16 03:54:16 +00:00
--help)
cat <<EOF
2017-04-02 14:53:55 +00:00
This script initializes the deps and files for bbj and also sets up its database.
It takes the following flags:
--help to print this
--dbset only runs the sql script
2017-04-02 07:35:58 +00:00
2017-04-02 14:53:55 +00:00
You can optionally pass a different python interpreter to use (such as
a virtual environment), with no arguments this will use the system python3
2019-03-03 22:13:24 +00:00
2017-04-02 14:53:55 +00:00
EOF
2022-01-16 03:54:16 +00:00
exit;;
2019-03-03 22:13:24 +00:00
2022-01-16 03:54:16 +00:00
--dbset)
create_db
exit;;
2017-04-02 14:53:55 +00:00
esac
2017-04-02 07:35:58 +00:00
2022-01-16 03:54:16 +00:00
[ -e logs ] || mkdir -p logs/exceptions
2019-03-03 22:13:24 +00:00
2022-01-16 03:54:16 +00:00
PYTHON=$(which python3)
[ -z "$1" ] || PYTHON="$1"
printf "Using %s...\n" "$PYTHON"
$PYTHON -m pip install -r requirements.txt
2019-03-03 22:13:24 +00:00
2022-01-16 03:54:16 +00:00
printf "Enter [i] to initialize a new database\n"
read -r CLEAR
2019-03-03 22:13:24 +00:00
2022-01-16 03:54:16 +00:00
if [ "$CLEAR" = "i" ]; then
create_db
2019-03-03 22:13:24 +00:00
fi