Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 33 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,33 @@
# Working with URCPP

## Important things to know before developing

- Uses Python 2.7
- There is still sqlite code in here, but we are using mysql

## Quick Installation Guide with Docker

1. Ensure that you have the proper binaries installed by running `which docker docker-compose` and verifying the output (there should be a path for both). New student VMs should already be ready. If you do not have them, install them.
* `sudo apt-get install docker.io`
* Use the Linux instructions from https://docs.docker.com/compose/install/
* Your user should be in the docker group or you will need sudo privileges.
2. Clone this repository.
3. In your new repo directory, use docker-compose to start your application.
* `docker-compose up`

4. If this is successful, access your application at your server + the port
* If on your computer: http://localhost:8080
* If on your student VM, use that IP: e.g., http://172.31.3.69:8080
5. The application data will persist in your docker/data/db/ directory. To re-initialize it, use the appropriate script in tools/.
6. To understand more about using Docker and docker-compose, read http://172.31.2.178/en/docker.

## Manual Installation Guide

### Necessary packages and configuration
1. Ensure you have the necessary packages to run this application.
* `apt install git mysql-server python2.7 python-pip virtualenv`
2. You must be using Python 2.7
* If you are unsure how to fix this, read http://172.31.2.178/en/python-versions
3. Ensure you have access to the git repo using ssh keys
* Try and clone this repository. If it doesn't work, do the next step
* Paste your public key into bitbucket
* If you are unsure how to get your key, read http://172.31.2.178/en/ssh
4. Clone this repo.

### Database Setup
1. Ensure MySQL is running, with the proper root password set
* test with `mysql -u root --password="root"`
* if you can't connect and you do not have sudo privileges, someone will have to set this up for you
* `sudo systemctl start mysql`
* `echo "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; flush privileges;" | sudo mysql -u root --password=root`
2. Create the user and database
* This will erase any existing data!
* There will be ignorable errors if this is the initial setup.
* Run `./erase_mysql_db_and_use_real_data.sh` from the tools directory.
3. Edit the application configuration for your db host.
* In `api/config.yaml`, change your database host from "db" to your mysql host (e.g., "localhost")

### Application Setup
1. Initialize the application: `./setup.sh`
2. Activate your virtual environment: `source venv/bin/activate`
3. Run the application: `python api.py`
4. If this is successful, access your application at your server + the port
* If on your computer: http://localhost:8080
* If on your student VM, use that IP: e.g., http://172.31.3.69:8080
5. The application data will persist in mysql database. To re-initialize it, use the appropriate script in tools/.

## Customization and Troubleshooting

### Database Config

### Common Errors
* If you run into this error `bind: address already in use`, run the following command:
`sudo systemctl stop mysql`



### OLD BITS
4. run `phpmyadmin-ctl install` to run the phpmyadmin client.
5. navigate to the phpmyadmin interface

## Requirements
- Python2.7
- linux, unix, mac, windows(with attachments), Ubuntu
- virtualenv
- mysql and python mysql-db

## Setup
1. In your working environment, clone the URCPP Repo:
- `https://github.com/BCStudentSoftwareDevTeam/urcpp` as of 02/10/2022
3. Pull the most recent changes
4. Run `source setup.sh`

## Create database with Phpmyadmin

5. Go to your Phpmyadmin interface and log in with your credentials
- Located here: `http://0.0.0.0/phpmyadmin/`
Make sure to replace 0.0.0.0 with your server's IP address
6. Create a new database named `urcpp_flask`
- If a database of that name already exists, drop it and create it again
7. Create a user named `urcpp_flask` with password `DanforthLabor123!`
8. Grant all permissions on the database `urcpp_flask` to `urcpp_flask`
Continue to step 14.

## Create database using MYSQL commands

9. In your terminal use the command `mysql -u root -p`. You will be prompted to enter your password
10. Create the database: ` CREATE DATABASE urcpp_flask; `
11. Create a user with given password: ` CREATE USER 'urcpp_flask'@localhost IDENTIFIED BY 'DanforthLabor123!'; `
12. Grant all permissions: ` GRANT ALL PRIVILEGES ON 'urcpp_flask' . * TO 'urcpp_flask'@localhost; `
13. Make sure permissions take effect: ` flush privileges; `

## Continue from here again
14. Run `python api.py`
51 changes: 47 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
# Setup virtualenv
#mkdir -p data

if [ ! -d venv ]
if [ -d venv ]
then
virtualenv venv
echo "Deactivating and removing old virtualenv"
deactivate 2>&1 /dev/null
rm -rf venv
fi

# Check for correct python version
# VERSION=`python2 -V | awk '{print $2}'`
# if [ "${VERSION:0:1}" -ne "2" ] || [ "${VERSION:2:1}" -ne "7" ]; then
# echo "You must use Python 2.7. You are using $VERSION"
# return 1
# else
# echo -e "You are using Python $VERSION"
# fi

virtualenv --python=python2.7 venv
. venv/bin/activate

pip install -r requirements.txt
Expand All @@ -27,11 +39,43 @@ fi
FILE=${PWD}/api/settings.py
if test -f "$FILE"; then
echo "$FILE exists"
else
else
touch $FILE
echo "$FILE created"
fi
echo "Remember to edit your mail settings in $FILE"
pip install -U Werkzeug==0.16.0
pip install Flask
pip install peewee
pip install pyyaml
# For security, for LDAP
pip install pyopenssl ndg-httpsclient pyasn1
pip install ldap3
# For docs
pip install mkdocs
pip install gunicorn
pip install tornado

# additional python library
pip install XlsxWriter

#for login
pip install Flask-Login
pip install PyMySQL
# For QR Codes
pip install flask-wtf
pip install wtf-peewee
#flask-mail library
pip install Flask-Mail
#pip install sqlite-web
#pip install pyotp
#pip install qrcode
#pip install Pillow
#pip install git+git://github.com/ojii/pymaging.git#egg=pymaging
#pip install git+git://github.com/ojii/pymaging-png.git#egg=pymaging-png

# Database setup
# python recreate_dynamic.py

# To deactivate the venv, use
#
Expand All @@ -41,4 +85,3 @@ echo "Remember to edit your mail settings in $FILE"
# To set up the venv again, then type
#
# $ source setup.sh