系统版本:Ubuntu 20.04.1 LTS
#!/bin/sh
# This shell works for Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-42-generic x86_64) only
echo '禁用合盖休眠'
sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=ignore/g' /etc/systemd/logind.conf
echo '更新源...'
apt-get update -y
apt-get upgrade -y
echo '安装无线网工具...'
apt-get install -y wireless-tools
echo '安装网络工具...'
apt-get install -y net-tools
echo '安装网络管理工具...'
apt-get install -y wpasupplicant
apt-get install -y network-manager
echo '安装无线网卡驱动...'
apt install -y broadcom-sta-dkms
apt --fix-broken install
echo '安装字符串截取工具...'
apt-get install -y awk
enp_name=$(ip a | grep 'enp' | awk '{print $2}' | grep 'enp')
wlp_name=$(ip a | awk '{print $2}' | grep 'wlp')
echo '无线网卡设备名:'${wlp_name%:*}
echo '有线网卡设备名:'${enp_name%:*}
SSID='你的WiFi名称'
PWD='WiFi密码'
echo '定义WiFi连接'
echo ' SSID:'$SSID' Passwd:'$PWD
echo '写入配置文件到/etc/netplan/00-installer-config.yaml'
echo "# This is the network config written by 'subiquity'
network:
renderer: NetworkManager
ethernets:
$enp_name
dhcp4: true
wifis:
$wlp_name
dhcp4: true
access-points:
'$SSID':
password: '$PWD'
version: 2">/etc/netplan/00-installer-config.yaml
echo '为管理工具生成配置...'
netplan generate
echo '使配置立即生效...'
netplan apply