From 23fb39215e67ad4f7da65049ccbf7b36aeec73c3 Mon Sep 17 00:00:00 2001 From: Brian Walborn Date: Wed, 16 Mar 2022 14:39:18 -0400 Subject: [PATCH] Fix database initialization error and add startup scripts --- README.md | 33 ++++++++++++------------------- cloud_browser/database/schema.sql | 1 + startup.ps1 | 11 +++++++++++ startup.sh | 8 ++++++++ 4 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 startup.ps1 create mode 100644 startup.sh diff --git a/README.md b/README.md index c0d7feb..fdd7603 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ - [Git](https://git-scm.com/downloads) (of course!) - [Python 3.9](https://www.python.org/downloads/release/python-395/) or greater - [AWS CLI configuration](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config) +___ ### Initial set up (Linux, Mac, & Windows) 1. Clone the repository ```sh @@ -18,35 +19,27 @@ cd cloud-browser ```sh pip install -r requirements.txt ``` -2. Set the `FLASK_APP` environment variable +2. Run the `startup.sh` script with the `-d` flag to initialize the database ```sh -export FLASK_APP=cloud_browser -``` -3. Initialize the database -```sh -flask init-database -``` -4. Run the application -```sh -flask run +./startup.sh -d ``` +3. Navigate to localhost:5000 in a browser + +**Note:** To run the application after the database has been initialized, simply run `./startup.sh` +___ ### Running the application (in PowerShell) 1. Install the dependecies with `pip` ```powershell py -m pip install -r .\requirements.txt ``` -2. Set the `FLASK_APP` environment variable -```powershell -$env:FLASK_APP="cloud_browser" -``` -3. Initialize the database -```powershell -py -m flask init-database -``` -4. Run the application +2. Run the `startup.ps1` script with the `-d` flag to initialize the database ```powershell -py -m flask run +.\startup.ps1 -d ``` +3. Navigate to localhost:5000 in a browser + +**Note:** To run the application after the database has been initialized, simply run `.\startup.ps1` +___ ### Initialize settings 1. Enter the desired regions and tags on the settings page. For example: ![alt text](cloud_browser/static/images/settings.png) diff --git a/cloud_browser/database/schema.sql b/cloud_browser/database/schema.sql index 1dd8ceb..77e5df8 100644 --- a/cloud_browser/database/schema.sql +++ b/cloud_browser/database/schema.sql @@ -1,4 +1,5 @@ DROP TABLE IF EXISTS settings_exclude_tags; +DROP TABLE IF EXISTS settings_putty_session_names; DROP TABLE IF EXISTS settings_query_regions; DROP TABLE IF EXISTS settings_query_tags; diff --git a/startup.ps1 b/startup.ps1 new file mode 100644 index 0000000..645dbcb --- /dev/null +++ b/startup.ps1 @@ -0,0 +1,11 @@ +param ( + [switch] $d +) + +$env:FLASK_APP="cloud_browser" + +if ($d) { + py -m flask init-database +} + +py -m flask run diff --git a/startup.sh b/startup.sh new file mode 100644 index 0000000..17e3294 --- /dev/null +++ b/startup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +export FLASK_APP=cloud_browser + +if [[ $* == *--d* ]]; then + flask init-database +fi + +flask run