Skip to content

Commit

Permalink
fix: Update install script - multiple fixes (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-silv authored Mar 21, 2024
1 parent 1c5a0eb commit 28aada1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
27 changes: 26 additions & 1 deletion SELFHOST.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Craig can be installed and ran locally. Some use cases for this are:
- Creating multiple instances of Craig

## Pre-requisites/dependencies
Craig can only be ran on a Linux machine. The installation has been tested on a fresh install of **Ubuntu 22.04**.
Craig can only be ran on a Linux machine. The installation has been tested on a fresh install of **Ubuntu 22.04** and **Kubuntu 23.10**.

The following `apt` packages will be automatically installed by the install script [install.sh](install.sh):

Expand Down Expand Up @@ -129,6 +129,31 @@ Most if not all browsers won't serve this because `localhost` doesn't have a sig

http://localhost:5029/rec/RECORDING_ID

### Error that Redis package is not signed

When testing with Kubuntu 23.10, the following error stops `sudo apt update` from working, which prematurely exits the install script:

```
E: Failed to fetch https://packages.redis.io/deb/dists/mantic/InRelease 403 Forbidden [IP: 18.173.121.98 443]
E: The repository 'https://packages.redis.io/deb mantic InRelease' is not signed.
```

This occurs because Redis does not have a signature for the Kubuntu 23.10 release (Mantic).

A workaround is to comment out the first line in `/etc/apt/sources.list.d/redis.list`, i.e.:

```sh
#deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb mantic main
```

To avoid having to continually comment this out every time the install script is ran, you can add the `#` directly in [install.sh](install.sh):

```sh
echo "#deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
```

This might need to be done for other distributions as well.

### Restarting Craig after reboot

By default, Craig will not automatically restart if you reboot your computer. You can re-run a modified version of [install.sh](install.sh) script so that the following steps are performed:
Expand Down
2 changes: 2 additions & 0 deletions install.config.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ GOOGLE_CLIENT_ID=test
GOOGLE_CLIENT_SECRET=test
MICROSOFT_CLIENT_ID=test
MICROSOFT_CLIENT_SECRET=test
DROPBOX_CLIENT_ID=test
DROPBOX_CLIENT_SECRET=test
APP_URI=http://localhost:3000
JWT_SECRET=1234

Expand Down
18 changes: 14 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,19 @@ install_apt_packages() {
# for more info, see: https://redis.io/docs/install/install-redis/install-redis-on-linux/
curl -fsSL https://packages.redis.io/gpg | sudo gpg --yes --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get update || true
sudo apt-get -y install redis
}

install_node() {
# Install and run node (must come before npm install because npm is included with node)
# we have to source nvm first otherwise in this non-interactive script it will not be available
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.nvm/nvm.sh

# There is a version error raised somewhere in "nvm.sh"
# because of set -e at the top of this script, we need to add the || true
source ~/.nvm/nvm.sh || true

nvm install $NODE_VERSION
nvm use $NODE_VERSION

Expand All @@ -123,7 +127,7 @@ start_redis() {

# otherwise 'redis-server' will not be found if this function
# is ran separately
source ~/.nvm/nvm.sh
source ~/.nvm/nvm.sh || true
nvm use $NODE_VERSION

# start redis and check if it is running, timeout if it hasn't started
Expand Down Expand Up @@ -203,6 +207,10 @@ start_postgresql() {
fi

sudo -u postgres -i psql -c "GRANT ALL PRIVILEGES ON DATABASE $DATABASE_NAME TO $POSTGRESQL_USER;"
sudo -u postgres -i psql -c "GRANT ALL ON SCHEMA public TO $POSTGRESQL_USER;"
sudo -u postgres -i psql -c "GRANT USAGE ON SCHEMA public TO $POSTGRESQL_USER;"
sudo -u postgres -i psql -c "ALTER DATABASE $DATABASE_NAME OWNER TO $POSTGRESQL_USER;"

sudo -u postgres -i psql -c "\l" # unnecessary but just for debugging
}

Expand Down Expand Up @@ -245,6 +253,8 @@ config_env() {
"GOOGLE_CLIENT_SECRET"
"MICROSOFT_CLIENT_ID"
"MICROSOFT_CLIENT_SECRET"
"DROPBOX_CLIENT_ID"
"DROPBOX_CLIENT_SECRET"
"APP_URI"
"JWT_SECRET"
)
Expand Down Expand Up @@ -340,7 +350,7 @@ start_app(){

# otherwise 'pm2' will not be found if this function
# is ran separately
source ~/.nvm/nvm.sh
source ~/.nvm/nvm.sh || true
nvm use $NODE_VERSION

info "Starting Craig..."
Expand Down

0 comments on commit 28aada1

Please sign in to comment.