很多地方要么信号不好,要么有“毒”,没有必要自动启动wifi,浪费电,又不安全等。
主要参考 https://askubuntu.com/questions/24171/
创建 /etc/init/radio-silence.conf 内容如下
代码: 全选
# radio-silence - Ensure radio silence on startup
#
# Override default startup behaviour of radios to ensure they are all
# disabled until the user deliberately enables them. This job requires
# radio-silence-wait to delay start of any services that may depend on
# resources manipulated by this job.
description "Disable all radios by default"
start on local-filesystems
pre-start script
#sed -i -re "s/^(.+[[:space:]]+)[01][[:space:]]*\$/\11/" /var/lib/rfkill/saved-state
sed -i -re "s/^(WirelessEnabled=).*\$/\1false/" /var/lib/NetworkManager/NetworkManager.state
end script
第二步 创建 /etc/init/radio-silence-wait.conf ,内容如下
代码: 全选
# radio-silence-wait - Helper task for radio-silence
#
# Delays the start of all jobs that may depend on resources manipulated
# by radio-silence job. Avoids the need to modify job configuration of
# those other jobs.
description "Assist radio-silence by delaying jobs it affects"
start on (starting rfkill-restore or starting network-manager)
stop on (started radio-silence or stopped radio-silence)
instance $JOB
normal exit 0 2
task
script
status radio-silence | grep -q "start/running" && exit 0
start radio-silence || true
sleep infinity
end script