#!/bin/bash
# Neo4j 启动脚本

NEO4J_HOME="/data/neo4j/neo4j-community-4.4.46"
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

cd "$NEO4J_HOME"

case "$1" in
    start)
        echo "正在启动 Neo4j..."
        ./bin/neo4j start
        sleep 3
        if ./bin/neo4j status > /dev/null 2>&1; then
            echo ""
            echo "✓ Neo4j 已成功启动！"
            echo "  Web 界面: http://localhost:7474"
            echo "  Bolt 连接: bolt://localhost:7687"
            echo "  用户名/密码: neo4j/neo4j"
        else
            echo "✗ Neo4j 启动失败，请查看日志: /data/neo4j/logs/neo4j.log"
        fi
        ;;
    stop)
        echo "正在停止 Neo4j..."
        ./bin/neo4j stop
        ;;
    restart)
        echo "正在重启 Neo4j..."
        ./bin/neo4j stop
        sleep 2
        ./bin/neo4j start
        sleep 3
        if ./bin/neo4j status > /dev/null 2>&1; then
            echo ""
            echo "✓ Neo4j 已成功重启！"
        fi
        ;;
    status)
        ./bin/neo4j status
        ;;
    *)
        echo "用法: $0 {start|stop|restart|status}"
        echo ""
        echo "命令说明:"
        echo "  start   - 启动 Neo4j"
        echo "  stop    - 停止 Neo4j"
        echo "  restart - 重启 Neo4j"
        echo "  status  - 查看 Neo4j 状态"
        exit 1
        ;;
esac





