add docs/setup_ubuntu_2204.sh
This commit is contained in:
parent
67812d0ba4
commit
8ccef4bdac
35
Makefile
35
Makefile
@ -1,7 +1,7 @@
|
||||
OS := $(shell uname -s)
|
||||
PG_DSN ?= postgres://user:password@127.0.0.1:5432/postgres
|
||||
|
||||
.PHONY: install install-openresty install-redis install-postgresql install-pgvector init-db \
|
||||
.PHONY: install install-openresty install-redis install-postgresql install-pgvector install-zhparser init-db \
|
||||
build build-server build-homepage build-panel \
|
||||
start start-openresty start-server start-homepage start-panel \
|
||||
stop stop-server stop-homepage stop-panel stop-openresty restart
|
||||
@ -10,7 +10,7 @@ PG_DSN ?= postgres://user:password@127.0.0.1:5432/postgres
|
||||
# Dependency installation
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
install: install-openresty install-redis install-postgresql install-pgvector
|
||||
install: install-openresty install-redis install-postgresql install-pgvector install-zhparser
|
||||
|
||||
install-openresty:
|
||||
ifeq ($(OS),Darwin)
|
||||
@ -26,28 +26,37 @@ install-redis:
|
||||
ifeq ($(OS),Darwin)
|
||||
brew install redis && brew services start redis
|
||||
else
|
||||
sudo apt-get update && \
|
||||
sudo apt-get install -y redis-server && \
|
||||
sudo systemctl enable --now redis-server
|
||||
@echo "Using setup_ubuntu_2204.sh to install Redis..."
|
||||
bash docs/setup_ubuntu_2204.sh install-redis
|
||||
endif
|
||||
|
||||
install-postgresql:
|
||||
ifeq ($(OS),Darwin)
|
||||
brew install postgresql && brew services start postgresql
|
||||
brew install postgresql@14 && brew services start postgresql@14
|
||||
else
|
||||
sudo apt-get update && \
|
||||
sudo apt-get install -y postgresql postgresql-contrib && \
|
||||
sudo systemctl enable --now postgresql
|
||||
@echo "Using setup-ubuntu-2204.sh to install PostgreSQL 14..."
|
||||
bash docs/setup_ubuntu_2204.sh install-postgresql
|
||||
endif
|
||||
|
||||
install-pgvector:
|
||||
ifeq ($(OS),Darwin)
|
||||
brew install pgvector
|
||||
else
|
||||
sudo apt-get update && \
|
||||
( sudo apt-get install -y postgresql-15-pgvector || \
|
||||
sudo apt-get install -y postgresql-14-pgvector || \
|
||||
echo "Please install pgvector manually." )
|
||||
@echo "Using setup-ubuntu-2204.sh to install pgvector..."
|
||||
bash docs/setup_ubuntu_2204.sh install-pgvector
|
||||
endif
|
||||
|
||||
install-zhparser:
|
||||
ifeq ($(OS),Darwin)
|
||||
brew install scws && \
|
||||
tmp_dir=$$(mktemp -d) && cd $$tmp_dir && \
|
||||
git clone https://github.com/amutu/zhparser.git && \
|
||||
cd zhparser && make SCWS_HOME=/opt/homebrew PG_CONFIG=$$(brew --prefix postgresql@14)/bin/pg_config && \
|
||||
sudo make install SCWS_HOME=/opt/homebrew PG_CONFIG=$$(brew --prefix postgresql@14)/bin/pg_config && \
|
||||
cd / && rm -rf $$tmp_dir
|
||||
else
|
||||
@echo "Using setup-ubuntu-2204.sh to install zhparser..."
|
||||
bash docs/setup_ubuntu_2204.sh install-zhparser
|
||||
endif
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
85
docs/setup_ubuntu_2204.sh
Normal file
85
docs/setup_ubuntu_2204.sh
Normal file
@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
install-postgresql() {
|
||||
echo "=== 安装 PostgreSQL 14 ==="
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y wget curl gnupg lsb-release ca-certificates
|
||||
if ! grep -q "apt.postgresql.org" /etc/apt/sources.list.d/pgdg.list 2>/dev/null; then
|
||||
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc -o /tmp/pgdg.asc || \
|
||||
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB97B0E2D95A5761FB72B0C18ACCC4CF8" -o /tmp/pgdg.asc
|
||||
sudo gpg --dearmor -o /usr/share/keyrings/postgresql.gpg /tmp/pgdg.asc
|
||||
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
|
||||
| sudo tee /etc/apt/sources.list.d/pgdg.list
|
||||
sudo apt-get update
|
||||
fi
|
||||
sudo apt-get install -y postgresql-14 postgresql-client-14 postgresql-contrib-14 postgresql-server-dev-14
|
||||
sudo systemctl enable --now postgresql
|
||||
}
|
||||
|
||||
install-redis() {
|
||||
echo "=== 安装 Redis ==="
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y redis-server
|
||||
sudo systemctl enable --now redis-server
|
||||
}
|
||||
|
||||
install-pgvector() {
|
||||
echo "=== 安装 pgvector (源码) ==="
|
||||
sudo apt-get install -y git make gcc
|
||||
tmp_dir=$(mktemp -d)
|
||||
cd "$tmp_dir"
|
||||
git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git || \
|
||||
git clone https://ghproxy.com/https://github.com/pgvector/pgvector.git
|
||||
cd pgvector
|
||||
make && sudo make install
|
||||
cd /
|
||||
rm -rf "$tmp_dir"
|
||||
}
|
||||
|
||||
install-zhparser() {
|
||||
echo "=== 安装 scws v1.2.3 + zhparser ==="
|
||||
sudo apt-get install -y automake autoconf libtool pkg-config
|
||||
|
||||
# 编译安装 scws v1.2.3
|
||||
tmp_dir=$(mktemp -d)
|
||||
cd "$tmp_dir"
|
||||
git clone https://github.com/hightman/scws.git || \
|
||||
git clone https://ghproxy.com/https://github.com/hightman/scws.git
|
||||
cd scws
|
||||
|
||||
# 修掉 automake 不兼容的注释
|
||||
sed -i '/^[[:space:]]*#/d' Makefile.am || true
|
||||
|
||||
# 生成 configure
|
||||
if [ ! -f configure ]; then
|
||||
if [ -x ./autogen.sh ]; then
|
||||
./autogen.sh
|
||||
else
|
||||
autoreconf -fi
|
||||
fi
|
||||
fi
|
||||
|
||||
./configure --prefix=/usr
|
||||
make -j"$(nproc)" && sudo make install
|
||||
cd /
|
||||
rm -rf "$tmp_dir"
|
||||
|
||||
# 编译安装 zhparser
|
||||
tmp_dir=$(mktemp -d)
|
||||
cd "$tmp_dir"
|
||||
git clone https://github.com/amutu/zhparser.git || \
|
||||
git clone https://ghproxy.com/https://github.com/amutu/zhparser.git
|
||||
cd zhparser
|
||||
make SCWS_HOME=/usr PG_CONFIG=/usr/lib/postgresql/14/bin/pg_config
|
||||
sudo make install SCWS_HOME=/usr PG_CONFIG=/usr/lib/postgresql/14/bin/pg_config
|
||||
cd /
|
||||
rm -rf "$tmp_dir"
|
||||
}
|
||||
|
||||
if declare -f "$1" > /dev/null; then
|
||||
"$1"
|
||||
else
|
||||
echo "用法: $0 {install-postgresql|install-redis|install-pgvector|install-zhparser}"
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user