From 9dfc148295480db6e1ea767656d95cbc5616be72 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 8 Jul 2023 16:02:06 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E6=B7=BB=E5=8A=A0=20http=20=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=AE=89=E8=A3=85=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/trans.sh b/trans.sh index e5e75f5..322bc28 100644 --- a/trans.sh +++ b/trans.sh @@ -1,16 +1,19 @@ #!/bin/ash # shellcheck shell=dash -# shellcheck disable=SC3047,SC3036,SC3010 +# shellcheck disable=SC3047,SC3036,SC3010,SC3001 # alpine 默认使用 busybox ash -# 命令出错退出脚本,进入到登录界面,防止失联 -# TODO: neet more test +# 命令出错终止运行,将进入到登录界面,防止失联 set -eE # 显示输出到前台 # 似乎script更优雅,但 alpine 不带 script 命令 -# script -f/dev/tty0 -exec >/dev/tty0 2>&1 +# script -f /dev/tty0 +if [ -e /dev/ttyS0 ]; then + exec > >(tee /dev/tty0 /dev/ttyS0 /reinstall.log) 2>&1 +else + exec > >(tee /dev/tty0 /reinstall.log) 2>&1 +fi trap 'error line $LINENO return $?' ERR catch() { @@ -22,7 +25,8 @@ catch() { error() { color='\e[31m' plain='\e[0m' - echo -e "${color}Error: $*$plain" + echo -e "${color}Error: $*${plain}" + wall "Error: $*" } add_community_repo() { @@ -81,6 +85,29 @@ is_efi() { [ -d /sys/firmware/efi/ ] } +setup_nginx() { + apk add nginx + cat </etc/nginx/http.d/default.conf + server { + listen 80 default_server; + listen [::]:80 default_server; + location = / { + root /; + try_files /reinstall.log /reinstall.log; + types { + text/plain log; + } + } + } +EOF + # rc-service nginx start + nginx +} +setup_lighttpd() { + apk add lighttpd + ln -sf /reinstall.log /var/www/localhost/htdocs/index.html + rc-service lighttpd start +} # 提取 finalos/extra 到变量 for prefix in finalos extra; do while read -r line; do @@ -94,6 +121,18 @@ $(xargs -n1