禁用Ubuntu更新
This commit is contained in:
parent
8ddfdf4803
commit
fe4597d118
45
update_operator.sh
Executable file
45
update_operator.sh
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "Usage: $0 On|Off"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ACTION=$1
|
||||||
|
|
||||||
|
if [ "$ACTION" == "On" ]; then
|
||||||
|
# 启用unattended-upgrades服务
|
||||||
|
sudo systemctl enable unattended-upgrades.service
|
||||||
|
sudo systemctl start unattended-upgrades.service
|
||||||
|
|
||||||
|
# 启用APT定时服务
|
||||||
|
sudo systemctl enable apt-daily.timer
|
||||||
|
sudo systemctl start apt-daily.timer
|
||||||
|
sudo systemctl enable apt-daily-upgrade.timer
|
||||||
|
sudo systemctl start apt-daily-upgrade.timer
|
||||||
|
|
||||||
|
# 启用APT配置中的自动更新
|
||||||
|
sudo sed -i 's/"0"/"1"/' /etc/apt/apt.conf.d/20auto-upgrades
|
||||||
|
|
||||||
|
echo "Automatic updates have been enabled."
|
||||||
|
elif [ "$ACTION" == "Off" ]; then
|
||||||
|
# 禁用unattended-upgrades服务
|
||||||
|
sudo systemctl stop unattended-upgrades.service
|
||||||
|
sudo systemctl disable unattended-upgrades.service
|
||||||
|
|
||||||
|
# 禁用APT定时服务
|
||||||
|
sudo systemctl stop apt-daily.timer
|
||||||
|
sudo systemctl disable apt-daily.timer
|
||||||
|
sudo systemctl stop apt-daily-upgrade.timer
|
||||||
|
sudo systemctl disable apt-daily-upgrade.timer
|
||||||
|
|
||||||
|
# 禁用APT配置中的自动更新
|
||||||
|
sudo sed -i 's/"1"/"0"/' /etc/apt/apt.conf.d/20auto-upgrades
|
||||||
|
|
||||||
|
echo "Automatic updates have been disabled."
|
||||||
|
else
|
||||||
|
echo "Invalid argument: $ACTION"
|
||||||
|
echo "Usage: $0 On|Off"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user