1 Star 0 Fork 649

xqchen/mugen_dis_file

forked from openEuler/mugen 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qemu_ctl.sh 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/bash
# Copyright (c) [2022] Huawei Technologies Co.,Ltd.ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
####################################
# @Author : saarloos
# @email : 9090-90-90-9090@163.com
# @Date : 2022-05-20 15:41:00
# @License : Mulan PSL v2
# @Version : 1.0
# @Desc :
#####################################
OET_PATH=$(
cd "$(dirname "$0")" || exit 1
pwd
)
export OET_PATH
con_op=""
br_name="testbr0"
rem_br=0
for i in $*; do
if [ $rem_br -eq 1 ]; then
br_name="$i"
rem_br=0
fi
if [[ $i == "--br_name" ]]; then
rem_br=1
fi
if [[ $i == "start" || $i == "stop" && -z con_op ]]; then
con_op=$i
fi
done
br_conf="/etc/qemu/bridge.conf"
br_conf1="/usr/local/etc/qemu/bridge.conf"
br_conf2=""
br_conf_bak="/etc/qemu/bridge.conf.bak"
br_conf1_bak="/usr/local/etc/qemu/bridge.conf.bak"
br_conf2_bak=""
if [[ -n $MUGEN_QEMU_ACL_DIR ]]; then
mkdir -p $MUGEN_QEMU_ACL_DIR
br_conf2="$MUGEN_QEMU_ACL_DIR/bridge.conf"
br_conf2_bak="$MUGEN_QEMU_ACL_DIR/bridge.conf.bak"
fi
if [[ $con_op == "start" ]]; then
if [[ ! -e $con_op ]]; then
mkdir -p /etc/qemu/
mkdir -p /usr/local/etc/qemu/
fi
if [ -e $br_conf ]; then
cp $br_conf $br_conf_bak
fi
if [ -e $br_conf1 ]; then
cp $br_conf1 $br_conf1_bak
fi
echo "allow ${br_name}" >> $br_conf
echo "allow ${br_name}" >> $br_conf1
if [[ -n ${br_conf2} ]]; then
if [ -e $br_conf2 ]; then
cp $br_conf2 $br_conf2_bak
fi
echo "allow ${br_name}" >> $br_conf2
fi
brctl addbr ${br_name}
ifconfig ${br_name} up
fi
python3 ${OET_PATH}/libs/locallibs/qemu_ctl.py "$@"
if [[ $con_op == "stop" ]]; then
if [ -e $br_conf_bak ]; then
cp $br_conf_bak $br_conf
rm -rf $br_conf_bak
fi
if [ -e $br_conf1_bak ]; then
cp $br_conf1_bak $br_conf1
rm -rf $br_conf1_bak
fi
if [[ -n ${br_conf2} ]]; then
if [ -e $br_conf2_bak ]; then
cp $br_conf2_bak $br_conf2
rm -rf $br_conf2_bak
fi
fi
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sevenjj/mugen_dis_file.git
git@gitee.com:sevenjj/mugen_dis_file.git
sevenjj
mugen_dis_file
mugen_dis_file
master

搜索帮助