169 lines
3.5 KiB
Markdown
169 lines
3.5 KiB
Markdown
# Quick Start Guide
|
|
|
|
The following Description applies to Ubuntu or similar.
|
|
|
|
## Clone repository
|
|
Clone this repository and navigate into
|
|
```sh
|
|
$ git clone https://gitlab.cip.ifi.lmu.de/jost/UniWorX.git && cd UniWorX
|
|
```
|
|
|
|
## LDAP
|
|
install:
|
|
```sh
|
|
$ sudo apt-get install slapd ldap-utils
|
|
```
|
|
|
|
|
|
## PostgreSQL
|
|
install:
|
|
```sh
|
|
$ sudo apt-get install postgresql
|
|
```
|
|
|
|
switch to user *postgres* (got created during installation):
|
|
```sh
|
|
$ sudo -i -u postgres
|
|
```
|
|
|
|
add db user *uniworx*:
|
|
```sh
|
|
$ createuser --interactive
|
|
```
|
|
|
|
you'll get a prompt:
|
|
|
|
```sh
|
|
Enter name of role to add:` - uniworx
|
|
Shall the new role be a superuser? (y/n)` - [not exactly sure. Guess not?]
|
|
Password: uniworx
|
|
...
|
|
```
|
|
|
|
create database *uniworx*:
|
|
```sh
|
|
$ createdb uniworx
|
|
```
|
|
|
|
after you added the database switch back to your own user with `Ctrl + D`.
|
|
|
|
to access the database as user *uniworx* you now need to add a new linux-user called *uniworx*. when you get asked for a password enter *uniworx*.
|
|
```sh
|
|
$ sudo adduser uniworx
|
|
```
|
|
|
|
log-in as new user *uniworx*:
|
|
```sh
|
|
$ sudo -i -u uniworx
|
|
```
|
|
|
|
you can now use
|
|
```sh
|
|
$ psql uniworx
|
|
```
|
|
to execute SQL-commands and such.
|
|
|
|
## stack
|
|
Install with:
|
|
```sh
|
|
$ curl -sSL https://get.haskellstack.org/ | sh
|
|
```
|
|
|
|
setup stack and install dependencies:
|
|
```sh
|
|
$ stack setup
|
|
```
|
|
|
|
During this step or the next you might get an error that says something about missing C libraries for `ldap` and `lber`. You can install these using
|
|
```sh
|
|
$ sudo apt-get install libsasl2-dev libldap2-dev
|
|
```
|
|
|
|
If you get an error that says *You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.*
|
|
Go ahead an install `libpq-dev` with
|
|
```sh
|
|
$ sudo apt-get install libpq-dev
|
|
```
|
|
|
|
Other packages you might need to install during this process:
|
|
```sh
|
|
$ sudo apt-get install pkg-config
|
|
sudo apt-get install libsodium-dev
|
|
```
|
|
|
|
Build the app:
|
|
```sh
|
|
$ stack build
|
|
```
|
|
|
|
This might take a few minutes if not hours... be prepared.
|
|
|
|
install yesod:
|
|
```sh
|
|
$ stack install yesod-bin --install-ghc
|
|
```
|
|
|
|
## Add Dumy-Data and run the app
|
|
After building the app you can prepare the database and add some dummy data:
|
|
```sh
|
|
$ ./db.sh -f
|
|
```
|
|
|
|
Run the app:
|
|
```sh
|
|
$ ./start.sh
|
|
...
|
|
Devel application launched: http://localhost:3000
|
|
```
|
|
|
|
If you followed the steps above you should now be able to login as user Gregor Kleen using `LDAP:g.kleen@ifi.lmu.de` as dummy login.
|
|
|
|
***
|
|
|
|
# Sources and more infos
|
|
PostgreSQl:
|
|
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04
|
|
|
|
stack: https://docs.haskellstack.org/en/stable/README/#how-to-install
|
|
|
|
ldap: https://wiki.ubuntuusers.de/OpenLDAP_ab_Precise/
|
|
|
|
|
|
Instead of run.sh, use:
|
|
stack build --flag uniworx:dev --flag uniworx:library-only
|
|
|
|
|
|
***
|
|
|
|
# PostgreSQL
|
|
|
|
Starten als Root:
|
|
|
|
# systemctl start postgresql
|
|
# find / -name postgresql.conf
|
|
# cd /var/lib/pgsql/data/
|
|
# su - postgres
|
|
|
|
|
|
psql -U uniworx -d uniworx -h 127.0.0.1 -w
|
|
|
|
--Zeige Tabellen
|
|
\dt
|
|
|
|
--Zeige Tabellen Inhalt:
|
|
TABLE "user";
|
|
-- Die Anführungszeichen können manchmal weggelassen werden, aber
|
|
-- bei user sind sie notwendig, da es auch Schlüsselwort in sql ist.
|
|
|
|
--Lösche Tabelle "course" und alle davon abhängigen:
|
|
DROP TABLE "course" CASCADE;
|
|
|
|
-- UserId 5 zum Lecturer in SchoolId 1 machen (27 ist laufende Nummer)
|
|
INSERT INTO "user_lecturer" (id,"user","school") VALUES (27,5,1);
|
|
|
|
-- Beenden:
|
|
\q
|
|
|
|
-- Hilfe:
|
|
\help
|