代码拉取完成,页面将自动刷新
#!/usr/bin/bash
# Copyright (c) [2021] 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 : lemon-higgins
# @email : lemon.higgins@aliyun.com
# @Date : 2021-04-23 16:08:22
# @License : Mulan PSL v2
# @Version : 1.0
# @Desc :
#####################################
usage() {
printf "Usage: sh dep_install.sh [options]\n
-e: install addtitional dependencies qemu for remote testing\n
-g shell_file: run shell file to set crocess compiliation, if have run srcipt must use source\n
-h: print this usage info\n
\n"
}
common_dep(){
zypper install -y expect psmisc make iputils python3-six python3-paramiko lshw
}
anolis_dep(){
yum install expect psmisc make iputils gcc -y
yum install python39 -y
ln -s -f /usr/bin/pip3.9 /etc/alternatives/pip3
ln -s -f /usr/bin/pip-3.9 /etc/alternatives/pip-3
ln -s -f /usr/bin/python3.9 /etc/alternatives/python3
pip3 install paramiko -i https://pypi.tuna.tsinghua.edu.cn/simple
}
qemu_dep(){
echo "install qemu"
zypper install -y bridge-utils
qemu-system-aarch64 --version && qemu-system-arm --version
if [ $? -eq 0 ]; then
return 0
fi
zypper install -y qemu-system-aarch64 qemu-system-arm
if [ $? -ne 0 ]; then
echo "ERROR: qemu not install, you need install it youself."
return 1
fi
}
run_name=$0
in_qemu=0
run_shell=""
check_option(){
had_g=0
for opt in "$@"; do
if [[ $opt == "-h" ]]; then
usage
return 0
elif [[ $opt == "-e" ]]; then
in_qemu=1
elif [[ $opt == "-g" ]]; then
had_g=1
check_name=${run_name##*/}
if [[ $check_name == "dep_install.sh" ]]; then
echo "ERROR: run with crocess compiliation, must use 'source' to run script"
return 1
fi
elif [ $had_g -eq 1 ]; then
run_shell=$opt
else
usage
return 1
fi
done
if [[ had_g -eq 1 && run_shell == "" ]]; then
echo "ERROR: -g parameter need"
usage
return 1
fi
return 0
}
main(){
check_option $@
if [ $? -ne 0 ]; then
return 1
fi
common_dep
if [ $? -ne 0 ]; then
return 1
fi
if [ $in_qemu -eq 1 ]; then
qemu_dep
if [ $? -ne 0 ]; then
return 1
fi
fi
if [ $run_shell ]; then
source $run_shell
if [ $? -ne 0 ]; then
echo "ERROR: run crocess compiliation file $run_shell fail"
return 1
fi
fi
return 0
}
main $@
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。