diff --git a/trans.sh b/trans.sh index 0d04fd5..ac04f9c 100644 --- a/trans.sh +++ b/trans.sh @@ -5,15 +5,6 @@ # 命令出错终止运行,将进入到登录界面,防止失联 set -eE - -# 显示输出到前台 -# 似乎script更优雅,但 alpine 不带 script 命令 -# 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() { @@ -91,35 +82,71 @@ setup_nginx() { server { listen 80 default_server; listen [::]:80 default_server; + location = / { root /; - try_files /reinstall.log /reinstall.log; - types { - text/plain log; - } + try_files /reinstall.html /reinstall.html; + # 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 + ln -sf /reinstall.html /var/www/localhost/htdocs/index.html rc-service lighttpd start } -# 提取 finalos/extra 到变量 -for prefix in finalos extra; do - while read -r line; do - if [ -n "$line" ]; then - key=$(echo $line | cut -d= -f1) - value=$(echo $line | cut -d= -f2-) - eval "$key='$value'" - fi - done </reinstall.html + + + + + + + + + +
+EOF
+    # 显示输出到前台
+    # 似乎script更优雅,但 alpine 不带 script 命令
+    # script -f /dev/tty0
+    if [ -e /dev/ttyS0 ]; then
+        exec > >(tee -a /dev/tty0 /dev/ttyS0 /reinstall.html) 2>&1
+    else
+        exec > >(tee -a /dev/tty0 /reinstall.html) 2>&1
+    fi
+}
+
+extract_env_from_cmdline() {
+    # 提取 finalos/extra 到变量
+    for prefix in finalos extra; do
+        while read -r line; do
+            if [ -n "$line" ]; then
+                key=$(echo $line | cut -d= -f1)
+                value=$(echo $line | cut -d= -f2-)
+                eval "$key='$value'"
+            fi
+        done <