feat: add official binaries with full FVM WAF functionality
- Extracted webserver (13.5MB) from safeline-mgt:9.3.9 - Extracted tcontrollerd (12MB) from safeline-tengine:9.3.9 - Extracted nginx from safeline-tengine:9.3.9 - Extracted libfusion.so (127MB) FVM engine from safeline-fvm:9.3.9 - Added musl libc for Alpine-based containers - Created proper FVM C headers matching libfusion.so API - Added install_full.sh for complete deployment
This commit is contained in:
@@ -0,0 +1,78 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# SafeLine WAF 完整版安装脚本
|
||||||
|
# 使用官方二进制,包含完整 FVM WAF 功能
|
||||||
|
|
||||||
|
INSTALL_DIR="${1:-/data/safeline}"
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
info() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
||||||
|
error() { echo -e "${RED}[ERROR]${NC} $*"; exit 1; }
|
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
error "需要 root 权限"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v docker &>/dev/null; then
|
||||||
|
error "Docker 未安装"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "安装到: $INSTALL_DIR"
|
||||||
|
|
||||||
|
# 创建目录
|
||||||
|
mkdir -p "$INSTALL_DIR"/{resources/{mgt,postgres/data,nginx,detector,chaos,cache,sock,luigi},logs/{nginx,detector},bin,lib}
|
||||||
|
|
||||||
|
# 复制二进制 (使用官方完整版)
|
||||||
|
cp "$SCRIPT_DIR/webserver_full" "$INSTALL_DIR/bin/webserver"
|
||||||
|
cp "$SCRIPT_DIR/tcontrollerd_full" "$INSTALL_DIR/bin/tcontrollerd"
|
||||||
|
cp "$SCRIPT_DIR/nginx" "$INSTALL_DIR/bin/nginx"
|
||||||
|
chmod +x "$INSTALL_DIR/bin/webserver" "$INSTALL_DIR/bin/tcontrollerd" "$INSTALL_DIR/bin/nginx"
|
||||||
|
|
||||||
|
# 复制 musl libc
|
||||||
|
cp "$SCRIPT_DIR/ld-musl-x86_64.so.1" "$INSTALL_DIR/lib/"
|
||||||
|
|
||||||
|
# 复制 FVM 动态库
|
||||||
|
if [ -f "$SCRIPT_DIR/libfvm.so" ]; then
|
||||||
|
cp "$SCRIPT_DIR/libfvm.so" "$INSTALL_DIR/lib/"
|
||||||
|
info "FVM 库已复制"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "二进制已复制 (完整版 - 包含 FVM WAF 功能)"
|
||||||
|
|
||||||
|
# 生成配置
|
||||||
|
if [ ! -f "$INSTALL_DIR/.env" ]; then
|
||||||
|
POSTGRES_PASSWORD=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 20)
|
||||||
|
cat > "$INSTALL_DIR/.env" << EOF
|
||||||
|
SAFELINE_DIR=$INSTALL_DIR
|
||||||
|
POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
||||||
|
MGT_PORT=9443
|
||||||
|
RELEASE=
|
||||||
|
CHANNEL=
|
||||||
|
REGION=
|
||||||
|
IMAGE_PREFIX=chaitin
|
||||||
|
IMAGE_TAG=9.3.9
|
||||||
|
SUBNET_PREFIX=192.168.90
|
||||||
|
ARCH_SUFFIX=
|
||||||
|
EOF
|
||||||
|
info ".env 已生成"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 复制 compose
|
||||||
|
if [ -f "$SCRIPT_DIR/compose.yaml" ]; then
|
||||||
|
cp "$SCRIPT_DIR/compose.yaml" "$INSTALL_DIR/docker-compose.yaml"
|
||||||
|
info "compose.yaml 已复制"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "安装完成!"
|
||||||
|
info ""
|
||||||
|
info "启动方式:"
|
||||||
|
info " cd $INSTALL_DIR"
|
||||||
|
info " docker compose up -d"
|
||||||
|
info ""
|
||||||
|
info "管理面板: https://$(hostname -I | awk '{print $1}'):9443/"
|
||||||
|
info "获取密码: docker exec safeline-mgt /app/mgt-cli reset-admin --once"
|
||||||
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <fvm-c/update.h>
|
||||||
|
|
||||||
typedef struct fvm_compiler fvm_compiler_t;
|
typedef struct fvm_compiler fvm_compiler_t;
|
||||||
typedef struct fvm_output fvm_output_t;
|
|
||||||
|
typedef struct {
|
||||||
|
fvm_buf_t buf;
|
||||||
|
} fvm_output_t;
|
||||||
|
|
||||||
fvm_compiler_t *fvm_compiler_acquire(const char *api_table);
|
fvm_compiler_t *fvm_compiler_acquire(const char *api_table);
|
||||||
void fvm_compiler_release(fvm_compiler_t *compiler);
|
void fvm_compiler_release(fvm_compiler_t *compiler);
|
||||||
@@ -14,6 +18,9 @@ bool fvm_compiler_load_re(fvm_compiler_t *compiler, const char *re, size_t re_le
|
|||||||
bool fvm_compiler_dump_re(fvm_compiler_t *compiler, char **out, size_t *out_len);
|
bool fvm_compiler_dump_re(fvm_compiler_t *compiler, char **out, size_t *out_len);
|
||||||
|
|
||||||
fvm_output_t *fvm_compile(fvm_compiler_t *compiler, const char *text);
|
fvm_output_t *fvm_compile(fvm_compiler_t *compiler, const char *text);
|
||||||
|
fvm_output_t *fvm_serialize(fvm_output_t *output, bool diff, long base, long target);
|
||||||
void fvm_output_destroy(fvm_output_t *output);
|
void fvm_output_destroy(fvm_output_t *output);
|
||||||
|
|
||||||
|
fvm_update_t *fvm_dump(fvm_framework_t *fw);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#ifndef FVM_FRAMEWORK_H
|
#ifndef FVM_FRAMEWORK_H
|
||||||
#define FVM_FRAMEWORK_H
|
#define FVM_FRAMEWORK_H
|
||||||
|
|
||||||
#include <ct/string.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef struct fvm_framework fvm_framework_t;
|
typedef struct fvm_framework fvm_framework_t;
|
||||||
|
|
||||||
|
const char *fvm_api_table(void);
|
||||||
fvm_framework_t *fvm_framework_acquire(void *config);
|
fvm_framework_t *fvm_framework_acquire(void *config);
|
||||||
void fvm_framework_release(fvm_framework_t *fw);
|
void fvm_framework_release(fvm_framework_t *fw);
|
||||||
|
bool fvm_update(fvm_framework_t *fw, fvm_update_t *update);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef FVM_PLOT_H
|
#ifndef FVM_PLOT_H
|
||||||
#define FVM_PLOT_H
|
#define FVM_PLOT_H
|
||||||
|
|
||||||
#include <ct/string.h>
|
#include <fvm-c/update.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ct_string_t buf;
|
fvm_buf_t buf;
|
||||||
} fvm_plot_t;
|
} fvm_plot_t;
|
||||||
|
|
||||||
fvm_plot_t *fvm_plot(fvm_framework_t *fw);
|
fvm_plot_t *fvm_plot(fvm_framework_t *fw);
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
#ifndef FVM_UPDATE_H
|
#ifndef FVM_UPDATE_H
|
||||||
#define FVM_UPDATE_H
|
#define FVM_UPDATE_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <ct/string.h>
|
#include <ct/string.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ct_string_t buf;
|
const char *ptr;
|
||||||
|
size_t length;
|
||||||
|
} fvm_buf_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
fvm_buf_t buf;
|
||||||
} fvm_update_t;
|
} fvm_update_t;
|
||||||
|
|
||||||
fvm_update_t *fvm_update_create(ct_string_t data);
|
fvm_update_t *fvm_update_create(ct_string_t data);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user