Skip to content

Commit

Permalink
Update Docs, and move scripts to dev-setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
BanjoFox committed Aug 22, 2023
1 parent 4c7e0a7 commit bf2abc6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 179 deletions.
20 changes: 7 additions & 13 deletions dev-setup/debian-setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# First we should go home
cd ~
cd ~/

# Add PostgreSQL's repository to your system:
echo "Adding PostgreSQL's repository to your system..."
Expand Down Expand Up @@ -33,14 +33,14 @@ rustup install stable

# Install Rust tools:
echo "Installing Rust tools..."
rustup component add rustfmt clippy
rustup component add rustfmt clippy cargo-watch
cargo install diesel_cli --no-default-features --features "postgres"

# Clone Aardwolf:
echo "Switching to home directory"
cd ~/
echo "Cloning Aardwolf..."
git clone git@github.com:Aardwolf-Social/aardwolf.git
git clone https://github.com/aardwolf/aardwolf

# Setup PostgreSQL
echo "Setting up PostgreSQL..."
Expand All @@ -49,26 +49,20 @@ sudo systemctl start postgresql.service

# Create the aardwolf database
echo "Creating the aardwolf database..."
sudo -u postgres psql -c "CREATE DATABASE aardwolf;"
sudo -u postgres psql -c "CREATE DATABASE aardwolf_testing;"

# Create the aardwolf database user
echo "Creating the aardwolf database user..."
sudo -u postgres psql -c "CREATE USER aardwolf_user WITH PASSWORD 'changeme';"
sudo -u postgres psql -c "grant all privileges on database aardwolf_testing to aardwolf_user;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE aardwolf TO aardwolf_user;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE aardwolf_testing TO aardwolf_user;"

# Set up environment variables for database URLs
echo "Setting up environment variables..."
echo "DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf_testing" > ~/aardwolf/.env
echo "DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf" > ~/aardwolf/.env
echo "TEST_DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf_testing" >> ~/aardwolf/.env

# Set up diesel
echo "Setting up diesel..."
diesel setup

# Run migrations
echo "Running migrations"
diesel migration run

# Setup aardwolf
echo "Setting up aardwolf..."
cargo run --bin setup
35 changes: 15 additions & 20 deletions dev-setup/macos-setup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#!/bin/bash

# Add PostgreSQL's repository to your system:
echo "Adding PostgreSQL's repository to your system..."
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Import the repository signing key:
echo "Importing the PostgreSQL's repository signing key..."
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# Update the package lists:
echo "Updating package lists..."
brew update
Expand All @@ -16,6 +8,10 @@ brew update
echo "Installing PostgreSQL..."
brew install postgres

# Start PostgreSQL, and create default user:
brew service start postgresql@15
/usr/local/opt/postgresql@15/bin/createuser -s postgres

# Install Rust:
echo "Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
Expand All @@ -24,6 +20,11 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "Installing Rust stable toolchain..."
rustup install stable

# Set RUSTFLAGS to point linker to libpq
echo "Setting RUSTFLAGS for libpq..."
brew link postgresql@15
export RUSTFLAGS="-L/usr/local/opt/postgresql@15/lib"

# Install Rust tools:
echo "Installing Rust tools..."
rustup component add rustfmt clippy
Expand All @@ -33,29 +34,23 @@ cargo instal diesel_cli --no-default-features --features "postgres"
echo "Switching to home directory"
cd ~/
echo "Cloning Aardwolf..."
git clone git@github.com:Aardwolf-Social/aardwolf.git
git clone https://github.com/aardwolf/aardwolf

# Create the aardwolf database
echo "Creating the aardwolf database..."
sudo -u postgres psql -c "CREATE DATABASE aardwolf;"
sudo -u postgres psql -c "CREATE DATABASE aardwolf_testing;"

# Create the aardwolf database user
echo "Creating the aardwolf database user..."
sudo -u postgres psql -c "CREATE USER aardwolf_user WITH PASSWORD 'changeme';"
sudo -u postgres psql -c "grant all privileges on database aardwolf_testing to aardwolf_user;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE aardwolf TO aardwolf_user;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE aardwolf_testing TO aardwolf_user;"

# Set up environment variables for database URLs
echo "Setting up environment variables..."
echo "DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf_testing" > .env
echo "TEST_DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf_testing" >> .env

# Set up diesel
echo "Setting up diesel..."
diesel setup

# Run migrations
echo "Running migrations"
diesel migration run
echo "DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf" > ~/aardwolf/.env
echo "TEST_DATABASE_URL=postgresql://aardwolf_user:[email protected]:5432/aardwolf_testing" >> ~/aardwolf/.env

# Setup aardwolf
echo "Setting up aardwolf..."
Expand Down
14 changes: 10 additions & 4 deletions doc/AARDWOLF-SETUP.MD
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ Then, download the [rustup installer](https://www.rust-lang.org/en-US/install.ht
### Install Rust Toolchain

Once you have `rustup` installed, make sure you have the `nightly` rust
Once you have `rustup` installed, make sure you have the `stable` rust
toolchain installed:

$ rustup toolchain install nightly
$ rustup toolchain install stable

### Install Rust Toolchain Components

(Optional) - These tools are useful for development and testing

$ rustup component add rustfmt clippy cargo-watch

### Installing Rust database functionality

Expand All @@ -65,9 +71,9 @@ among other things.

To install it, run the following command:

$ cargo +nightly install -f diesel_cli --no-default-features --features "postgres"
$ cargo install diesel_cli --no-default-features --features "postgres"

This command will use the `nightly` version of `cargo` (the rust package
This command will use the `stable` version of `cargo` (the rust package
manager) to install the newest version of the `diesel_cli` crate. The
`--no-default-features --features "postgres"` options tell `cargo` to
skip installing the `mysql` and `sqlite` parts of `diesel`, which
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion doc/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ error: could not compile `aardwolf` (bin "aardwolf-server" test) due to previous
**Resolution:**
The key here after the wall of text --> `note: ld: library not found for -lpq`. The `lpq` package is normally installed as part of PostgreSQL (Lib PQ)

Debian/Ubunutu: `apt install libpq`
Debian/Ubunutu: `apt install libpq-dev`
Mac OS (Homebrew):
- Option 1: Install complete Postgres: `brew install postgres`
- Option 2: Install the libpq library only, and use `RUSTFLAGS="-L /usr/local/opt/libpq/lib" cargo [command] [package-name]`
76 changes: 0 additions & 76 deletions install/debian-setup.sh

This file was deleted.

65 changes: 0 additions & 65 deletions install/macos-setup.sh

This file was deleted.

0 comments on commit bf2abc6

Please sign in to comment.