|
2 | 2 |
|
3 | 3 | MT-SSO is a Single-Sign-On authentication system for [EnCOMPASS](https://github.com/mathematicalthinking/encompass) and [VMT](https://github.com/mathematicalthinking/vmt) |
4 | 4 |
|
5 | | -## Installation (Technologies used) |
6 | | -- [MongoDB](http://www.mongodb.org/), |
7 | | -- [Express](http://expressjs.com/), |
8 | | -- [Node.js](http://nodejs.org/) |
9 | | -- [TypeScript](https://www.typescriptlang.org/) |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +You will need the following things properly installed on your computer. These instructions may vary if not using a mac. Some of the tools are a suggestion, such as MacDown. |
| 8 | + |
| 9 | +Note: these procedures work for an M1 Mac running Monterey. Please update this ddocument for other variations of OS and hardware. |
| 10 | + |
| 11 | +### Install HomeBrew (for zsh shell) |
| 12 | + [HomeBrew Install](https://docs.brew.sh/Installation) |
| 13 | +#### Summary: |
| 14 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" |
| 15 | + echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile |
| 16 | + eval "$(/opt/homebrew/bin/brew shellenv)" |
| 17 | + Note: this will install command line tools for xcode if needed |
| 18 | + |
| 19 | +### Install Git |
| 20 | + |
| 21 | +[Git](https://git-scm.com/) |
| 22 | +#### summary: |
| 23 | + brew install git |
| 24 | + brew install git-gui |
| 25 | + git config --global user.name "<your name here>" |
| 26 | + git config --global user.email <your.email@here> |
| 27 | + |
| 28 | +### Install NVM (Node Version Manager): |
| 29 | + |
| 30 | +[NVM Readme.md](https://github.com/nvm-sh/nvm) |
| 31 | + |
| 32 | +#### summary: |
| 33 | + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash |
| 34 | + |
| 35 | +#### open a new tab for NVM environment variables to be set |
| 36 | + nvm --version |
| 37 | + nvm install 12.16.1 |
| 38 | + <!-- - [Node.js](https://nodejs.org/) (with npm) --> |
| 39 | + |
| 40 | +### Install Google Chrome and Firefox |
| 41 | +[Google Chrome](https://google.com/chrome/) |
| 42 | + |
| 43 | +[Firefox](https://www.mozilla.org/en-US/firefox/new/) |
| 44 | + |
| 45 | +### MongoDB |
| 46 | + |
| 47 | +#### Install Mongodb Community Edition (M1 Mac) |
| 48 | + [Mongo Install on Mac](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/) |
| 49 | + |
| 50 | + xcode-select --install |
| 51 | + |
| 52 | + ln -s /opt/homebrew/Cellar/[email protected]/4.4.10/bin/mongod /opt/homebrew/bin/mongod |
| 53 | + mongod --config /opt/homebrew/etc/mongod.conf |
| 54 | + mongosh |
| 55 | + |
| 56 | +#### Send output from mongod to console, not log file |
| 57 | +##### Comment out systemLog options, so it defaults to console |
| 58 | + |
| 59 | + vi /opt/homebrew/etc/mongod.conf |
| 60 | + cat /opt/homebrew/etc/mongod.conf |
| 61 | + |
| 62 | +Config file should look like: |
| 63 | + |
| 64 | +``` |
| 65 | +# systemLog: |
| 66 | + # destination: file |
| 67 | + # path: /opt/homebrew/var/log/mongodb/mongo.log |
| 68 | + # logAppend: true |
| 69 | +storage: |
| 70 | + dbPath: /opt/homebrew/var/mongodb |
| 71 | +net: |
| 72 | + bindIp: 127.0.0.1 |
| 73 | +``` |
| 74 | + |
| 75 | +#### Mongodb Troubleshooting (M1 Mac) |
| 76 | +- Log location on M1 Mac: /opt/homebrew/var/log/mongodb/mongo.log |
| 77 | +- Database location on M1 Mac: /opt/homebrew/var/mongodb |
| 78 | +- Configuration file location on M1 Mac: /opt/homebrew/etc/mongod.conf |
| 79 | +- run mongod with debugging (-v for level 1, -vvvvv for level 5) |
| 80 | + ```mongod -vvvvv --config /opt/homebrew/etc/mongod.conf``` |
| 81 | + |
| 82 | +- 'mongod not found' on M1 Mac |
| 83 | + - to run with full path to see if any errors: |
| 84 | + ```/opt/homebrew/opt/[email protected]/bin/mongod``` |
| 85 | + |
| 86 | + - to set symbolic link to resolve problem: |
| 87 | + ```ln -s /opt/homebrew/Cellar/[email protected]/4.4.10/bin/mongod /opt/homebrew/bin/mongod``` |
| 88 | + |
| 89 | +- monitor the mongo.log (tail to only see log items after starting command - <ctl>c to stop): |
| 90 | + ```tail -f /opt/homebrew/var/log/mongodb/mongo.log``` |
| 91 | + |
| 92 | +- "Error during global initialization","attr":{"error":{"code":38,"codeName":"FileNotOpen","errmsg":"Failed to open /opt/homebrew/var/log/mongodb/mongo.log"}} |
| 93 | + - check the security on the log file: |
| 94 | + ```ls -al /opt/homebrew/var/log/mongodb/mongo.log``` |
| 95 | + - change the ownership of the log file to not be root |
| 96 | + ```sudo chown <yourMacUsername>:admin /opt/homebrew/var/log/mongodb/mongo.log``` |
| 97 | + - Lesson Learned: do not do sudo brew install |
| 98 | +- "DBException in initAndListen, terminating","attr":{"error":"IllegalOperation: Attempted to create a lock file on a read-only directory: /opt/homebrew/var/mongodb"} |
| 99 | + - check the security on the database directory: |
| 100 | + ```ls -al /opt/homebrew/var/mongodb``` |
| 101 | + - change ownership of all database files to not be root: |
| 102 | + ```sudo chown -R <yourMacUsername>:admin /opt/homebrew/var/mongodb/``` |
| 103 | + - Lesson Reinforced: do not do sudo brew install |
| 104 | +- mongosh returns ```MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017``` |
| 105 | + - confirm mongod is running |
| 106 | + |
| 107 | +#### install MongoDB Compass GUI |
| 108 | +[Download Compass](https://www.mongodb.com/try/download/compass) |
| 109 | + |
| 110 | +### Install Markdown Editor |
| 111 | +#### for mac you can use MacDown: |
| 112 | + https://macdown.uranusjr.com/) |
| 113 | + |
| 114 | + |
| 115 | +### Install Express |
| 116 | +[Express](http://expressjs.com/) |
| 117 | + |
| 118 | +#### Summary: |
| 119 | + npm install express --save |
| 120 | + |
| 121 | +### Install Typescript |
| 122 | +[TypeScript](https://www.typescriptlang.org/) |
| 123 | + |
| 124 | +#### Summary: |
| 125 | + npm install typescript --save-dev |
| 126 | + |
| 127 | +### Set Up Development Environment variable in the .env file |
| 128 | + |
| 129 | +#### Option 1 - 21pstem Setup (OAUTH via Mathematical Thinking google accounts) |
| 130 | +1. Locate the most recent date stamped folder of the Mathematical Thinking environments file in the SoftwareConfigs / DotEnvFiles folder. |
| 131 | +2. |
| 132 | + |
| 133 | +#### Option 2 - other setups (OAUTH via other google accounts) |
| 134 | + |
| 135 | +1. Copy the .env.example file to .env |
| 136 | + |
| 137 | + cp .env.example .env |
| 138 | + |
| 139 | +1. ##### Set up OAuth with Google for Sign In with Google |
| 140 | + |
| 141 | + [Set Up Sign In with Google (To Do)](https://github.com/mathematicalthinking/mt-sso/wiki/Setup-Sign-In-with-Google) |
| 142 | + |
| 143 | +## Start the Mathematical Thinking Single Sign On |
| 144 | + mongod --config /opt/homebrew/etc/mongod.conf |
| 145 | + npm run dev |
| 146 | + |
| 147 | +### Setup To Do |
| 148 | +1. Database load or generated testing database |
| 149 | + download mtlogin_stage_db_2021_05_10.gz from VmtEncompass folder |
| 150 | + mongo restore command |
| 151 | +2. User email and password to log in at |
| 152 | + username from mtlogin_stage_db_2021_05_10.gz database |
| 153 | + |
| 154 | + |
10 | 155 |
|
0 commit comments