2024-03-03 16:36:46 +01:00
|
|
|
#!/bin/sh
|
2024-03-03 07:02:27 +01:00
|
|
|
|
2024-03-03 16:36:46 +01:00
|
|
|
set -xeu
|
|
|
|
node --version
|
2024-03-03 07:02:27 +01:00
|
|
|
|
2024-03-03 17:43:59 +01:00
|
|
|
FIREFISH_URL='http://localhost:3030'
|
2024-03-03 17:35:31 +01:00
|
|
|
|
2024-03-03 07:02:27 +01:00
|
|
|
# Check Environment Initialized Flag
|
2024-03-03 16:36:46 +01:00
|
|
|
if [ ! -f '/.firefish_env_initialized' ]; then
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# Install compilation dependencies
|
|
|
|
apt-get update
|
|
|
|
DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates python3 postgresql-client-15
|
|
|
|
curl -vvv --proto '=https' --tlsv1.2 --show-error --fail https://sh.rustup.rs | sh -s -- -y
|
|
|
|
|
|
|
|
# Add Cargo PATH
|
|
|
|
PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
|
2024-03-03 16:36:46 +01:00
|
|
|
if [ ! -f '/firefish/README.md' ]; then
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# Download Firefish and decompress
|
|
|
|
curl -vvv -O --proto '=https' --tlsv1.2 --show-error --fail https://firefish.dev/firefish/firefish/-/archive/develop/firefish-develop.tar.bz2
|
|
|
|
tar -xjvf firefish-develop.tar.bz2 --strip-components 1 -C /firefish
|
|
|
|
|
|
|
|
# Configuring a new server
|
|
|
|
cd /firefish
|
|
|
|
cp .config/devenv.yml .config/default.yml
|
2024-03-03 16:59:00 +01:00
|
|
|
|
2024-03-03 17:35:31 +01:00
|
|
|
URL="$(echo "${FIREFISH_URL}" | sed 's#/#\\/#g')"
|
2024-03-03 17:43:59 +01:00
|
|
|
sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/g" .config/default.yml
|
2024-03-03 17:35:31 +01:00
|
|
|
rm .config/defaut.yml.bak
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Configure postgres, add pgroonga search
|
2024-03-03 16:36:46 +01:00
|
|
|
psql -U firefish -p 25432 -h db -c 'CREATE EXTENSION pgroonga IF NOT EXISTS;'
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# Configure pnpm, and install dev mode dependencies for compilation
|
|
|
|
cd /firefish
|
|
|
|
corepack enable
|
|
|
|
corepack prepare pnpm@latest --activate
|
2024-03-03 16:36:46 +01:00
|
|
|
pnpm install
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add Environment Initialized Flag
|
2024-03-03 16:36:46 +01:00
|
|
|
touch /.firefish_env_initialized
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# Add Cargo PATH
|
|
|
|
PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
|
|
|
|
# Start a new server
|
|
|
|
cd /firefish
|
2024-03-03 16:36:46 +01:00
|
|
|
pnpm install
|
|
|
|
pnpm run build:debug
|
2024-03-03 07:02:27 +01:00
|
|
|
pnpm run migrate
|
|
|
|
pnpm run start
|