You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
smp_pc_20240625/download_and_execute.sh

103 lines
2.3 KiB

5 months ago
#!/bin/bash
5 months ago
check_software() {
local software_name=$1
if command -v $software_name &> /dev/null
then
echo "$software_name 已安装"
else
echo "$software_name 未安装"
fi
}
check_library() {
local library_path=$1
if [ -f "$library_path" ]; then
echo "库文件 $library_path 存在"
else
echo "库文件 $library_path 不存在"
fi
}
check_python_library() {
local library_name=$1
python -c "import $library_name" &> /dev/null
if [ $? -eq 0 ]; then
echo "Python库 $library_name 存在"
else
echo "Python库 $library_name 不存在"
fi
}
# 检查某个软件
check_software "git"
5 months ago
5 months ago
# 检查某个库文件
#check_library "/usr/lib/libc.so.6"
# 检查某个Python库
#check_python_library "numpy"
5 months ago
# 检查 libcamera-still 命令是否存在
if command -v libcamera-still >/dev/null 2>&1; then
echo "libcamera-still 命令存在"
else
echo "libcamera-still 命令不存在"
exit 1
fi
5 months ago
5 months ago
# 设置仓库URL和本地目录
repo_url="https://bdgit.educoder.net/pv2ajsu8k/smp_pc_20240625.git"
local_dir="smp_pc"
# 检查是否安装了git
if ! command -v git &> /dev/null; then
echo "未找到git尝试安装git..."
if command -v apt-get &> /dev/null; then
sudo apt-get update
sudo apt-get install -y git
elif command -v yum &> /dev/null; then
sudo yum install -y git
else
echo "无法自动安装git请手动安装git后重试。"
exit 1
fi
fi
5 months ago
# 检查是否存在本地目录
if [ -d "$local_dir" ]; then
echo "本地目录 $local_dir 已存在,请删除后重试。"
exit 1
fi
5 months ago
# 克隆仓库
if git clone $repo_url $local_dir; then
echo "仓库克隆成功"
else
echo "仓库克隆失败"
exit 1
fi
5 months ago
2 weeks ago
# 进入仓库目录
cd $local_dir || { echo "无法进入目录 $local_dir"; exit 1; }
5 months ago
5 months ago
# 检查smp_init.sh是否存在
if [ -f "smp_init.sh" ]; then
# 如果没有执行权限,尝试添加执行权限
if [ ! -x "smp_init.sh" ]; then
echo "smp_init.sh 没有执行权限,尝试添加执行权限..."
chmod +x "smp_init.sh" || { echo "无法添加执行权限"; exit 1; }
fi
# 执行smp_init.sh
5 months ago
./smp_init.sh
5 months ago
echo "smp_init.sh 执行完成"
else
echo "smp_init.sh 不存在"
exit 1
5 months ago
fi