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
|
|
|
|
|
|
|
# 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
|
2024-03-08 17:24:22 +01:00
|
|
|
apt-get update
|
|
|
|
DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates python3 postgresql-client-15 git
|
2024-03-03 07:02:27 +01:00
|
|
|
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-04 10:09:59 +01:00
|
|
|
# If Firefish not exist
|
2024-03-03 16:36:46 +01:00
|
|
|
if [ ! -f '/firefish/README.md' ]; then
|
2024-03-03 07:02:27 +01:00
|
|
|
|
2024-03-04 10:09:59 +01:00
|
|
|
# Clone Firefish
|
|
|
|
cd /
|
|
|
|
git clone -v https://firefish.dev/firefish/firefish.git
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# 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:45:25 +01:00
|
|
|
URL="$(echo "${URL}" | sed 's#/#\\/#g')"
|
2024-03-04 10:09:59 +01:00
|
|
|
sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/" .config/default.yml
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Configure postgres, add pgroonga search
|
2024-03-03 18:13:13 +01:00
|
|
|
psql --user=firefish --host=firefish_db --dbname=firefish_db --command='CREATE EXTENSION IF NOT EXISTS pgroonga;'
|
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 18:13:13 +01:00
|
|
|
pnpm install --prod false
|
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 18:13:13 +01:00
|
|
|
pnpm install --prod false
|
2024-03-03 16:36:46 +01:00
|
|
|
pnpm run build:debug
|
2024-03-03 07:02:27 +01:00
|
|
|
pnpm run migrate
|
|
|
|
pnpm run start
|