#!/bin/bash # 安装 D-Bus 配置文件脚本 # 用于允许 soft_bus_daemon 注册 D-Bus 服务 set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CONFIG_FILE="$SCRIPT_DIR/com.softbus.Daemon.conf" SESSION_CONFIG_DIR="$HOME/.config/dbus-1/session.d" SYSTEM_CONFIG_DIR="/etc/dbus-1/session.d" echo "Installing D-Bus configuration for soft_bus_daemon..." # 创建用户级配置目录(推荐) if [ ! -d "$SESSION_CONFIG_DIR" ]; then echo "Creating directory: $SESSION_CONFIG_DIR" mkdir -p "$SESSION_CONFIG_DIR" fi # 复制配置文件到用户目录 if [ -f "$CONFIG_FILE" ]; then echo "Copying configuration to: $SESSION_CONFIG_DIR/" cp "$CONFIG_FILE" "$SESSION_CONFIG_DIR/" echo "✓ Configuration installed successfully!" echo "" echo "Note: You may need to restart your D-Bus session or log out/in for changes to take effect." echo "Alternatively, restart the dbus-daemon:" echo " killall dbus-daemon # This will restart automatically" else echo "Error: Configuration file not found: $CONFIG_FILE" exit 1 fi # 可选:安装到系统目录(需要 root 权限) if [ "$1" == "--system" ]; then if [ "$EUID" -ne 0 ]; then echo "Error: --system option requires root privileges" exit 1 fi if [ ! -d "$SYSTEM_CONFIG_DIR" ]; then echo "Creating directory: $SYSTEM_CONFIG_DIR" mkdir -p "$SYSTEM_CONFIG_DIR" fi echo "Copying configuration to: $SYSTEM_CONFIG_DIR/" cp "$CONFIG_FILE" "$SYSTEM_CONFIG_DIR/" echo "✓ System-wide configuration installed successfully!" fi