运行此 bash 脚本一次会导致每次重启时都出现“检测到系统程序问题”

运行此 bash 脚本一次会导致每次重启时都出现“检测到系统程序问题”

我正在尝试创建一个脚本,当运行时,它将设置一个可让两个或更多设备进行通信的 WiFi 网络如果我运行此脚本的当前版本一次,它会导致该设备显示“检测到系统程序问题”弹出窗口每一个随后重新启动。

目前,这还不算灾难,只是令人恼火。但是,考虑到将来我可能会在几十台设备上运行此脚本,情况就不太理想了!

这是 bash 脚本:

#!/bin/bash

# Install required software.
sudo apt install dnsmasq
sudo apt install hostapd
sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

# Configure a static IP.
if ! python3 edit_dhcpcd_config.py ; then
  exit 1
fi

# Configure the DHCP server.
if [ ! -f /etc/dnsmasq.conf.orig ]; then
  sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
fi
if ! python3 edit_dnsmasq_config.py ; then
  exit 1
fi
if ! sudo systemctl start dnsmasq ; then
  exit 1
fi

# Configure the access point host software.
if ! python3 edit_hostapd_conf.py ; then
  exit 1
fi
if ! python3 edit_daemon_conf.py ; then
  exit 1
fi

# Start it up.
if ! sudo systemctl unmask hostapd ; then
  exit 1
fi
if ! sudo systemctl enable hostapd ; then
  exit 1
fi
if ! sudo systemctl start hostapd ; then
  exit 1
fi

echo "Mother network set up successfully."

# Check everything's up.
#sudo systemctl status hostapd
#sudo systemctl status dnsmasq

各种种类Python 脚本上面调用的只是代码片段,它们要么附加到各种 dnsmasq 和 hostapd 配置文件中,要么替换这些配置文件。如果需要,我很乐意发布这些文件。

答案1

这实际上是系统崩溃的通知。虽然在大多数情况下这并不严重,但你可以通过阅读 的输出来检查崩溃的原因ls -l /var/crash/

如果您发现崩溃的原因是您的脚本中的某个内容,则应该修改脚本并重试。

但是,如果您决定完全禁用崩溃报告,请按照以下说明操作,这样将来就不会再显示崩溃报告。


如果您愿意,可以通过编辑文件/etc/default/apport、更改并保存文件enabled=1来禁用崩溃报告。enabled=0

或者,您可以通过在脚本中添加以下行来执行此操作:

sudo sed -i 's/enabled=1/enabled=0/g' /etc/default/apport

祝你好运

答案2

现在看来,这个问题是由我的一个简单错误引起的,而不是更深层次的问题。当我测试“检测到系统程序问题”弹出窗口是否仍在出现时,reboot我从命令行运行。当我运行此程序时,某些窗口(通常是 Chromium)仍处于打开状态,因此必须比预期更快地关闭它们。一旦我在重新启动之前关闭所有打开的窗口,弹出窗口便不再出现。

相关内容