1. 开发环境搭建
- 1.虚拟机Vmware的安装:在PC主机下安装 Linux 系统,方便切换windows和Linux系统
- 2.在虚拟机Vmware中安装Ubuntu 操作系统:便于基于Linux系统的开发
- 3.Ubuntu 交叉编译工具链安装
- 4.Source Insight 安装:用于在Windows下代码编辑、阅读代码的工具
- 5.Visual Studio Code 的安装:用于在Windows下代码编辑、阅读代码的工具(免费的)
- 6.SecureCRT 安装 :终端工具
编写Vmware开发环境搭建的脚本
function pc_set(){
local sources_list='
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
'
local tftp_xinetd='
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
}
includedir /etc/xinetd.d
'
local tftpd_hpa="# /etc/default/tftpd-hpa
TFTP_USERNAME=\"tftp\"
TFTP_DIRECTORY=\"${
tftp_path}\"
TFTP_ADDRESS=\":69\"
TFTP_OPTIONS=\"-l -c -s\"
"
local tftp="
server tftp
{
socket_type = dgram
wait = yes
disable = no
user = root
protocol = udp
server = /usr/sbin/in.tftpd
server_args = -s ${tftp_path} -c
#log_on_success += PID HOST DURATION
#log_on_failure += HOST
per_source = 11
cps =100 2
flags =IPv4
}
"
local exports="# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
${nfs_path} *(rw,sync,no_root_squash)
"
sudo passwd #修改用户密码
cd ~
#更换国内源
if [ -f /etc/apt/sources.list ]; then #查询文件是否存在
multiple_input_file /etc/apt/sources.list "$sources_list"
else
echo "/etc/apt/sources.list 文件不存在"
echo "退出执行"
exit
fi
sudo apt-get update #更新软件源
sudo apt-get upgrade #升级软件
#Ubuntu(20.04)和Windows10双系统时间同步
sudo apt-get install ntpdate #在Ubuntu下更新本地时间
sudo ntpdate time.windows.com
#解决Ubuntu与主机之间不能粘贴复制,重启之后生效
sudo apt-get install open-vm-tools #安装工具open-vm-tools
sudo apt-get install open-vm-tools-desktop #安装工具open-vm-tools-desktop
#解决总是报错误提示【您想要报告这个错误吗】
if [ -f /etc/default/apport ]; then #查询文件是否存在
local Line_num=`grep -n "enabled=1" /etc/default/apport | cut -f1 -d:` #只输出匹配到的行号
if [[ $Line_num != "" ]]; then
sudo sed -i "${Line_num}c enabled=0" /etc/default/apport #删除原来的行,替换成行内容
if [[ $? != 0 ]];then
echo "/etc/default/apport 文件中 enabled=0 替换失败"
echo "退出执行"
exit
else
echo "/etc/default/apport 文件中 enabled=0 替换成功"
fi
else
echo "/etc/default/apport 文件中 enabled=0"
sudo cat /etc/default/apport
fi
else
echo "/etc/default/apport 文件不存在"
echo "退出执行"
exit
fi
#64位的ubantu运行32位的交叉编译工具链需要32位的运行库