forked from OpenAgricultureFoundation/openag-device-software
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial rework of scripts directory and install flow
- Loading branch information
Jake Rye
committed
Jan 23, 2019
1 parent
4004f03
commit 1b1fc1b
Showing
67 changed files
with
468 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ pyudev==0.21.0 | |
whitenoise==4.1 | ||
django-bootstrap-static==4.0.0 | ||
django-tempus-dominus==5.0.1.2 | ||
pyftdi==0.29.2 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Log creation status | ||
echo 'Creating database...' | ||
|
||
# Create database on linux operating system | ||
if [[ "$OSTYPE" == "linux"* ]]; then | ||
sudo -u postgres psql -c "CREATE DATABASE openag_brain OWNER openag;" | ||
|
||
# Create database on darwin operating system | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
psql postgres -c "CREATE DATABASE openag_brain OWNER openag;" | ||
|
||
# Unsupported operating system | ||
else | ||
echo "Unable to create database, unsupported operating system: $OSTYPE" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Log creation status | ||
echo 'Creating postgres user...' | ||
|
||
# Create database on linux operating system | ||
if [[ "$OSTYPE" == "linux"* ]]; then | ||
sudo -u postgres psql -c "CREATE USER openag WITH PASSWORD 'openag';" | ||
sudo -u postgres psql -c "ALTER USER openag SUPERUSER;" | ||
|
||
# Create database on darwin operating system | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
psql postgres -c "CREATE USER openag WITH PASSWORD 'openag';" | ||
psql postgres -c "ALTER USER openag SUPERUSER;" | ||
|
||
# Unsupported operating system | ||
else | ||
echo "Unable to create database, unsupported operating system: $OSTYPE" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Log creation status | ||
echo "Creating project users..." | ||
|
||
# Check virtual environment is activated | ||
if [[ -z "${VIRTUAL_ENV}" ]] ; then | ||
echo "Please activate your virtual environment then re-run script" | ||
exit 1 | ||
fi | ||
|
||
# Check project root exists | ||
if [[ -z "$PROJECT_ROOT" ]]; then | ||
echo "Please set your project root in your virtual environment then re-run script" | ||
exit 1 | ||
fi | ||
|
||
# Check python3.6 is installed | ||
INSTALL_PATH=`which python3.6` | ||
if [[ ! -f "$INSTALL_PATH" ]]; then | ||
echo "Please install python3.6 then re-run script" | ||
exit 1 | ||
fi | ||
|
||
# Create project users | ||
echo "from django.contrib.auth.models import User; User.objects.filter(email='[email protected]').delete(); User.objects.create_superuser('openag', '[email protected]', 'openag')" | python3.6 $PROJECT_ROOT/manage.py shell | ||
echo "from django.contrib.auth.models import User; User.objects.create_superuser('backdoor', '[email protected]', 'B@ckd00r')" | python3.6 $PROJECT_ROOT/manage.py shell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Log recreation status | ||
echo 'Dropping database...' | ||
|
||
# Recreate on linux operating system | ||
if [[ "$OSTYPE" == "linux"* ]]; then | ||
sudo -u postgres psql -c "DROP DATABASE openag_brain;" | ||
|
||
# Recreate on darwin operating system | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
psql postgres -c "DROP DATABASE openag_brain;" | ||
|
||
# Invalid operating system | ||
else | ||
echo "Unable to drop database, unsupported operating system: $OSTYPE" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Log drop status | ||
echo 'Dropping state table...' | ||
|
||
# Drop state table on linux operating system | ||
if [[ "$OSTYPE" == "linux"* ]]; then | ||
sudo -u postgres psql openag_brain -c "DELETE FROM app_statemodel;" | ||
|
||
# Drop state table on darwin operating system | ||
elif [[ "$OSTYPE" == "linux"* ]]; then | ||
psql postgres openag_brain -c "DELETE FROM app_statemodel;" | ||
|
||
# Invalid operating system | ||
else | ||
echo "Unable to drop state table, unsupported operating system: $OSTYPE" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
psql --username=openag openag_brain -c '\l' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
psql --username=openag openag_brain -c '\dt' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Log migration status | ||
echo "Migrating database..." | ||
|
||
# Check virtual environment is activated | ||
if [[ -z "${VIRTUAL_ENV}" ]] ; then | ||
echo "Please activate your virtual environment then re-run script" | ||
exit 1 | ||
fi | ||
|
||
# Check project root exists | ||
if [[ -z "$PROJECT_ROOT" ]]; then | ||
echo "Please set your project root in your virtual environment then re-run script" | ||
exit 1 | ||
fi | ||
|
||
# Check python3.6 is installed | ||
INSTALL_PATH=`which python3.6` | ||
if [[ ! -f "$INSTALL_PATH" ]]; then | ||
echo "Please install python3.6 then re-run script" | ||
exit 1 | ||
fi | ||
|
||
# Migrate database | ||
python3.6 $PROJECT_ROOT/manage.py migrate |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,6 @@ echo "from django.contrib.auth.models import User; User.objects.filter(email='op | |
echo "from django.contrib.auth.models import User; User.objects.create_superuser('backdoor', '[email protected]', 'B@ckd00r')" | python3.6 manage.py shell | ||
|
||
|
||
# How to list the databases: | ||
# psql --username=openag openag_brain -c '\l' | ||
|
||
# How to list the tables in our database: | ||
# psql --username=openag openag_brain -c '\dt' | ||
|
||
# How to log into postgres interactively: | ||
# psql --username=openag openag_brain | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Log creation status | ||
echo "Creating virtual environment..." | ||
|
||
# Install on linux or darwin operating system | ||
if [[ "$OSTYPE" == "linux"* || "$OSTYPE" == "darwin"* ]]; then | ||
|
||
# Ensure virtualenv is installed | ||
INSTALL_PATH=`which virtualenv` | ||
if [[ ! -f "$INSTALL_PATH" ]]; then | ||
|
||
# Log install status | ||
echo "Installing virtualenv..." | ||
|
||
# Check pip3.6 is installed | ||
INSTALL_PATH=`which pip3.6` | ||
if [[ ! -f "$INSTALL_PATH" ]]; then | ||
echo "Unable to install virtualenv, pip3.6 is not installed" | ||
exit 1 | ||
fi | ||
|
||
# Install virtualenv | ||
pip3.6 install virtualenv | ||
|
||
fi | ||
|
||
# Remove any existing virtual environment | ||
rm -fr venv | ||
|
||
# Create virtual environment | ||
virtualenv -p python3.6 venv | ||
|
||
# Invalid operating system | ||
else | ||
echo "Unable to create virtual environment, unsupported operating system: $OSTYPE" | ||
exit 1 | ||
fi |
14 changes: 14 additions & 0 deletions
14
scripts/install/initialize_virtual_environment_activate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Initialize passed in variables | ||
PROJECT_ROOT=$1 | ||
|
||
# TODO: Make sure we received project root as passed in parameter | ||
|
||
# Set project root as environment variable in virtual environment | ||
printf "\n# Set project root\n" >> $PROJECT_ROOT/venv/bin/activate | ||
echo "export PROJECT_ROOT=$PROJECT_ROOT" >> $PROJECT_ROOT/venv/bin/activate | ||
|
||
# Set platform environment variables in virtual environment | ||
printf "\n# Set platform variables\n" >> $PROJECT_ROOT/venv/bin/activate | ||
echo "source $PROJECT_ROOT/scripts/platform/get_platform_info.sh" >> $PROJECT_ROOT/venv/bin/activate |
Oops, something went wrong.