#!/bin/bash function cd_dir { local dir_path=$1 # 检查目录是否存在 if [ ! -d "$dir_path" ]; then echo "Directory $dir_path does not exist. Creating..." mkdir -p "$dir_path" fi cd "$dir_path" || exit } # 安装包检测 function check_and_install { for package_name in "$@" do if ! dpkg -l $package_name &> /dev/null then echo "$package_name not found. Installing..." sudo apt-get update sudo apt-get install $package_name -y else echo "$package_name already installed." fi done } check_and_install librabbitmq-dev cd_dir build cmake .. make -j8 sudo make install -j8