更新 install.sh

This commit is contained in:
星光-k
2025-01-10 10:41:48 +00:00
committed by GitHub
parent 2027604950
commit cd97843453

View File

@@ -43,10 +43,16 @@ if ! grep -q "^$DEFAULT_LANG UTF-8" /etc/locale.gen; then
fi fi
# 生成 locale # 生成 locale
locale-gen if ! locale-gen; then
echo "生成 locale 失败"
exit 1
fi
# 重新配置 locales # 重新配置 locales
dpkg-reconfigure --frontend=noninteractive locales if ! dpkg-reconfigure --frontend=noninteractive locales; then
echo "重新配置 locales 失败"
exit 1
fi
# 如果需要调试输出 # 如果需要调试输出
if [ "$DEBUG" = true ]; then if [ "$DEBUG" = true ]; then
@@ -108,7 +114,7 @@ install_packages() {
if [ "$DEBUG" = true ]; then if [ "$DEBUG" = true ]; then
echo "正在安装软件包..." echo "正在安装软件包..."
fi fi
sudo apt-get update && sudo apt-get install -y git pigpio raspi-config netcat* gawk python3-dev python3-pip python3-pil python3-numpy python3-gpiozero python3-pigpio build-essential screen sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y git pigpio raspi-config netcat* gawk python3-dev python3-pip python3-pil python3-numpy python3-gpiozero python3-pigpio build-essential screen
} }
# 安装pip包函数 # 安装pip包函数
@@ -116,7 +122,10 @@ install_pip_packages() {
if [ "$DEBUG" = true ]; then if [ "$DEBUG" = true ]; then
echo "正在安装pip软件包..." echo "正在安装pip软件包..."
fi fi
sudo pip3 install -i $PIPY_MIRROR spidev borax pillow requests if ! sudo pip3 install -i $PIPY_MIRROR spidev borax pillow requests; then
echo "pip软件包安装失败"
exit 1
fi
} }
# 复制服务文件并设置为开机启动 # 复制服务文件并设置为开机启动
@@ -124,9 +133,14 @@ setup_service() {
if [ "$DEBUG" = true ]; then if [ "$DEBUG" = true ]; then
echo "正在设置墨水屏时钟服务..." echo "正在设置墨水屏时钟服务..."
fi fi
if [ ! -d "$HOME/2.13-Ink-screen-clock" ]; then
cd ~ cd ~
git clone $INK_SCREEN_CLOCK_REPO_URL if ! git clone $INK_SCREEN_CLOCK_REPO_URL; then
if [ $? -eq 0 ]; then echo "克隆墨水屏时钟仓库失败"
exit 1
fi
fi
# 假设服务文件在仓库的 bin 文件夹下 # 假设服务文件在仓库的 bin 文件夹下
SERVICE_PATH="raspi_e-paper.service" SERVICE_PATH="raspi_e-paper.service"
SERVICE_FILE_PATH="$HOME/2.13-Ink-screen-clock/bin/$SERVICE_PATH" SERVICE_FILE_PATH="$HOME/2.13-Ink-screen-clock/bin/$SERVICE_PATH"
@@ -142,10 +156,6 @@ setup_service() {
echo "服务文件不存在于路径: $SERVICE_FILE_PATH" echo "服务文件不存在于路径: $SERVICE_FILE_PATH"
exit 1 exit 1
fi fi
else
echo "克隆墨水屏时钟仓库失败"
exit 1
fi
} }
# 主逻辑 # 主逻辑