diff --git a/static/404.html b/static/404.html new file mode 100644 index 0000000..48d74d7 --- /dev/null +++ b/static/404.html @@ -0,0 +1,17 @@ + + + + + +找不到页面 | 海纳思系统 + + + + + +
+
跳到主要内容

找不到页面

我们找不到您要找的页面。

请联系原始链接来源网站的所有者,并告知他们链接已损坏。

+ + + + \ No newline at end of file diff --git a/static/ad-form.html b/static/ad-form.html index a5086e5..3ac8432 100644 --- a/static/ad-form.html +++ b/static/ad-form.html @@ -102,7 +102,7 @@ document.write("您是到访的第" + visits + "位用户!")

diff --git a/static/ad.html b/static/ad.html new file mode 100644 index 0000000..3ac8432 --- /dev/null +++ b/static/ad.html @@ -0,0 +1,111 @@ + + + + +海纳思系统官方通告 + + + + + +
+

海纳思系统官方广告位招租

+
+ +

22000+装机数

+

日活6000+

+

日增约100台

+

要求:符合海纳思服务器的环境需求

+

捐助并投放,与作者共赢!请联系本站

+
+
+ + + + + +

+ + + + diff --git a/static/ad.jpg b/static/ad.jpg index 0b212f6..0696ad1 100644 Binary files a/static/ad.jpg and b/static/ad.jpg differ diff --git a/static/ad.pdf b/static/ad.pdf deleted file mode 100644 index 0f08576..0000000 Binary files a/static/ad.pdf and /dev/null differ diff --git a/static/ad_count.txt b/static/ad_count.txt new file mode 100644 index 0000000..f9b0327 --- /dev/null +++ b/static/ad_count.txt @@ -0,0 +1 @@ +815 \ No newline at end of file diff --git a/static/alist-histb-com/supersized-init.js b/static/alist-histb-com/supersized-init.js index 4a56722..afba8b4 100644 --- a/static/alist-histb-com/supersized-init.js +++ b/static/alist-histb-com/supersized-init.js @@ -20,10 +20,10 @@ jQuery(function($){ // 组件 slide_links : 'blank', // 个别环节为每张幻灯片(选项:假的,'民','名','空') slides : [ // 幻灯片影像 - {image : 'https://ecoo.top/alist-histb-com/1.jpg'}, - {image : 'https://ecoo.top/alist-histb-com/2.jpg'}, - {image : 'https://ecoo.top/alist-histb-com/3.jpg'}, - {image : 'https://ecoo.top/alist-histb-com/4.jpg'} + {image : 'https://www.ecoo.top/alist-histb-com/1.jpg'}, + {image : 'https://www.ecoo.top/alist-histb-com/2.jpg'}, + {image : 'https://www.ecoo.top/alist-histb-com/3.jpg'}, + {image : 'https://www.ecoo.top/alist-histb-com/4.jpg'} ] }); diff --git a/static/atfirst.html b/static/atfirst.html new file mode 100644 index 0000000..30044f3 --- /dev/null +++ b/static/atfirst.html @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + 刷机成功后第一步 + + + + + + + + + + + +
+ +
+ + + + + + + + + + + diff --git a/static/bj.jpg b/static/bj.jpg new file mode 100644 index 0000000..04255c4 Binary files /dev/null and b/static/bj.jpg differ diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..8f0e45a Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/findip.html b/static/findip.html new file mode 100644 index 0000000..a0be2f3 --- /dev/null +++ b/static/findip.html @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + 刷机后IP连接 + + + + + + + + + + + +
+ +
+ + + + + + + + + + + diff --git a/static/flashstyle.html b/static/flashstyle.html new file mode 100644 index 0000000..7092291 --- /dev/null +++ b/static/flashstyle.html @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + 选择哪种方式刷入海思设备 + + + + + + + + + + + +
+ +
+ + + + + + + + + + + diff --git a/static/getreg.html b/static/getreg.html new file mode 100644 index 0000000..3cd3e21 --- /dev/null +++ b/static/getreg.html @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + 如何获得海思设备reg名称 + + + + + + + + + + + +
+ +
+ + + + + + + + + + + diff --git a/static/hiop.sh b/static/hiop.sh new file mode 100755 index 0000000..a7fdc88 --- /dev/null +++ b/static/hiop.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +ARCH_BIT=$(getconf LONG_BIT) +[ "$ARCH_BIT" = "32" ] && ARCH="armhf" || ARCH="arm64" + +dl_url="https://dl.ecoo.top/update/system" +declare -a system_versions +system_versions=( + [1]="海纳思Hi-OpenWrt固件 openwrt-armvirt-${ARCH_BIT}-root.ext4.gz" + [2]="海纳思NAS完整版固件 Ubuntu-20.04.5-${ARCH}.gz" +) + +readonly COLOUR_RESET='\e[0m' +declare -A COLORS +COLORS=( + ["red"]='\e[91m' + ["green"]='\e[32;1m' + ["yellow"]='\e[33m' +) + +printStr() { + color=$1 + printf ${COLORS[${color}]}"$2"${COLOUR_RESET}"\n" +} + +_exit() { + exit_singal=$1 + shift + [ "$exit_singal" != "0" ] && printStr red "$*" || printStr green "$*" + exit $exit_singal +} + +get_md5() { + case $1 in + -c) + shift + wget -q $1 -O - | grep $2 | awk '{print $1}' + ;; + -l) + shift + [ ! -f "$1" ] && return 1 + md5sum $1 2> /dev/null | awk '{print $1}' + ;; + esac +} + +echo " ++---------------------------------------------------------------------- +| 海纳思hi-op固件切换专用脚本温馨提示: ++---------------------------------------------------------------------- +| 切换后原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +#nasversion=`cat /etc/nasversion` +#if [ $nasversion != "20230401" ];then +# _exit 1 "请使用最新20230401系统!" +#fi + +for index in "${!system_versions[@]}"; do + printStr green "$index. $(echo ${system_versions[$index]}|awk '{print $1}')" +done + +while :; do + printStr yellow "你想要安装哪个版本? 输入数字后按回车确定:" + read version_number + for index in "${!system_versions[@]}"; do + if [ "$version_number" = "$index" ]; then + selected_version="$(echo ${system_versions[$index]}|awk '{print $1}')" + dlfile="$(echo ${system_versions[$index]}|awk '{print $2}')" + break 2 + fi + done +done + +wget -q --show-progress --no-check-certificate ${dl_url}/${dlfile} -O /tmp/${dlfile} || _exit 1 "下载失败,请重试" +[ "$(get_md5 -c ${dl_url}/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /tmp/${dlfile})" ] && _exit 1 "文件校验失败,请重试" + +mv /tmp/${dlfile} /tmp/backup-${ARCH_BIT}.gz +mkdir -p /tmp/backup +mount /dev/mmcblk0p8 /tmp/backup +if [ ! -f /tmp/backup/backup-${ARCH_BIT}1.gz ]; then + mv /tmp/backup/backup-${ARCH_BIT}.gz /tmp/backup/backup-${ARCH_BIT}1.gz +fi +mv /tmp/backup-${ARCH_BIT}.gz /tmp/backup +sync +umount /tmp/backup + +printStr yellow " +============================================================== +配置已完成,盒子正在重启并准备初始化中, +若5分钟后还没有获得ip,请手动重启盒子,并继续稍等初始化结束 +==============================================================" +recoverbackup diff --git a/static/hitool.html b/static/hitool.html new file mode 100644 index 0000000..6b35cbd --- /dev/null +++ b/static/hitool.html @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + +华为海思刷机工具Hitool使用指南 + + + +

华为海思刷机工具TTL刷机教程

+

它有另外一个昵称叫“海兔”。 +本站提供windows和linux版本的下载:

+ + + + + + + + + + + + + + + + +
平台国内高速下载地址备用海外下载地址
windows海兔工具windows版https://oss.histb.com/HiTool-windows.7z
linux海兔工具linux版https://oss.histb.com/hitool_linux.tar.gz
+

使用教程:

+

一.参阅华为官方的pdf文档:HiBurn.pdfHiTool.pdf

+

二.windows版无需安装,解压后打开hitool.exe即可使用。

+

三.刷入海思机顶盒NAS系统注意事项:

+

(a.)请首先关闭防火墙,杀软等阻拦69端口通讯的设置。

+

(b.)其次严格按照TTL刷机图的几个要点进行配置。

+

(c.)USB-TTL转接板最好用免驱的CH340,淘宝价大约8元左右包邮,含杜邦线和排针。

+

+

+

(d.)只接上GDN,TX,RX三个点即可,瞎接VCC可能会导致烧坏板子。

+

(e.)请使用3.3V的转接器跳线连接。

+

第1步.TTL跑码以获得机顶盒的芯片(CPU)和元件管脚参数(reg name):或参考其它方法获得reg名称

+

+

第2步.参考神雕开发的设备适配表,查看你的设备需要下载的固件:

+

适配表:https://www.ecoo.top/histb.html

+

固件下载:https://dl.ecoo.top

+

第3步.根据自己盒子的芯片型号来操作Hitool进行固件烧写:

+

+

+

最后:在路由器管理页面,查找路由器自动分配给盒子的IP,浏览器输入IP地址进入盒子首页。

+

注意:

+

hi3798m默认型号的mac是00:11:22:33:44:55

+ +

四.常见问题解答

+

1.无法下载fastboot,多数是因为TTL线跟电脑hitool工具之间通讯不良造成的。

+

检查排针是否牢牢的稳固的插好在板子上,

+

检查杜邦线是否有问题, + 检查板子的GDN,TX,RX是否正确排序。(TX,RX需要对调)

+

2.端口被占用,请关闭其它使用串口的连接。

+

3.刷完fastboot,一直停留在TTTT符号,没有接好网线,或者网络不通,或者防火墙没有关闭。

+

4.fastboot选对了,但是刷不进去,或者刷入失败,检查是否高安板,高安请放弃。 + 检查是否NAND内存,NAND板请放弃。

+

5.部分盒子由于厂家设置了TTL阻断,需要飞线或者重新加电阻接通才会正常使用。

+

6.更多疑难问题,请到社区bbs.histb.com求助。

+

本文ecoo.top版权所有。

+ + + + + diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..2ca085c --- /dev/null +++ b/static/index.html @@ -0,0 +1,17 @@ + + + + + +e酷网 海纳思系统 | 海纳思系统 + + + + + +
+
跳到主要内容

海思芯片 Hisilicon 系列

已开发适配的海思芯片机顶盒,CPU型号为 hi3798mv1xx,hi3798mv2xx,hi3798mv3xx

晶晨芯片 Amlogic 系列

已开发适配 S805 玩客云盒子,晶晨芯片的盒子后续 S905 陆续推出。

x86 系列

即将推出 x86 机型的海纳思系统。

海纳思系统专业版

包含wifi功能,打印功能,内网穿透的专业版。
更多详情

海纳思宝塔专用版

内置宝塔程序,预编译并内置全家桶 LNMP 套件。
更多详情

海纳思网心云专用版

可以赚点小钱钱的系统,优化后运行容器魔方镜像。
更多详情

开源,免费,易用的家用 Linux 服务器系统

海纳思系统,一个基于开源 Linux Ubuntu 20.04 LTS 打造的 NAS 系统,
开发者精心打造,已开发和内置丰富的程序和功能,内网穿透,网盘共享,
远程下载,Docker安装,个人博客,网络建站,socks5服务,ftp上传下载,
webdav接口,终端控制,一键还原,计划任务等等。

Policy Persistence
homepage

将千家万户的机顶盒打造成一台超低功耗的 Linux 服务器

实测功耗约为 3 瓦, 3x24x365÷1000x0.7≈18元/年,一杯奶茶钱,养活它一年。
普遍盒子4核心CPU,内核频率高达1.4GHz-1.6GHz,流畅运行各项 NAS 程序。
作为家用存储机,Linux 学习机,学生技术孵化机,网络下载机,组网跳板机,均可。
应用于网页建站,内网穿越,公网映射,科学上网,跑脚本,定时任务等,更佳。
我是小盒子,也是大世界!千家万户都有一个机顶盒,开启您的探索之旅!

+ + + + \ No newline at end of file diff --git a/static/iptv.txt b/static/iptv.txt new file mode 100644 index 0000000..9598996 --- /dev/null +++ b/static/iptv.txt @@ -0,0 +1,34 @@ +CCTV-1,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001022/index.m3u8 +CCTV-2,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001220/index.m3u8 +CCTV-3,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001186/index.m3u8 +CCTV-4 中文卫视频道,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001221/index.m3u8 +CCTV-5 体育,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001187/index.m3u8 +CCTV-5+ 体育赛事,http://iptvrr.sh.chinamobile.com:6060/yinhe/2/ch00000090990000001334/index.m3u8?virtualDomain=yinhe.live_hls.zte.com +CCTV-6 电影,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001188/index.m3u8 +CCTV-7 国防军事,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001236/index.m3u8 +CCTV-8 电视剧,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001189/index.m3u8 +CCTV-9 纪录,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001237/index.m3u8 +CCTV-10 科教,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001238/index.m3u8 +CCTV-11 戏曲,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001309/index.m3u8 +CCTV-12 社会与法,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001239/index.m3u8 +CCTV-13 新闻,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001328/index.m3u8 +CCTV-14 少儿,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001240/index.m3u8 +CCTV-15 音乐,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001338/index.m3u8 +CCTV-16 奥林匹克,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001258/index.m3u8 +CCTV-17 农业农村,http://iptvrr.sh.chinamobile.com:6060/cms001/ch00000090990000001241/index.m3u8 +CCTV1,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225804/index.m3u8 +CCTV2,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226195/index.m3u8 +CCTV2,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226224/index.m3u8 +CCTV3,http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888888/224/3221226397/1.m3u8 +CCTV4,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226191/index.m3u8 +CCTV5,http://39.134.24.161/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226395/index.m3u8 +CCTV5+,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225761/index.m3u8 +CCTV6,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226393/index.m3u8 +CCTV7,http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226192/index.m3u8 +CCTV8,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226012/index.m3u8 +CCTV9,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226197/index.m3u8 +CCTV10,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226189/index.m3u8 +CCTV13,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226233/index.m3u8 +CCTV14,http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226193/index.m3u8 +CCTV15,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225785/index.m3u8 +CCTV16,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226921/index.m3u8 \ No newline at end of file diff --git a/static/ms79565163.txt b/static/ms79565163.txt new file mode 100644 index 0000000..d96e885 --- /dev/null +++ b/static/ms79565163.txt @@ -0,0 +1,5 @@ +{ + "Description": "Microsoft 365 的域所有权验证文件 - 放置在网站根目录中", + "Domain": "ecoo.top", + "Id": "23d5e5c4-937c-4a7c-8175-5f5b9ad9c12a" +} \ No newline at end of file diff --git a/static/mv100-bt.sh b/static/mv100-bt.sh new file mode 100755 index 0000000..a965752 --- /dev/null +++ b/static/mv100-bt.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +declare -a system_versions +system_versions=( + [1]='海纳思NAS社区版固件 Ubuntu-20.04.5-armhf.gz' + [2]='海纳思宝塔付费专用固件 Ubuntu-bt-armhf.gz' +) + +echo " ++---------------------------------------------------------------------- +| 海纳思系统固件切换专用脚本温馨提示: ++---------------------------------------------------------------------- +| 切换后原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" + +temp_file=$(mktemp) +curl -sSL https://hi.ecoo.top/mirror-utils.sh > $temp_file +if [ ! -f /etc/public-download.sh ] || [ "$(cat $temp_file|md5sum|awk '{print $1}')" != "$(cat /etc/public-download.sh|md5sum|awk '{print $1}')" ]; then + cp $temp_file /etc/public-download.sh +fi +rm -f $temp_file +source /etc/public-download.sh + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +date_20230818=$(date -d '20230818' +%s) +if [ $(date -d $(cat /etc/nasversion) +%s) -lt ${date_20230818} ]; then + _exit 1 "请升级到 20230818 或更新的版本后再执行此命令!" +fi + +#if [ $(df -T|grep /tmp|awk '{print int($5)}') -lt 358400 ]; then +# printStr red "临时目录 /tmp 剩余空间小于350M!" +# printStr red "请执行扩容命令并执行 reboot 重启后再执行本升级命令!" +# printStr yellow " tmp扩容命令:" +# printStr green " sed -i \"s|^tmpfs.*\$|tmpfs /tmp tmpfs defaults,nosuid,size=500M 0 0|g\" /etc/fstab" +# _exit 1 +#fi + +is64bit=$(getconf LONG_BIT) +if [ "${is64bit}" != '32' ];then + _exit 1 "抱歉, 当前系统切换版本不支持64位系统, 请使用32位系统!"; +fi + +for index in "${!system_versions[@]}"; do + printStr green "$index. $(echo ${system_versions[$index]}|awk '{print $1}')" +done + +while :; do + printStr yellow "你想要安装哪个版本? 输入数字后按回车确定:" + read version_number + for index in "${!system_versions[@]}"; do + if [ "$version_number" = "$index" ]; then + selected_version="$(echo ${system_versions[$index]}|awk '{print $1}')" + dlfile="$(echo ${system_versions[$index]}|awk '{print $2}')" + break 2 + fi + done +done + +printStr yellow "检测并选定下载节点..." +get_mirror_url + +rm -rf /tmp/* +printStr yellow "下载刷机包..." +dl_get update/system/${dlfile} /root/${dlfile} +[ "$(get_md5 -c ${NODE_URL}/update/system/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /root/${dlfile})" ] && _exit 1 "文件校验失败,请重试" +printStr green "正在配置系统,请稍后..." +mv /root/${dlfile} /root/backup-32.gz +mkdir -p /tmp/backup +mount /dev/mmcblk0p8 /tmp/backup +mv /root/backup-32.gz /tmp/backup +sync +umount /tmp/backup + +printStr yellow " +============================================================== +配置已完成,盒子正在重启并准备初始化中, +若5分钟后还没有获得ip,请手动重启盒子,并继续稍等初始化结束 +==============================================================" +recoverbackup -a diff --git a/static/mv100-wx.sh b/static/mv100-wx.sh new file mode 100755 index 0000000..b3d4180 --- /dev/null +++ b/static/mv100-wx.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +declare -a system_versions +system_versions=( + [1]='海思机顶盒网心云专用固件 onething-32.gz' + [2]='海纳思系统 Ubuntu-20.04.5-armhf.gz' +) + +echo " ++---------------------------------------------------------------------- +| 海纳思系统网心云固件切换专用脚本温馨提示: ++---------------------------------------------------------------------- +| 切换后原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" + +temp_file=$(mktemp) +curl -sSL https://hi.ecoo.top/mirror-utils.sh > $temp_file +if [ ! -f /etc/public-download.sh ] || [ "$(cat $temp_file|md5sum|awk '{print $1}')" != "$(cat /etc/public-download.sh|md5sum|awk '{print $1}')" ]; then + cp $temp_file /etc/public-download.sh +fi +rm -f $temp_file +source /etc/public-download.sh + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +#nasversion=`cat /etc/nasversion` +#if [ $nasversion != "20230701" ];then +# _exit 1 "请使用最新20230701系统!网站公告有升级方法。" +#fi + +is64bit=$(getconf LONG_BIT) +if [ "${is64bit}" != '32' ];then + _exit 1 "抱歉, 当前系统切换版本不支持64位系统, 请使用32位系统!"; +fi + +for index in "${!system_versions[@]}"; do + printStr green "$index. $(echo ${system_versions[$index]}|awk '{print $1}')" +done + +while :; do + printStr yellow "你想要安装哪个版本? 输入数字后按回车确定:" + read version_number + for index in "${!system_versions[@]}"; do + if [ "$version_number" = "$index" ]; then + selected_version="$(echo ${system_versions[$index]}|awk '{print $1}')" + dlfile="$(echo ${system_versions[$index]}|awk '{print $2}')" + break 2 + fi + done +done + +printStr yellow "检测并选定下载节点..." +get_mirror_url + +printStr yellow "下载刷机包..." +dl_get update/system/${dlfile} /root/${dlfile} +[ "$(get_md5 -c ${NODE_URL}/update/system/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /root/${dlfile})" ] && _exit 1 "文件校验失败,请重试" + +mv /root/${dlfile} /root/backup-32.gz +mkdir -p /root/backup +mount /dev/mmcblk0p8 /root/backup +mv /root/backup-32.gz /root/backup +sync +umount /root/backup + +printStr yellow " +============================================================== +配置已完成,盒子正在重启并准备初始化中, +若5分钟后还没有获得ip,请手动重启盒子,并继续稍等初始化结束 +==============================================================" +recoverbackup -a diff --git a/static/mv100_upgrade.sh b/static/mv100_upgrade.sh new file mode 100755 index 0000000..9aff4bd --- /dev/null +++ b/static/mv100_upgrade.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +dlfile="mv100-99.flash.gz" + +echo " ++---------------------------------------------------------------------- +| 海纳思系统hi3798mv100升级系统专用脚本温馨提示: ++---------------------------------------------------------------------- +| 此专用脚本可以让你在任意版本的NAS系统下一键升级到20240201, ++---------------------------------------------------------------------- +| 升级20240201版专用,原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" +read -p "继续执行?[y/n]: " result +[ "${result^^}" != "Y" ] && exit + +temp_file=$(mktemp) +curl -sSL https://hi.ecoo.top/mirror-utils.sh > $temp_file +if [ ! -f /etc/public-download.sh ] || [ "$(cat $temp_file|md5sum|awk '{print $1}')" != "$(cat /etc/public-download.sh|md5sum|awk '{print $1}')" ]; then + cp $temp_file /etc/public-download.sh +fi +rm -f $temp_file +source /etc/public-download.sh + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换用户!" +fi + +model=$(cpuid) +platform=hi3798mv100 + +if [ "$(echo ${model})" != "$platform" ];then + _exit 1 "本升级程序仅支持${platform}机型!" +fi + +promode=$(uname -r|cut -c 13-) +if [ $promode = 16010066 ];then + _exit 1 "专业版用户请使用vipupgrade命令进行升级!" +fi + +space_left=$(df -hT|grep /dev/root|awk '{print $4}') +if [ "$(expr $(echo ${space_left%%G}) \> 1)" != 1 ];then + _exit 1 "请确保剩余空间大于1G!" +fi + +printStr yellow "检测并选定下载节点..." +get_mirror_url + +printStr yellow "下载刷机包..." +dl_get update/system/${dlfile} /${dlfile} +printStr yellow "校验刷机包..." +echo "${NODE_URL}/update/system/${dlfile}.md5sum" +[ "$(get_md5 -c ${NODE_URL}/update/system/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /${dlfile})" ] && _exit 1 "文件校验失败,请重试" +printStr green "下载完成!" + +printStr yellow "刷机中,请勿断电..." +gunzip -c /${dlfile} | dd of=/dev/mmcblk0 bs=1024 seek=1024 status=progress conv=sync + +[[ $? == 0 ]] && printStr yellow " +============================================================== +恭喜刷机已完成,系统重启中,待初始化5-8分钟结束后即可登录。 +==============================================================" && reboot || \ + _exit 1 "刷机失败" \ No newline at end of file diff --git a/static/mv200_upgrade.sh b/static/mv200_upgrade.sh new file mode 100755 index 0000000..97e91e1 --- /dev/null +++ b/static/mv200_upgrade.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +if [ -f /sys/firmware/devicetree/base/my_board_info/custom_id ];then + custom_id=$(tr -d '\0' < /sys/firmware/devicetree/base/my_board_info/custom_id) + if [ "${custom_id}" = "n2ns1" ];then + dlfile="n2-99.flash.gz" + fi +else + dlfile="mv200-99.flash.gz" +fi + +echo " ++---------------------------------------------------------------------- +| 海纳思系统hi3798mv200升级系统专用脚本温馨提示: ++---------------------------------------------------------------------- +| 此专用脚本可以让你在任意版本的NAS系统下一键升级到20240201, ++---------------------------------------------------------------------- +| 升级20240201版专用,原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" +read -p "继续执行?[y/n]: " result +[ "${result^^}" != "Y" ] && exit + +temp_file=$(mktemp) +curl -sSL https://hi.ecoo.top/mirror-utils.sh > $temp_file +if [ ! -f /etc/public-download.sh ] || [ "$(cat $temp_file|md5sum|awk '{print $1}')" != "$(cat /etc/public-download.sh|md5sum|awk '{print $1}')" ]; then + cp $temp_file /etc/public-download.sh +fi +rm -f $temp_file +source /etc/public-download.sh + +model=$(cpuid) +platform=hi3798mv200 + +if [ "$(echo ${model})" != "$platform" ];then + _exit 1 "本升级程序仅支持${platform}机型!" +fi + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +is64bit=$(getconf LONG_BIT) +if [ "${is64bit}" != '64' ];then + _exit 1 "抱歉, 当前系统切换版本不支持32位系统, 请使用64位系统!"; +fi +promode=$(uname -r|cut -c 13-) +if [ $promode = 26010066 ];then + _exit 1 "专业版用户请使用vipupgrade命令进行升级!" +fi +#nasversion=`cat /etc/nasversion` +#if [ $nasversion = "20230101" ];then +# _exit 1 "已经是20230101最新版,无需升级系统!" +#fi + +space_left=$(df -hT|grep /dev/root|awk '{print $4}') +if [ "$(expr $(echo ${space_left%%G}) \> 1)" != 1 ];then + _exit 1 "请确保剩余空间大于1G!" +fi + +printStr yellow "检测并选定下载节点..." +get_mirror_url + +printStr yellow "下载刷机包..." +dl_get update/system/${dlfile} /${dlfile} +printStr yellow "校验刷机包..." +[ "$(get_md5 -c ${NODE_URL}/update/system/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /${dlfile})" ] && _exit 1 "文件校验失败,请重试" +printStr green "下载完成!" + +printStr yellow "刷机中,请勿断电..." +gunzip -c /${dlfile} | dd of=/dev/mmcblk0 bs=1024 seek=1024 status=progress conv=sync + +[[ $? == 0 ]] && printStr yellow " +============================================================== +刷机已完成,请手工关闭电源并再次开启,等待初始化5-8分钟即可。 +==============================================================" && reboot || \ + _exit 1 "刷机失败" + diff --git a/static/mv23-basic.sh b/static/mv23-basic.sh new file mode 100755 index 0000000..cd2b69b --- /dev/null +++ b/static/mv23-basic.sh @@ -0,0 +1,134 @@ +#!/bin/bash + +declare -A dl_mirrors +dl_mirrors=( + ["neimeng"]="https://node.histb.com:9088/update/system" + ["hunan"]="https://node3.histb.com:9088/update/system" + ["hongkong"]="https://node2.histb.com/update/system" + ["dl"]="https://dl.ecoo.top/update/system" +) + +declare -a system_versions +system_versions=( + [1]='海纳思NAS社区版固件 Ubuntu-20.04.5-arm64.gz' + [2]='海纳思纯净版固件 basic-hinas-64.gz' +) + +readonly COLOUR_RESET='\e[0m' +declare -A COLORS +COLORS=( + ["red"]='\e[91m' + ["green"]='\e[32;1m' + ["yellow"]='\e[33m' +) + +printStr() { + color=$1 + printf ${COLORS[${color}]}"$2"${COLOUR_RESET}"\n" +} + +_exit() { + exit_singal=$1 + shift + [ "$exit_singal" != "0" ] && printStr red "$*" || printStr green "$*" + exit $exit_singal +} + +get_mirror_url() { + tmp_file=/dev/shm/net_test.pl + [ -f "${tmp_file}" ] && rm -f ${tmp_file} + touch $tmp_file + + for mirror_name in ${!dl_mirrors[*]}; do + mirror_url=${dl_mirrors[$mirror_name]} + NODE_CHECK=$(curl -k -L --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${mirror_url}/net_test|xargs) + NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $2}') + TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $3 * 1000 }'|cut -d '.' -f 1) + if [ "${NODE_STATUS}" == "200" ];then + echo "$TIME_TOTAL $mirror_name $mirror_url" >> $tmp_file + fi + done + + NODE_NAME=$(cat $tmp_file|sort -g -t " " -k 1|head -n 1|awk '{print $2}') + NODE_URL=$(cat $tmp_file|sort -g -t " " -k 1|head -n 1|awk '{print $3}') + printStr green "using mirror: $NODE_NAME" + rm -f $tmp_file +} + +get_md5() { + case $1 in + -c) + shift + wget -4 -q --no-check-certificate $1 -O - | grep $2 | awk '{print $1}' + ;; + -l) + shift + [ ! -f "$1" ] && return 1 + md5sum $1 2> /dev/null | awk '{print $1}' + ;; + esac +} + +echo " ++---------------------------------------------------------------------- +| 海纳思系统固件切换专用脚本温馨提示: ++---------------------------------------------------------------------- +| 切换后原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +date_20230818=$(date -d '20230818' +%s) +if [ $(date -d $(cat /etc/nasversion) +%s) -lt ${date_20230818} ]; then + _exit 1 "请升级到 20230818 或更新的版本后再执行此命令!" +fi + +if [ $(df -T|grep /tmp|awk '{print int($5)}') -lt 358400 ]; then + rm -rf /tmp/* +fi + +is64bit=$(getconf LONG_BIT) +if [ "${is64bit}" != '64' ];then + _exit 1 "抱歉, 当前系统切换版本不支持32位系统, 请使用64位系统!"; +fi + +for index in "${!system_versions[@]}"; do + printStr green "$index. $(echo ${system_versions[$index]}|awk '{print $1}')" +done + +while :; do + printStr yellow "你想要安装哪个版本? 输入数字后按回车确定:" + read version_number + for index in "${!system_versions[@]}"; do + if [ "$version_number" = "$index" ]; then + selected_version="$(echo ${system_versions[$index]}|awk '{print $1}')" + dlfile="$(echo ${system_versions[$index]}|awk '{print $2}')" + break 2 + fi + done +done +echo "正在检测最快节点服务器" +get_mirror_url +[ -z ${NODE_URL} ] && _exit 1 "所有下载节点服务器网络不可达,稍后再试,或联系群主修复。" +rm -rf /tmp/* +wget -4 -q --show-progress --no-check-certificate ${NODE_URL}/${dlfile} -O /root/${dlfile} || _exit 1 "下载失败,请重试" +[ "$(get_md5 -c ${NODE_URL}/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /root/${dlfile})" ] && _exit 1 "文件校验失败,请重试" +printStr green "正在配置系统,请稍后..." +mv /root/${dlfile} /root/backup-64.gz +mkdir -p /tmp/backup +mount /dev/mmcblk0p8 /tmp/backup +mv /root/backup-64.gz /tmp/backup +sync +umount /tmp/backup + +printStr yellow " +============================================================== +配置已完成,盒子正在重启并准备初始化中, +请关闭电源重新上电,8分钟后手动重启电源第二次,并继续稍等初始化结束 +==============================================================" +recoverbackup -a diff --git a/static/mv23-bt.sh b/static/mv23-bt.sh new file mode 100755 index 0000000..1563848 --- /dev/null +++ b/static/mv23-bt.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +declare -a system_versions +system_versions=( + [1]='海纳思NAS社区版固件 Ubuntu-20.04.5-arm64.gz' + [2]='海纳思宝塔收费专用固件 Ubuntu-bt-arm64.gz' +) + +echo " ++---------------------------------------------------------------------- +| 海纳思系统固件切换专用脚本温馨提示: ++---------------------------------------------------------------------- +| 切换后原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" + +temp_file=$(mktemp) +curl -sSL https://hi.ecoo.top/mirror-utils.sh > $temp_file +if [ ! -f /etc/public-download.sh ] || [ "$(cat $temp_file|md5sum|awk '{print $1}')" != "$(cat /etc/public-download.sh|md5sum|awk '{print $1}')" ]; then + cp $temp_file /etc/public-download.sh +fi +rm -f $temp_file +source /etc/public-download.sh + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +date_20230818=$(date -d '20230818' +%s) +if [ $(date -d $(cat /etc/nasversion) +%s) -lt ${date_20230818} ]; then + _exit 1 "请升级到 20230818 或更新的版本后再执行此命令!" +fi + +if [ $(df -T|grep /tmp|awk '{print int($5)}') -lt 358400 ]; then + rm -rf /tmp/* +fi + +is64bit=$(getconf LONG_BIT) +if [ "${is64bit}" != '64' ];then + _exit 1 "抱歉, 当前系统切换版本不支持32位系统, 请使用64位系统!"; +fi + +for index in "${!system_versions[@]}"; do + printStr green "$index. $(echo ${system_versions[$index]}|awk '{print $1}')" +done + +while :; do + printStr yellow "你想要安装哪个版本? 输入数字后按回车确定:" + read version_number + for index in "${!system_versions[@]}"; do + if [ "$version_number" = "$index" ]; then + selected_version="$(echo ${system_versions[$index]}|awk '{print $1}')" + dlfile="$(echo ${system_versions[$index]}|awk '{print $2}')" + break 2 + fi + done +done + +printStr yellow "检测并选定下载节点..." +get_mirror_url + +rm -rf /tmp/* +printStr yellow "下载刷机包..." +dl_get update/system/${dlfile} /root/${dlfile} +[ "$(get_md5 -c ${NODE_URL}/update/system/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /root/${dlfile})" ] && _exit 1 "文件校验失败,请重试" +printStr green "正在配置系统,请稍后..." +mv /root/${dlfile} /root/backup-64.gz +mkdir -p /tmp/backup +mount /dev/mmcblk0p8 /tmp/backup +mv /root/backup-64.gz /tmp/backup +sync +umount /tmp/backup + +printStr yellow " +============================================================== +配置已完成,盒子正在重启并准备初始化中, +请关闭电源重新上电,8分钟后手动重启电源第二次,并继续稍等初始化结束 +==============================================================" +recoverbackup -a diff --git a/static/mv23-wx.sh b/static/mv23-wx.sh new file mode 100755 index 0000000..b89c249 --- /dev/null +++ b/static/mv23-wx.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +dl_url="https://node.histb.com:9088/update/system" +declare -a system_versions +system_versions=( + [1]='网心云专用固件 onething-64.gz' + [2]='海纳思NAS系统固件 Ubuntu-20.04.5-arm64.gz' +) + +echo " ++---------------------------------------------------------------------- +| 海纳思系统网心云固件切换专用脚本温馨提示: ++---------------------------------------------------------------------- +| 切换后原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" + +temp_file=$(mktemp) +curl -sSL https://hi.ecoo.top/mirror-utils.sh > $temp_file +if [ ! -f /etc/public-download.sh ] || [ "$(cat $temp_file|md5sum|awk '{print $1}')" != "$(cat /etc/public-download.sh|md5sum|awk '{print $1}')" ]; then + cp $temp_file /etc/public-download.sh +fi +rm -f $temp_file +source /etc/public-download.sh + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +nasversion=`cat /etc/nasversion` +#if [ $nasversion != "20230818" ];then +# _exit 1 "请使用最新20230818系统!" +#fi + +is64bit=$(getconf LONG_BIT) +if [ "${is64bit}" != '64' ];then + _exit 1 "抱歉, 当前系统切换版本不支持32位系统, 请使用64位系统!"; +fi + +for index in "${!system_versions[@]}"; do + printStr green "$index. $(echo ${system_versions[$index]}|awk '{print $1}')" +done + +while :; do + printStr yellow "你想要安装哪个版本? 输入数字后按回车确定:" + read version_number + for index in "${!system_versions[@]}"; do + if [ "$version_number" = "$index" ]; then + selected_version="$(echo ${system_versions[$index]}|awk '{print $1}')" + dlfile="$(echo ${system_versions[$index]}|awk '{print $2}')" + break 2 + fi + done +done + +printStr yellow "检测并选定下载节点..." +get_mirror_url + +printStr yellow "下载刷机包..." +dl_get update/system/${dlfile} /tmp/${dlfile} +[ "$(get_md5 -c ${NODE_URL}/update/system/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /tmp/${dlfile})" ] && _exit 1 "文件校验失败,请重试" + +mv /tmp/${dlfile} /tmp/backup-64.gz +mkdir -p /tmp/backup +mount /dev/mmcblk0p8 /tmp/backup +mv /tmp/backup-64.gz /tmp/backup +sync +umount /tmp/backup + +printStr yellow " +============================================================== +配置已完成,盒子正在重启并准备初始化中, +若5分钟后还没有获得ip,请手动重启盒子,并继续稍等初始化结束 +==============================================================" +recoverbackup diff --git a/static/mv300_upgrade.sh b/static/mv300_upgrade.sh new file mode 100755 index 0000000..a4353c6 --- /dev/null +++ b/static/mv300_upgrade.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +dlfile="mv300-99.flash.gz" # 文件路径 + +echo " ++---------------------------------------------------------------------- +| 海纳思系统hi3798mv300升级系统专用脚本温馨提示: ++---------------------------------------------------------------------- +| 此专用脚本可以让你在任意版本的NAS系统下一键升级到20240201, ++---------------------------------------------------------------------- +| 升级20240201版专用,原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" +read -p "继续执行?[y/n]: " result +[ "${result^^}" != "Y" ] && exit + +temp_file=$(mktemp) +curl -sSL https://hi.ecoo.top/mirror-utils.sh > $temp_file +if [ ! -f /etc/public-download.sh ] || [ "$(cat $temp_file|md5sum|awk '{print $1}')" != "$(cat /etc/public-download.sh|md5sum|awk '{print $1}')" ]; then + cp $temp_file /etc/public-download.sh +fi +rm -f $temp_file +source /etc/public-download.sh + +model=$(cpuid) +platform=hi3798mv300 + +if [ "$(echo ${model})" != "$platform" ];then + _exit 1 "本升级程序仅支持${platform}机型!" +fi + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +is64bit=$(getconf LONG_BIT) +if [ "${is64bit}" != '64' ];then + _exit 1 "抱歉, 当前系统切换版本不支持32位系统, 请使用64位系统!"; +fi + +promode=$(uname -r|cut -c 13-) +if [ $promode = 36010066 ];then + _exit 1 "专业版用户请使用vipupgrade命令进行升级!" +fi +#nasversion=`cat /etc/nasversion` +#if [ $nasversion = "20230101" ];then +# _exit 1 "已经是20230101最新版,无需升级系统!" +#fi + +space_left=$(df -hT|grep /dev/root|awk '{print $4}') +if [ "$(expr $(echo ${space_left%%G}) \> 1)" != 1 ];then + _exit 1 "请确保剩余空间大于1G!" +fi + +printStr yellow "检测并选定下载节点..." +get_mirror_url + + +printStr yellow "下载刷机包..." +dl_get update/system/${dlfile} /${dlfile} +printStr yellow "校验刷机包..." +[ "$(get_md5 -c ${NODE_URL}/update/system/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /${dlfile})" ] && _exit 1 "文件校验失败,请重试" +printStr green "下载完成!" + +printStr yellow "刷机中,请勿断电..." +gunzip -c /${dlfile} | dd of=/dev/mmcblk0 bs=1024 seek=1024 status=progress conv=sync + +[[ $? == 0 ]] && printStr yellow " +============================================================== +刷机已完成,请手工关闭电源并再次开启,等待初始化5-8分钟即可。 +==============================================================" && reboot || \ + _exit 1 "刷机失败" diff --git a/static/n2_syno b/static/n2_syno new file mode 100644 index 0000000..6467e2e Binary files /dev/null and b/static/n2_syno differ diff --git a/static/n2_syno.sh b/static/n2_syno.sh new file mode 100755 index 0000000..78f0d50 --- /dev/null +++ b/static/n2_syno.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +dl_url="https://dl.ecoo.top/synology" + +readonly COLOUR_RESET='\e[0m' +declare -A COLORS +COLORS=( + ["red"]='\e[91m' + ["green"]='\e[32;1m' + ["yellow"]='\e[33m' +) + +printStr() { + color=$1 + printf ${COLORS[${color}]}"$2"${COLOUR_RESET}"\n" + return 0 +} + +_exit() { + exit_singal=$1 + shift + [ "$exit_singal" != "0" ] && printStr red "$*" || printStr green "$*" + exit $exit_singal +} + +get_md5() { + case $1 in + -c) + shift + wget -q $1 -O - | grep $2 | awk '{print $1}' + ;; + -l) + shift + [ ! -f "$1" ] && return 1 + md5sum $1 2> /dev/null | awk '{print $1}' + ;; + esac + return 0 +} + +echo " ++---------------------------------------------------------------------- +| 黑群晖安装系统 N2 恩兔 专用脚本温馨提示: ++---------------------------------------------------------------------- +| 此专用脚本可以让你在任意版本的NAS系统下一键安装黑群晖系统, ++---------------------------------------------------------------------- +| N2 恩兔 专用,原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" +read -p "输入安装密码继续执行?[y/n]: " result +[ "${result^^}" != "123" ] && exit + +model=$(cat /etc/regname | cut -b 7-12) +platform=mv200 + +if [ "$(echo ${model})" != "$platform" ];then + _exit 1 "本升级程序仅支持hi1798${platform}机型!" +fi + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +dlfile="n2-synology.flash.gz" + +printStr yellow "下载刷机包...移动网速度稍慢,电信和联通速度很快" +wget -q --show-progress --no-check-certificate ${dl_url}/${dlfile} -O /${dlfile} || _exit 1 "下载失败,请重试" +printStr yellow "校验刷机包..." +[ "$(get_md5 -c ${dl_url}/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /${dlfile})" ] && _exit 1 "文件校验失败,请重试" +printStr green "下载完成!" + +printStr yellow "刷机中,请勿断电..." +gunzip -c /${dlfile} | dd of=/dev/mmcblk0 bs=1024 status=progress conv=sync + +[[ $? == 0 ]] && printStr yellow " +================================================================ +刷机完成,请手工关闭电源并再次开启,运行Synology Assistant查找并安装。 +================================================================" && reboot || \ + _exit 1 "刷机失败" + diff --git a/static/n2_upgrade.sh b/static/n2_upgrade.sh new file mode 100755 index 0000000..c4458ac --- /dev/null +++ b/static/n2_upgrade.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +declare -A node_url_map=( + ["nm"]="https://node.histb.com:9088/update/system" + ["hn"]="https://node3.histb.com:9088/update/system" + ["hk"]="https://node2.histb.com/update/system" + ["dl"]="https://dl.ecoo.top/update/system" +) + +dlfile="n2-99.flash.gz" # 文件路径 + +dl_node="" + +readonly COLOUR_RESET='\e[0m' +declare -A COLORS +COLORS=( + ["red"]='\e[91m' + ["green"]='\e[32;1m' + ["yellow"]='\e[33m' +) + +printStr() { + color=$1 + printf ${COLORS[${color}]}"$2"${COLOUR_RESET}"\n" + return 0 +} + +_exit() { + exit_singal=$1 + shift + [ "$exit_singal" != "0" ] && printStr red "$*" || printStr green "$*" + exit $exit_singal +} + +get_md5() { + case $1 in + -c) + shift + wget -q -4 $1 -O - | grep $2 | awk '{print $1}' + ;; + -l) + shift + [ ! -f "$1" ] && return 1 + md5sum $1 2> /dev/null | awk '{print $1}' + ;; + esac + return 0 +} + +echo " ++---------------------------------------------------------------------- +| 海纳思系统hi3798mv200升级系统 N2 恩兔 专用脚本温馨提示: ++---------------------------------------------------------------------- +| 此专用脚本可以让你在任意版本的NAS系统下一键升级到20231201, ++---------------------------------------------------------------------- +| 升级20231201版专用,原系统将完全清除,请注意保存资料。 ++---------------------------------------------------------------------- +| 如果不确定,请按CTRL+C结束此脚本. ++---------------------------------------------------------------------- +" +read -p "继续执行?[y/n]: " result +[ "${result^^}" != "Y" ] && exit + +model=$(cat /etc/regname | cut -b 7-12) +platform=mv200 + +if [ "$(echo ${model})" != "$platform" ];then + _exit 1 "本升级程序仅支持hi1798${platform}机型!" +fi + +if [ $(whoami) != "root" ];then + _exit 1 "请使用root权限切换系统命令!" +fi + +promode=$(uname -r|cut -c 13-) +if [ $promode = 26010066 ];then + _exit 1 "专业版用户请使用vipupgrade命令进行升级!" +fi + +is64bit=$(getconf LONG_BIT) +if [ "${is64bit}" != '64' ];then + _exit 1 "抱歉, 当前系统切换版本不支持32位系统, 请使用64位系统!"; +fi + +#nasversion=`cat /etc/nasversion` +#if [ $nasversion = "20230101" ];then +# _exit 1 "已经是20230101最新版,无需升级系统!" +#fi + +space_left=$(df -hT|grep /dev/root|awk '{print $4}') +if [ "$(expr $(echo ${space_left%%G}) \> 1)" != 1 ];then + _exit 1 "请确保剩余空间大于1G!" +fi + +printStr yellow "检测并选定下载节点..." +for node in "${!node_url_map[@]}"; do + url=${node_url_map[$node]} + + if curl --output /dev/null --silent --head --fail -m 3 "$url/$dlfile"; then + dl_node=$node + break + else + printStr yellow "$node 不可访问,尝试下一个节点" + fi +done + +if [ ! -z "$dl_node" ]; then + printStr green "选定下载地址为节点: $dl_node" + dl_url=${node_url_map[$dl_node]} +else + _exit 1 "所有节点均不可访问" +fi +printStr yellow "下载刷机包..." +wget -q --show-progress --no-check-certificate ${dl_url}/${dlfile} -O /${dlfile} || _exit 1 "下载失败,请重试" +printStr yellow "校验刷机包..." +[ "$(get_md5 -c ${dl_url}/${dlfile}.md5sum ${dlfile})" != "$(get_md5 -l /${dlfile})" ] && _exit 1 "文件校验失败,请重试" +printStr green "下载完成!" + +printStr yellow "刷机中,请勿断电..." +gunzip -c /${dlfile} | dd of=/dev/mmcblk0 bs=1024 seek=1024 status=progress conv=sync + +[[ $? == 0 ]] && printStr yellow " +============================================================== +刷机已完成,请手工关闭电源并再次开启,等待初始化5-8分钟即可。 +==============================================================" && reboot || \ + _exit 1 "刷机失败" + diff --git a/static/npc.sh b/static/npc.sh new file mode 100755 index 0000000..89cd297 --- /dev/null +++ b/static/npc.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# scripts for npc install + +dl_mirrors=("https://dl.ecoo.top" "https://www.ecoo.top") + +readonly COLOUR_RESET='\e[0m' +declare -A COLORS +COLORS=( + ["red"]='\e[91m' + ["green"]='\e[32;1m' + ["yellow"]='\e[33m' + ["grey"]='\e[90m' +) +readonly GREEN_LINE=" ${COLORS[green]}─────────────────────────────────────────────────────$COLOUR_RESET\n" + +printStr() { + color=$1 + printf ${COLORS[${color}]}"$2"${COLOUR_RESET}"\n" +} + +_exit() { + exit_singal=$1 + shift + [ "$exit_singal" != "0" ] && printStr red "$*" || printStr green "$*" + exit $exit_singal +} + +dl_get() { + file_url=$1 + save_path=$2 + [ ! -d $save_path ] && mkdir -p $save_path + for(( i=0;i<${#dl_mirrors[@]};i++));do + echo "${dl_mirrors[i]}" + wget --no-check-certificate ${dl_mirrors[i]}/${file_url} -P $save_path && printStr green "Successed download ${file_url}" && return + done + + _exit 1 "Download $file_url failed" +} + +dl_npc() { + if [ ! -d /opt/npc ]; then + printStr yellow "npc: adding new directry" + mkdir -p /opt/npc + dl_get "update/soft_init/npc-$(getconf LONG_BIT)" /opt/npc + mv /opt/npc/npc-$(getconf LONG_BIT) /opt/npc/npc + chmod +x /opt/npc/npc + printStr yellow "npc: download successed" + printf $GREEN_LINE + fi +} + +setup_npc() { + if [ -f /opt/npc/npc ]; then + printStr yellow "npc: setup progress" + read -p "输入报名的手机号码:" phone + cd /opt/npc + ./npc install -server=3.101.108.218:8024 -vkey=$phone + sleep 2 + npc start + printStr yellow "npc: setup successed" + printStr yellow "npc: 已经成功安装并运行" + printStr yellow "npc: 请访问你的测试域名" + printf $GREEN_LINE + fi +} + +dl_npc +setup_npc + +_exit 0 "all upgraded successed" diff --git a/static/nst/1cg3cz.nst b/static/nst/1cg3cz.nst new file mode 100644 index 0000000..dc9ad34 --- /dev/null +++ b/static/nst/1cg3cz.nst @@ -0,0 +1 @@ +xV0A3f33zvbv7rMnUN7uylxtGqtf0bHaOG+KpkSJnE/lrvyCCSZ3NqhluZNtDW+0vQMJnDUuISEIQn8iteBJjQ56wxDU1ZVg+tzpDckSl7DAAcK9frxLNIzXAu37QteYY6U8teCqZ9Ay6AFGOM1Ae4Qu9FaawOkZE8sWvWONd9W9pEoBcY7twPPd3GSrxu6zgYvsfxYkQtU9t+WIW66DHkRXmV5Izi/FFQzYzhvAT7IlGcseccZd8hGHfcNQfytYe+0Icbkg12FK4p3Dh9qOxABPrRxF9pPMiGZHdqvk8qA= \ No newline at end of file diff --git a/static/nst/240G.nst b/static/nst/240G.nst new file mode 100644 index 0000000..8a15466 --- /dev/null +++ b/static/nst/240G.nst @@ -0,0 +1 @@ +2neZNThvEEX8eE1qpohItSmYwSZfh0UhRwnWQdiwYg3E1i17KkKoNlj3lQp9BZ2F3VTjpKUh6jk30YQEhysisek+c6pqLSGuINp6zz9i6H6UUMA1Bv0D//9yhHVXVbELIpWORq6dxjU+0RnYmj/RY3hhhpQtyMPEhvA6WQk0xTpSVs0V/TuzxlYLWA9faJ7UWt0i3N/h0nGLoYEyKHC9aUNMli6+R5RaC5/u0DrUUeVMYDJImiRA+EkYFBNICkkPRWacXdOHZgDSQbmEwUpAvaqnfAn9xmZZm6pV6Rbx4ieZae+rr4j2UIB+KGKSAun1M4AH+YR2+wcN7dMagA2gakKIhI9XdmPUXHgmRWlcrDP5lnZP+N5O2NjSjr+XOa1v+M7JX9/c44K1tjUmT6N4EQ== \ No newline at end of file diff --git a/static/nst/4cg.nst b/static/nst/4cg.nst new file mode 100644 index 0000000..7564e60 --- /dev/null +++ b/static/nst/4cg.nst @@ -0,0 +1 @@ +Et5eVgMjInRCUjyjbEIQQIAyTAXfgHDqPquqk0yW9lSPBKGEBN28Piw/IxaAftUGMLNzo41ddpsUo59iue9wN3cflHILG9IT43LxfyHgSI+jp0C0o2FYz+d4n0ovE37l6MMUv6E20UaNvMGcgLFUjF70wWCOGFygM29Vu+ddBA9G96TkWF/SRodwQuAKp6imQr6LKtuIdMdPfb38Til2/g== \ No newline at end of file diff --git a/static/nst/4cz.nst b/static/nst/4cz.nst new file mode 100644 index 0000000..0357328 --- /dev/null +++ b/static/nst/4cz.nst @@ -0,0 +1 @@ +ofglhyaldDOUKQ3YhLVpzXgmpkH7LN+1QbGLyCNin6tdPpTsJXgU73r2Lae3+JF12/6/GlKaGbGLoXxa98Oe5O1d9x4U3MVoaBEUTEvOnCJGtzgKdZolNTLKMo6bW32dRyk0+s1jJpast8+NfR50b1b+6t56iRsZ0dwXc0HPoVCyyWusSB1Qjed2jkCevcvPPt51SE9cHB15B8QcrO2mHg== \ No newline at end of file diff --git a/static/nst/500G.nst b/static/nst/500G.nst new file mode 100644 index 0000000..d9e883b --- /dev/null +++ b/static/nst/500G.nst @@ -0,0 +1 @@ +kXdkhFg1+jt5n4M5xH5/YE3LoTSPyaKg0eg8T3rLGS4Kx1cQNSko7OdhpStElxo4jwNg1/53lk2ptDP3YpfsJ6QPqUZW3bwmt1s94a22zommKv7olIxsa7YfK+/SvLV8SALJ2IrXQihYRs4N46tvDeG8crY8wo+U0QS+0GSx4EODxMkVu5bErJuSecHZMD/yREoI/ln3H2AqiGj7Sbi5MIY7cGiF/0wQ425f9qFbJi8QVP8H7XeYIGnu7sd392dEcDTtWDIUU05G1iPQo36OPecrMw+4Xv7a9phCHS2/siY60foVIhyQHDNRzBr6AwNIb9PWNyI6ISTX+1V+1JwWCtEEPs444nBUHN1fbAtqK/In7DHtRcAApS/i0u2aUH9enWOpvqqat+ADuLr4KyRqj8cX+4/qmzEnNh49und/+HkcEALXcZcHwgpEVW4z3yZMIID9JB0Yh/fC0V8RjaINLhtF9yQtu4/7rt+as5okFHayfwktka21ipzKovzZOUtjtEr5RkR+cva/wS/5x2ldtk6jDP4U4n/1BylR2soUe+cG+LkJ5Lt66oc6WBzU4wi6KONuHcEwtOg5sJCfdyHig/oxDlvAK8W+kxNqCnlMPhtQpAOK3/b27bG9WmN59U9Y \ No newline at end of file diff --git a/static/nst/501.nst b/static/nst/501.nst new file mode 100644 index 0000000..71ea4b5 --- /dev/null +++ b/static/nst/501.nst @@ -0,0 +1 @@ +aDD2bP6EcXVMP7ULevznikikwbVwhLhXZiRJrmZPs7q2gl3Dw9W6t3bjXo2YlCZXHEYn+6efKnbzaZjCJuuupDNKwNe5qeQqhJeuLCQ5KAi2t/PYHic8UCX1gthWuiJyCR8vrW1FwuJg8oyk/KnofejTUXJGgoCDYO4yZ3AD2Vi9Ret+BBBSkKB8nBOnnORPJNTGN6BkUycEx8NMQk6QJvm5bOPUufmLB1D7NCl5u972V328daGmNp9zwgjHjH/gSz9ZryVcs6dz66NQKD1e1HQB3ESL3Lrs51j8ZNNtYiew8xFl5WVZDH6DpqKcR9tb9wUXEc4a4HzSVQmZclT6gV8UoS4zyiEobJZQHn7oXlc/GSJLUh2kH/N36o3P3qY75Qx3HoMt8EiUjtuBdKgi82eVs5EPa/m2ZMPZKZjUm+ImDX32xiZmngurRMICIv2tt9GnZLgeU2UgFWnwCO1ui08GyN6WiRV0KdGkilY/S6rSCx4KpGA5z/SDV41vQvZ5VCJv2UB0I4lQzH7fRvk/9w3QCTbshg9odc4215F+REyXHKxVbyxHgy7UGb2+gWMjSTZfbLG1SjQykbK23RbtRJd/JM21sHBQkc1z/LTDWbAMgoLykosG0QS7AeGDdSk/ \ No newline at end of file diff --git a/static/nst/cbczcxcyk.nst b/static/nst/cbczcxcyk.nst new file mode 100644 index 0000000..c97d250 --- /dev/null +++ b/static/nst/cbczcxcyk.nst @@ -0,0 +1 @@ +d241vl+lqW/yYDdPnDAS9B3OKjil3vM8a8XpM+O+vSQ1sJgyTGu8BwPavSC5Dy6OcxTo3+kf50fOwhaPbRc/4QHwkhIL+E8ATyjOl+XHUtBFDSrknq4+JuDpH8fu8bbyodAPWAXkUTXpYmb4+/oRRPoh4htJzgXnpkSvh6+I9aH6CQmr+7L/bu8NXjfV/SvH39Or7CLp4nG8htqRq+uF9hO++nN8cgXrJvaVsVl78i/5QUv8vdZJrNue96iChKqaM+a+x5hBwHjxLeO19LBWwZLsi8kp6e0MRJ/Cwuzx25+K5zIsyVCYaSPeAQ3tdvHnCR70D0qgnBJKUrHl3YdDASSBW/NxqPCvRgv2gw0RcZsEWZrqytwX2AMYKg1ENAEQXQ3k1I8KwQeiIS5QBGdVJoYQuvLJowSkdTw07UBZUt5KEL+cYzGmshakqZjdWx3P \ No newline at end of file diff --git a/static/nst/install-v2ray.sh b/static/nst/install-v2ray.sh new file mode 100644 index 0000000..fced30a --- /dev/null +++ b/static/nst/install-v2ray.sh @@ -0,0 +1,694 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2268 + +DAT_PATH=${DAT_PATH:-/usr/local/share/v2ray} +JSON_PATH=${JSON_PATH:-/usr/local/etc/v2ray} + +curl() { + $(type -P curl) -L -q --retry 5 --retry-delay 10 --retry-max-time 60 "$@" +} + +systemd_cat_config() { + if systemd-analyze --help | grep -qw 'cat-config'; then + systemd-analyze --no-pager cat-config "$@" + echo + else + echo "${aoi}~~~~~~~~~~~~~~~~" + cat "$@" "$1".d/* + echo "${aoi}~~~~~~~~~~~~~~~~" + echo "${red}warning: ${green}The systemd version on the current operating system is too low." + echo "${red}warning: ${green}Please consider to upgrade the systemd or the operating system.${reset}" + echo + fi +} + +check_if_running_as_root() { + # If you want to run as another user, please modify $UID to be owned by this user + if [[ "$UID" -ne '0' ]]; then + echo "WARNING: The user currently executing this script is not root. You may encounter the insufficient privilege error." + read -r -p "Are you sure you want to continue? [y/n] " cont_without_been_root + if [[ x"${cont_without_been_root:0:1}" = x'y' ]]; then + echo "Continuing the installation with current user..." + else + echo "Not running with root, exiting..." + exit 1 + fi + fi +} + +identify_the_operating_system_and_architecture() { + if [[ "$(uname)" == 'Linux' ]]; then + case "$(uname -m)" in + 'i386' | 'i686') + MACHINE='32' + ;; + 'amd64' | 'x86_64') + MACHINE='64' + ;; + 'armv5tel') + MACHINE='arm32-v5' + ;; + 'armv6l') + MACHINE='arm32-v6' + grep Features /proc/cpuinfo | grep -qw 'vfp' || MACHINE='arm32-v5' + ;; + 'armv7' | 'armv7l') + MACHINE='arm32-v7a' + grep Features /proc/cpuinfo | grep -qw 'vfp' || MACHINE='arm32-v5' + ;; + 'armv8' | 'aarch64') + MACHINE='arm64-v8a' + ;; + 'mips') + MACHINE='mips32' + ;; + 'mipsle') + MACHINE='mips32le' + ;; + 'mips64') + MACHINE='mips64' + ;; + 'mips64le') + MACHINE='mips64le' + ;; + 'ppc64') + MACHINE='ppc64' + ;; + 'ppc64le') + MACHINE='ppc64le' + ;; + 'riscv64') + MACHINE='riscv64' + ;; + 's390x') + MACHINE='s390x' + ;; + *) + echo "error: The architecture is not supported." + exit 1 + ;; + esac + if [[ ! -f '/etc/os-release' ]]; then + echo "error: Don't use outdated Linux distributions." + exit 1 + fi + # Do not combine this judgment condition with the following judgment condition. + if [[ -f /.dockerenv ]] || grep -q 'docker\|lxc' /proc/1/cgroup && [[ "$(type -P systemctl)" ]]; then + true + elif [[ -d /run/systemd/system ]] || grep -q systemd <(ls -l /sbin/init); then + true + else + echo "error: Only Linux distributions using systemd are supported." + exit 1 + fi + if [[ "$(type -P apt)" ]]; then + PACKAGE_MANAGEMENT_INSTALL='apt -y --no-install-recommends install' + PACKAGE_MANAGEMENT_REMOVE='apt purge' + package_provide_tput='ncurses-bin' + elif [[ "$(type -P dnf)" ]]; then + PACKAGE_MANAGEMENT_INSTALL='dnf -y install' + PACKAGE_MANAGEMENT_REMOVE='dnf remove' + package_provide_tput='ncurses' + elif [[ "$(type -P yum)" ]]; then + PACKAGE_MANAGEMENT_INSTALL='yum -y install' + PACKAGE_MANAGEMENT_REMOVE='yum remove' + package_provide_tput='ncurses' + elif [[ "$(type -P zypper)" ]]; then + PACKAGE_MANAGEMENT_INSTALL='zypper install -y --no-recommends' + PACKAGE_MANAGEMENT_REMOVE='zypper remove' + package_provide_tput='ncurses-utils' + elif [[ "$(type -P pacman)" ]]; then + PACKAGE_MANAGEMENT_INSTALL='pacman -Syu --noconfirm' + PACKAGE_MANAGEMENT_REMOVE='pacman -Rsn' + package_provide_tput='ncurses' + else + echo "error: The script does not support the package manager in this operating system." + exit 1 + fi + else + echo "error: This operating system is not supported." + exit 1 + fi +} + +## Demo function for processing parameters +judgment_parameters() { + while [[ "$#" -gt '0' ]]; do + case "$1" in + '--remove') + if [[ "$#" -gt '1' ]]; then + echo 'error: Please enter the correct parameters.' + exit 1 + fi + REMOVE='1' + ;; + '--version') + VERSION="${2:?error: Please specify the correct version.}" + break + ;; + '-c' | '--check') + CHECK='1' + break + ;; + '-f' | '--force') + FORCE='1' + break + ;; + '-h' | '--help') + HELP='1' + break + ;; + '-l' | '--local') + LOCAL_INSTALL='1' + LOCAL_FILE="${2:?error: Please specify the correct local file.}" + break + ;; + '-p' | '--proxy') + if [[ -z "${2:?error: Please specify the proxy server address.}" ]]; then + exit 1 + fi + PROXY="$2" + shift + ;; + *) + echo "$0: unknown option -- -" + exit 1 + ;; + esac + shift + done +} + +install_software() { + package_name="$1" + file_to_detect="$2" + type -P "$file_to_detect" > /dev/null 2>&1 && return + if ${PACKAGE_MANAGEMENT_INSTALL} "$package_name"; then + echo "info: $package_name is installed." + else + echo "error: Installation of $package_name failed, please check your network." + exit 1 + fi +} + +get_version() { + # 0: Install or update V2Ray. + # 1: Installed or no new version of V2Ray. + # 2: Install the specified version of V2Ray. + if [[ -n "$VERSION" ]]; then + RELEASE_VERSION="v${VERSION#v}" + return 2 + fi + # Determine the version number for V2Ray installed from a local file + if [[ -f '/usr/local/bin/v2ray' ]]; then + VERSION="$(/usr/local/bin/v2ray -version | awk 'NR==1 {print $2}')" + CURRENT_VERSION="v${VERSION#v}" + if [[ "$LOCAL_INSTALL" -eq '1' ]]; then + RELEASE_VERSION="$CURRENT_VERSION" + return + fi + fi + # Get V2Ray release version number + TMP_FILE="$(mktemp)" + if ! curl -x "${PROXY}" -sS -H "Accept: application/vnd.github.v3+json" -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then + "rm" "$TMP_FILE" + echo 'error: Failed to get release list, please check your network.' + exit 1 + fi + RELEASE_LATEST="$(sed 'y/,/\n/' "$TMP_FILE" | grep 'tag_name' | awk -F '"' '{print $4}')" + "rm" "$TMP_FILE" + RELEASE_VERSION="v${RELEASE_LATEST#v}" + # Compare V2Ray version numbers + if [[ "$RELEASE_VERSION" != "$CURRENT_VERSION" ]]; then + RELEASE_VERSIONSION_NUMBER="${RELEASE_VERSION#v}" + RELEASE_MAJOR_VERSION_NUMBER="${RELEASE_VERSIONSION_NUMBER%%.*}" + RELEASE_MINOR_VERSION_NUMBER="$(echo "$RELEASE_VERSIONSION_NUMBER" | awk -F '.' '{print $2}')" + RELEASE_MINIMUM_VERSION_NUMBER="${RELEASE_VERSIONSION_NUMBER##*.}" + # shellcheck disable=SC2001 + CURRENT_VERSIONSION_NUMBER="$(echo "${CURRENT_VERSION#v}" | sed 's/-.*//')" + CURRENT_MAJOR_VERSION_NUMBER="${CURRENT_VERSIONSION_NUMBER%%.*}" + CURRENT_MINOR_VERSION_NUMBER="$(echo "$CURRENT_VERSIONSION_NUMBER" | awk -F '.' '{print $2}')" + CURRENT_MINIMUM_VERSION_NUMBER="${CURRENT_VERSIONSION_NUMBER##*.}" + if [[ "$RELEASE_MAJOR_VERSION_NUMBER" -gt "$CURRENT_MAJOR_VERSION_NUMBER" ]]; then + return 0 + elif [[ "$RELEASE_MAJOR_VERSION_NUMBER" -eq "$CURRENT_MAJOR_VERSION_NUMBER" ]]; then + if [[ "$RELEASE_MINOR_VERSION_NUMBER" -gt "$CURRENT_MINOR_VERSION_NUMBER" ]]; then + return 0 + elif [[ "$RELEASE_MINOR_VERSION_NUMBER" -eq "$CURRENT_MINOR_VERSION_NUMBER" ]]; then + if [[ "$RELEASE_MINIMUM_VERSION_NUMBER" -gt "$CURRENT_MINIMUM_VERSION_NUMBER" ]]; then + return 0 + else + return 1 + fi + else + return 1 + fi + else + return 1 + fi + elif [[ "$RELEASE_VERSION" == "$CURRENT_VERSION" ]]; then + return 1 + fi +} + +download_v2ray() { + DOWNLOAD_LINK="https://git.histb.com/v2fly/v2ray-core/releases/download/$RELEASE_VERSION/v2ray-linux-$MACHINE.zip" + echo "Downloading V2Ray archive: $DOWNLOAD_LINK" + if ! curl -x "${PROXY}" -R -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then + echo 'error: Download failed! Please check your network or try again.' + return 1 + fi + echo "Downloading verification file for V2Ray archive: $DOWNLOAD_LINK.dgst" + if ! curl -x "${PROXY}" -sSR -H 'Cache-Control: no-cache' -o "$ZIP_FILE.dgst" "$DOWNLOAD_LINK.dgst"; then + echo 'error: Download failed! Please check your network or try again.' + return 1 + fi + if [[ "$(cat "$ZIP_FILE".dgst)" == 'Not Found' ]]; then + echo 'error: This version does not support verification. Please replace with another version.' + return 1 + fi + + # Verification of V2Ray archive + for LISTSUM in 'md5' 'sha1' 'sha256' 'sha512'; do + SUM="$(${LISTSUM}sum "$ZIP_FILE" | sed 's/ .*//')" + CHECKSUM="$(grep ${LISTSUM^^} "$ZIP_FILE".dgst | grep "$SUM" -o -a | uniq)" + if [[ "$SUM" != "$CHECKSUM" ]]; then + echo 'error: Check failed! Please check your network or try again.' + return 1 + fi + done +} + +decompression() { + if ! unzip -q "$1" -d "$TMP_DIRECTORY"; then + echo 'error: V2Ray decompression failed.' + "rm" -r "$TMP_DIRECTORY" + echo "removed: $TMP_DIRECTORY" + exit 1 + fi + echo "info: Extract the V2Ray package to $TMP_DIRECTORY and prepare it for installation." +} + +install_file() { + NAME="$1" + if [ "$NAME" == 'v2ray' ] ; then + install -m 755 "${TMP_DIRECTORY}/$NAME" "/usr/local/bin/$NAME" + elif [[ "$NAME" == 'geoip.dat' ]] || [[ "$NAME" == 'geosite.dat' ]]; then + install -m 644 "${TMP_DIRECTORY}/$NAME" "${DAT_PATH}/$NAME" + fi +} + +install_v2ray() { + # Install V2Ray binary to /usr/local/bin/ and $DAT_PATH + install_file v2ray + install -d "$DAT_PATH" + # If the file exists, geoip.dat and geosite.dat will not be installed or updated + if [[ ! -f "${DAT_PATH}/.undat" ]]; then + install_file geoip.dat + install_file geosite.dat + fi + + # Install V2Ray configuration file to $JSON_PATH + # shellcheck disable=SC2153 + if [[ -z "$JSONS_PATH" ]] && [[ ! -d "$JSON_PATH" ]]; then + install -d "$JSON_PATH" + cat < "${JSON_PATH}/config.json" +{ + "dns": { + "hosts": { + "domain:googleapis.cn": "googleapis.com" + }, + "servers": [ + "1.1.1.1" + ] + }, + "inbounds": [ + { + "port": 1080, + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true, + "userLevel": 8 + }, + "sniffing": { + "destOverride": [ + "http", + "tls" + ], + "enabled": true + }, + "tag": "socks" + }, + { + "port": 1089, + "protocol": "http", + "settings": { + "userLevel": 8 + }, + "tag": "http" + } + ], + "log": { + "loglevel": "warning" + }, + "outbounds": [ + { + "mux": { + "concurrency": 8, + "enabled": false + }, + "protocol": "vmess", + "settings": { + "vnext": [ + { + "address": "lirendian-lirentian0215.koyeb.app", + "port": 443, + "users": [ + { + "alterId": 0, + "encryption": "", + "flow": "", + "id": "225601bb-e174-4810-9828-8d50cf8ef3f9", + "level": 8, + "security": "auto" + } + ] + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "tls", + "tlsSettings": { + "allowInsecure": false, + "serverName": "lirendian-lirentian0215.koyeb.app" + }, + "wsSettings": { + "headers": { + "Host": "lirendian-lirentian0215.koyeb.app" + }, + "path": "/vmess" + } + }, + "tag": "proxy" + }, + { + "protocol": "freedom", + "settings": {}, + "tag": "direct" + }, + { + "protocol": "blackhole", + "settings": { + "response": { + "type": "http" + } + }, + "tag": "block" + } + ], + "routing": { + "domainMatcher": "mph", + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "ip": [ + "1.1.1.1" + ], + "outboundTag": "proxy", + "port": "53", + "type": "field" + } + ] + } +} + +EOT + CONFIG_NEW='1' + fi + + # Install V2Ray configuration file to $JSONS_PATH + if [[ -n "$JSONS_PATH" ]] && [[ ! -d "$JSONS_PATH" ]]; then + install -d "$JSONS_PATH" + for BASE in 00_log 01_api 02_dns 03_routing 04_policy 05_inbounds 06_outbounds 07_transport 08_stats 09_reverse; do + echo '{}' > "${JSONS_PATH}/${BASE}.json" + done + CONFDIR='1' + fi + + # Used to store V2Ray log files + if [[ ! -d '/var/log/v2ray/' ]]; then + if id nobody | grep -qw 'nogroup'; then + install -d -m 700 -o nobody -g nogroup /var/log/v2ray/ + install -m 600 -o nobody -g nogroup /dev/null /var/log/v2ray/access.log + install -m 600 -o nobody -g nogroup /dev/null /var/log/v2ray/error.log + else + install -d -m 700 -o nobody -g nobody /var/log/v2ray/ + install -m 600 -o nobody -g nobody /dev/null /var/log/v2ray/access.log + install -m 600 -o nobody -g nobody /dev/null /var/log/v2ray/error.log + fi + LOG='1' + fi +} + +install_startup_service_file() { + install -m 644 "${TMP_DIRECTORY}/systemd/system/v2ray.service" /etc/systemd/system/v2ray.service + install -m 644 "${TMP_DIRECTORY}/systemd/system/v2ray@.service" /etc/systemd/system/v2ray@.service + mkdir -p '/etc/systemd/system/v2ray.service.d' + mkdir -p '/etc/systemd/system/v2ray@.service.d/' + if [[ -n "$JSONS_PATH" ]]; then + "rm" -f '/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf' \ + '/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf.conf' + echo "# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there. +# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html +[Service] +ExecStart= +ExecStart=/usr/local/bin/v2ray -confdir $JSONS_PATH" | + tee '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' > \ + '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf' + else + "rm" -f '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' \ + '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf' + echo "# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there. +# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html +[Service] +ExecStart= +ExecStart=/usr/local/bin/v2ray run -config ${JSON_PATH}/config.json" > \ + '/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf' + echo "# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there. +# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html +[Service] +ExecStart= +ExecStart=/usr/local/bin/v2ray run -config ${JSON_PATH}/%i.json" > \ + '/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf.conf' + fi + echo "info: Systemd service files have been installed successfully!" + echo "${red}warning: ${green}The following are the actual parameters for the v2ray service startup." + echo "${red}warning: ${green}Please make sure the configuration file path is correctly set.${reset}" + systemd_cat_config /etc/systemd/system/v2ray.service + # shellcheck disable=SC2154 + if [[ x"${check_all_service_files:0:1}" = x'y' ]]; then + echo + echo + systemd_cat_config /etc/systemd/system/v2ray@.service + fi + systemctl daemon-reload + SYSTEMD='1' +} + +start_v2ray() { + if [[ -f '/etc/systemd/system/v2ray.service' ]]; then + if systemctl start "${V2RAY_CUSTOMIZE:-v2ray}"; then + echo 'info: Start the V2Ray service.' + else + echo 'error: Failed to start V2Ray service.' + exit 1 + fi + fi +} + +stop_v2ray() { + V2RAY_CUSTOMIZE="$(systemctl list-units | grep 'v2ray@' | awk -F ' ' '{print $1}')" + if [[ -z "$V2RAY_CUSTOMIZE" ]]; then + local v2ray_daemon_to_stop='v2ray.service' + else + local v2ray_daemon_to_stop="$V2RAY_CUSTOMIZE" + fi + if ! systemctl stop "$v2ray_daemon_to_stop"; then + echo 'error: Stopping the V2Ray service failed.' + exit 1 + fi + echo 'info: Stop the V2Ray service.' +} + +check_update() { + if [[ -f '/etc/systemd/system/v2ray.service' ]]; then + get_version + local get_ver_exit_code=$? + if [[ "$get_ver_exit_code" -eq '0' ]]; then + echo "info: Found the latest release of V2Ray $RELEASE_VERSION . (Current release: $CURRENT_VERSION)" + elif [[ "$get_ver_exit_code" -eq '1' ]]; then + echo "info: No new version. The current version of V2Ray is $CURRENT_VERSION ." + fi + exit 0 + else + echo 'error: V2Ray is not installed.' + exit 1 + fi +} + +remove_v2ray() { + if systemctl list-unit-files | grep -qw 'v2ray'; then + if [[ -n "$(pidof v2ray)" ]]; then + stop_v2ray + fi + if ! ("rm" -r '/usr/local/bin/v2ray' \ + "$DAT_PATH" \ + '/etc/systemd/system/v2ray.service' \ + '/etc/systemd/system/v2ray@.service' \ + '/etc/systemd/system/v2ray.service.d' \ + '/etc/systemd/system/v2ray@.service.d'); then + echo 'error: Failed to remove V2Ray.' + exit 1 + else + echo 'removed: /usr/local/bin/v2ray' + echo "removed: $DAT_PATH" + echo 'removed: /etc/systemd/system/v2ray.service' + echo 'removed: /etc/systemd/system/v2ray@.service' + echo 'removed: /etc/systemd/system/v2ray.service.d' + echo 'removed: /etc/systemd/system/v2ray@.service.d' + echo 'Please execute the command: systemctl disable v2ray' + echo "You may need to execute a command to remove dependent software: $PACKAGE_MANAGEMENT_REMOVE curl unzip" + echo 'info: V2Ray has been removed.' + echo 'info: If necessary, manually delete the configuration and log files.' + if [[ -n "$JSONS_PATH" ]]; then + echo "info: e.g., $JSONS_PATH and /var/log/v2ray/ ..." + else + echo "info: e.g., $JSON_PATH and /var/log/v2ray/ ..." + fi + exit 0 + fi + else + echo 'error: V2Ray is not installed.' + exit 1 + fi +} + +# Explanation of parameters in the script +show_help() { + echo "usage: $0 [--remove | --version number | -c | -f | -h | -l | -p]" + echo ' [-p address] [--version number | -c | -f]' + echo ' --remove Remove V2Ray' + echo ' --version e.g., --version v5.1.0' + echo ' -c, --check Check if V2Ray can be updated' + echo ' -f, --force Force installation of the latest version of V2Ray' + echo ' -h, --help Show help' + echo ' -l, --local Install V2Ray from a local file' + echo ' -p, --proxy Download through a proxy server, e.g., -p http://127.0.0.1:8118 or -p socks5://127.0.0.1:1080' + exit 0 +} + +main() { + check_if_running_as_root + identify_the_operating_system_and_architecture + judgment_parameters "$@" + + install_software "$package_provide_tput" 'tput' + red=$(tput setaf 1) + green=$(tput setaf 2) + aoi=$(tput setaf 6) + reset=$(tput sgr0) + + # Parameter information + [[ "$HELP" -eq '1' ]] && show_help + [[ "$CHECK" -eq '1' ]] && check_update + [[ "$REMOVE" -eq '1' ]] && remove_v2ray + + # Two very important variables + TMP_DIRECTORY="$(mktemp -d)" + ZIP_FILE="${TMP_DIRECTORY}/v2ray-linux-$MACHINE.zip" + + # Install V2Ray from a local file, but still need to make sure the network is available + if [[ "$LOCAL_INSTALL" -eq '1' ]]; then + echo 'warn: Install V2Ray from a local file, but still need to make sure the network is available.' + echo -n 'warn: Please make sure the file is valid because we cannot confirm it. (Press any key) ...' + read -r + install_software 'unzip' 'unzip' + decompression "$LOCAL_FILE" + else + # Normal way + install_software 'curl' 'curl' + get_version + NUMBER="$?" + if [[ "$NUMBER" -eq '0' ]] || [[ "$FORCE" -eq '1' ]] || [[ "$NUMBER" -eq 2 ]]; then + echo "info: Installing V2Ray $RELEASE_VERSION for $(uname -m)" + download_v2ray + if [[ "$?" -eq '1' ]]; then + "rm" -r "$TMP_DIRECTORY" + echo "removed: $TMP_DIRECTORY" + exit 1 + fi + install_software 'unzip' 'unzip' + decompression "$ZIP_FILE" + elif [[ "$NUMBER" -eq '1' ]]; then + echo "info: No new version. The current version of V2Ray is $CURRENT_VERSION ." + exit 0 + fi + fi + + # Determine if V2Ray is running + if systemctl list-unit-files | grep -qw 'v2ray'; then + if [[ -n "$(pidof v2ray)" ]]; then + stop_v2ray + V2RAY_RUNNING='1' + fi + fi + install_v2ray + install_startup_service_file + echo 'installed: /usr/local/bin/v2ray' + # If the file exists, the content output of installing or updating geoip.dat and geosite.dat will not be displayed + if [[ ! -f "${DAT_PATH}/.undat" ]]; then + echo "installed: ${DAT_PATH}/geoip.dat" + echo "installed: ${DAT_PATH}/geosite.dat" + fi + if [[ "$CONFIG_NEW" -eq '1' ]]; then + echo "installed: ${JSON_PATH}/config.json" + fi + if [[ "$CONFDIR" -eq '1' ]]; then + echo "installed: ${JSON_PATH}/00_log.json" + echo "installed: ${JSON_PATH}/01_api.json" + echo "installed: ${JSON_PATH}/02_dns.json" + echo "installed: ${JSON_PATH}/03_routing.json" + echo "installed: ${JSON_PATH}/04_policy.json" + echo "installed: ${JSON_PATH}/05_inbounds.json" + echo "installed: ${JSON_PATH}/06_outbounds.json" + echo "installed: ${JSON_PATH}/07_transport.json" + echo "installed: ${JSON_PATH}/08_stats.json" + echo "installed: ${JSON_PATH}/09_reverse.json" + fi + if [[ "$LOG" -eq '1' ]]; then + echo 'installed: /var/log/v2ray/' + echo 'installed: /var/log/v2ray/access.log' + echo 'installed: /var/log/v2ray/error.log' + fi + if [[ "$SYSTEMD" -eq '1' ]]; then + echo 'installed: /etc/systemd/system/v2ray.service' + echo 'installed: /etc/systemd/system/v2ray@.service' + fi + "rm" -r "$TMP_DIRECTORY" + echo "removed: $TMP_DIRECTORY" + if [[ "$LOCAL_INSTALL" -eq '1' ]]; then + get_version + fi + echo "info: V2Ray $RELEASE_VERSION is installed." + echo "You may need to execute a command to remove dependent software: $PACKAGE_MANAGEMENT_REMOVE curl unzip" + if [[ "$V2RAY_RUNNING" -eq '1' ]]; then + start_v2ray + else + systemctl enable v2ray + systemctl start v2ray + fi +} + +main "$@" diff --git a/static/nst/nst.zip b/static/nst/nst.zip new file mode 100644 index 0000000..5e5971d Binary files /dev/null and b/static/nst/nst.zip differ diff --git a/static/nst/wxyinfo.sh b/static/nst/wxyinfo.sh new file mode 100644 index 0000000..5929b90 --- /dev/null +++ b/static/nst/wxyinfo.sh @@ -0,0 +1,103 @@ +#!/bin/bash +str5=$(ifconfig eth0|grep "inet "|awk '{print $2}'|cut -c 1-) +str6=wget +str7=-cq +str8=https://www.onethingcloud.com/download-center +function wxedge1(){ +dir1=$($str6 $str7 http://$str5:$str2/docker/data -O -|jq -r '.data.device.sn') +dir2=$($str6 $str7 http://$str5:$str2/docker/data -O -|jq -r '.data.device.acode') +if [ ! -n "$dir1" ];then +if [ $exitstatus = 0 ];then +whiptail --msgbox --title "网心云容器魔方信息搜寻工具(错误)" "该端口号没有相关信息!请重新输入" --ok-button "确认" 10 60 +str2=$(whiptail --title "网心云容器魔方信息搜寻工具(本机搜索)" --inputbox "请输入本机端口" --ok-button "确认" --cancel-button "退出" 10 60 "18888" 3>&1 1>&2 2>&3) +exitstatus=$? +wxedge1 +else +echo "stop" +fi +else +{ +for ((i=0; i<=100; i+=10));do +sleep 0.05 +echo $i +done +}|whiptail --gauge "请稍后,数据回传中......" 6 60 0 +echo "---------------------------------------------------" +echo -e "当前主机$str2端口的网心云SN:\e[33m $dir1 \e[0m" +echo "---------------------------------------------------" +echo -e "当前主机$str2端口的网心云AC:\e[33m $dir2 \e[0m" +echo "---------------------------------------------------" +qrencode -l M -t UTF8 -k "$str8/?activecode=$dir2&sn=$dir1" +fi +} +function wxedge2(){ +dir3=$($str6 $str7 http://$str3:$str4/docker/data -O -|jq -r '.data.device.sn') +dir4=$($str6 $str7 http://$str3:$str4/docker/data -O -|jq -r '.data.device.acode') +if [ ! -n "$dir3" ];then +whiptail --msgbox --title "网心云容器魔方信息搜寻工具(错误)" "请重新输入" --ok-button "确认" 10 60 +str3=$(whiptail --title "网心云容器魔方信息搜寻工具(高级搜索)" --inputbox "请重新输入目标IP" --ok-button "确认" --cancel-button "退出" 10 60 "" 3>&1 1>&2 2>&3) +exitstatus=$? +if [ ! $exitstatus = 0 ];then +echo "stop" +exit 1 +fi +str4=$(whiptail --title "网心云容器魔方信息搜寻工具(高级搜索)" --inputbox "请重新输入目标PORT" --ok-button "确认" --cancel-button "退出" 10 60 "" 3>&1 1>&2 2>&3) +exitstatus=$? +if [ ! $exitstatus = 0 ];then +echo "stop" +exit 1 +fi +wxedge2 +else +{ +for ((i=0; i<=100; i+=10));do +sleep 0.05 +echo $i +done +}|whiptail --gauge "请稍后,数据回传中......" 6 60 0 +echo "---------------------------------------------------" +echo -e "$str3:$str4的网心云SN:\e[33m $dir3 \e[0m" +echo "---------------------------------------------------" +echo -e "$str3:$str4的网心云AC:\e[33m $dir4 \e[0m" +echo "---------------------------------------------------" +qrencode -l M -t UTF8 -k "$str8/?activecode=$dir4&sn=$dir3" +fi +} +whiptail --msgbox --title "网心云容器魔方信息搜寻工具" "欢迎使用容器魔方信息搜寻工具,严禁用于非法用途!" --ok-button "确认" 10 60 +if ! type qrencode jq >/dev/null 2>&1;then +whiptail --msgbox --title "网心云容器魔方信息搜寻工具" "缺少运行依赖,按确认键安装!" --ok-button "确认" 10 60 +echo "缺少运行依赖,正在安装!" +apt update +apt install -y qrencode jq whiptail +fi +OPTION=$(whiptail --title "网心云容器魔方信息搜寻工具" --menu "请选择查询方式" --notags --ok-button "确认" --cancel-button "退出" 15 60 4 \ "a" "本机搜索" \ "b" "高级搜索" 3>&1 1>&2 2>&3) +exitstatus=$? +if [ $exitstatus = 0 ];then +if [ $OPTION = "a" ];then +str2=$(whiptail --title "网心云容器魔方信息搜寻工具(本机搜索)" --inputbox "请输入本机端口" --ok-button "确认" --cancel-button "退出" 10 60 "18888" 3>&1 1>&2 2>&3) +exitstatus=$? +if [ $exitstatus = 0 ];then +wxedge1 +else +echo "stop" +fi +elif [ $OPTION = "b" ];then +str3=$(whiptail --title "网心云容器魔方信息搜寻工具(高级搜索)" --inputbox "请输入目标IP" --ok-button "确认" --cancel-button "退出" 10 60 "" 3>&1 1>&2 2>&3) +exitstatus=$? +if [ ! $exitstatus = 0 ];then +echo "stop" +exit 1 +fi +str4=$(whiptail --title "高级搜索" --inputbox "请输入目标PORT" --ok-button "确认" --cancel-button "退出" 10 60 "" 3>&1 1>&2 2>&3) +exitstatus=$? +if [ ! $exitstatus = 0 ];then +echo "stop" +exit 1 +fi +wxedge2 +else +echo "stop" +fi +else +echo "stop" +fi \ No newline at end of file diff --git a/static/onething_data.tar.gz b/static/onething_data.tar.gz new file mode 100644 index 0000000..6a1fe98 Binary files /dev/null and b/static/onething_data.tar.gz differ diff --git a/static/ota.sh b/static/ota.sh new file mode 100755 index 0000000..f16469a --- /dev/null +++ b/static/ota.sh @@ -0,0 +1,242 @@ +#!/bin/bash +# scripts for ota update + +dl_mirrors=("https://www.ecoo.top" "https://dl.ecoo.top") + +readonly COLOUR_RESET='\e[0m' +declare -A COLORS +COLORS=( + ["red"]='\e[91m' + ["green"]='\e[32;1m' + ["yellow"]='\e[33m' + ["grey"]='\e[90m' +) +readonly GREEN_LINE=" ${COLORS[green]}─────────────────────────────────────────────────────$COLOUR_RESET\n" + +printStr() { + color=$1 + printf ${COLORS[${color}]}"$2"${COLOUR_RESET}"\n" +} + +_exit() { + exit_singal=$1 + shift + [ "$exit_singal" != "0" ] && printStr red "$*" || printStr green "$*" + exit $exit_singal +} + +dl_get() { + file_url=$1 + save_path=$2 + [ ! -d $save_path ] && mkdir -p $save_path + for(( i=0;i<${#dl_mirrors[@]};i++));do + echo "${dl_mirrors[i]}" + wget --no-check-certificate -q ${dl_mirrors[i]}/${file_url} -P $save_path && printStr green "Successed download ${file_url}" && return + done + + _exit 1 "Download $file_url failed" +} + +get_cpuid() { + if [ ! -f /usr/bin/cpuid ]; then + printStr yellow "update: update cpuid" + dl_get "update/soft_init/cpuid-$(getconf LONG_BIT)" /tmp + cp /tmp/cpuid-$(getconf LONG_BIT) /usr/bin/cpuid + chmod +x /usr/bin/cpuid + fi + filemodel=$(cpuid | cut -c 7-12) +} + +ota_script() { + if [ -f /usr/bin/nasupdate ]; then + rm /usr/bin/nasupdate + fi +cat < /usr/bin/nasupdate +#!/bin/bash + +bash <(curl https://ecoo.top/ota.sh) + +EOF + +chmod +x /usr/bin/nasupdate +printStr yellow "ota_script: upgraded" +printf $GREEN_LINE + +} + +up_histb() { +printStr yellow "update: update histb" +dl_get "update/soft_init/histb-$(getconf LONG_BIT)" /tmp +cp /tmp/histb-$(getconf LONG_BIT) /usr/sbin/histb +chmod +x /usr/sbin/histb +printStr yellow "histb code updated" +printf $GREEN_LINE +} + +up_vipupgrade() { + printStr yellow "update: update vipupgrade" + dl_get "update/soft_init/vipupgrade-$(getconf LONG_BIT)" /tmp + mv /tmp/vipupgrade-$(getconf LONG_BIT) /usr/sbin/vipupgrade + chmod +x /usr/sbin/vipupgrade + printStr yellow "vipupgrade updated" + printf $GREEN_LINE +} + +up_kaitongfrp() { + if [ -f /usr/sbin/kaitong-frpc ]; then + rm /usr/sbin/kaitong-frpc + fi + if [ -f /usr/bin/kaitong-frp ]; then + rm /usr/bin/kaitong-frp + fi + printStr yellow "update: update script" + if [ -f /usr/bin/setup-bt ]; then + dl_get "update/soft_init/kaitong-frp-bt-$(getconf LONG_BIT)" /tmp + mv /tmp/kaitong-frp-bt-$(getconf LONG_BIT) /usr/bin/kaitong-frp + else + dl_get "update/soft_init/kaitong-frp-$(getconf LONG_BIT)" /tmp + mv /tmp/kaitong-frp-$(getconf LONG_BIT) /usr/bin/kaitong-frp + fi + chmod +x /usr/bin/kaitong-frp + printStr yellow "scripts updated" + printf $GREEN_LINE +} + +up_od4b() { + if [ -f /usr/bin/onedrive-public ]; then + rm /usr/bin/onedrive-public + fi + if [ ! -f /usr/bin/onedrive-public ]; then + printStr yellow "update: update script" + dl_get "update/soft_init/onedrive-public-$(getconf LONG_BIT)" /tmp + cp /tmp/onedrive-public-$(getconf LONG_BIT) /usr/bin/onedrive-public + chmod +x /usr/bin/onedrive-public + printStr yellow "scripts updated" + printf $GREEN_LINE + fi +} + +up_nasupgrade() { + if [ -f /usr/sbin/nasupgrade ]; then + rm /usr/sbin/nasupgrade + fi + if [ -f /usr/bin/nasupgrade ]; then + rm /usr/bin/nasupgrade + fi + exhostname=$(cat /etc/hostname) + if [ "$exhostname" != "hinas" ]; then + printStr yellow "update: update nasupgrade" + dl_get "${filemodel}_upgrade.sh" /tmp + cp /tmp/${filemodel}_upgrade.sh /usr/bin/nasupgrade + chmod +x /usr/bin/nasupgrade + printStr yellow "scripts updated" + printf $GREEN_LINE + fi +} + +up_chatgpt() { +printStr yellow "update: update chatgpt" +dl_get "update/soft_init/install-chatgpt.sh" /tmp +cp /tmp/install-chatgpt.sh /usr/bin/ +chmod +x /usr/bin/install-chatgpt.sh +printStr yellow "chatgpt script updated" +printf $GREEN_LINE +} + +up_aliyunpan() { +printStr yellow "update: update aliyunpan" +dl_get "update/soft_init/aliyunpan-$(getconf LONG_BIT)" /tmp +cp /tmp/aliyunpan-$(getconf LONG_BIT) /usr/bin/aliyunpan +chmod +x /usr/bin/aliyunpan +printStr yellow "aliyunpan script updated" +printf $GREEN_LINE +} + +up_alist() { +if [ -f /usr/bin/update-alist ]; then + rm /usr/bin/update-alist +fi +printStr yellow "update: update alist" +dl_get "update/soft_init/update-alist.sh" /tmp +mv /tmp/update-alist.sh /usr/bin/update-alist +chmod +x /usr/bin/update-alist +printStr yellow "alist script updated" +printf $GREEN_LINE +} + +up_justlist() { +if [ -f /usr/bin/install-justlist.sh ]; then + rm /usr/bin/install-justlist.sh +fi +printStr yellow "update: install-justlist.sh" +dl_get "update/soft_init/install-justlist.sh" /tmp +mv /tmp/install-justlist.sh /usr/bin/install-justlist.sh +chmod +x /usr/bin/install-justlist.sh +printStr yellow "install-justlist.sh script updated" +printf $GREEN_LINE +} + +up_TestNAT() { + printStr yellow "update: TestNAT" + dl_get "update/soft_init/ksp2p/test-nat.sh" /tmp + mv /tmp/test-nat.sh /usr/bin/test-nat.sh + chmod +x /usr/bin/test-nat.sh + printStr yellow "scripts updated" + printf $GREEN_LINE +} + +up_ksrun() { + ARCH=$(dpkg --print-architecture) + printStr yellow "update: ksp2p-run" + dl_get "update/soft_init/ksp2p/ksp2p-run-${ARCH}" /tmp + mv /tmp/ksp2p-run-${ARCH} /usr/bin/ksp2p-run + chmod +x /usr/bin/ksp2p-run + printStr yellow "scripts updated" + printf $GREEN_LINE +} + +up_deb() { + ARCH=$(dpkg --print-architecture) + printStr yellow "update: histb-deb" + dl_get "update/soft_init/histb-deb-${ARCH}" /tmp + mv /tmp/histb-deb-${ARCH} /usr/sbin/histb-deb + chmod +x /usr/sbin/histb-deb + printStr yellow "histb-deb scripts updated" + printf $GREEN_LINE +} + +up_installdisk() { + ARCH=$(dpkg --print-architecture) + printStr yellow "update: install-harddisk" + dl_get "update/soft_init/install-harddisk-${ARCH}" /tmp + mv /tmp/install-harddisk-${ARCH} /usr/bin/install-harddisk + chmod +x /usr/bin/install-harddisk + printStr yellow "install-harddisk scripts updated" + printf $GREEN_LINE +} + +up_pulldocker() { + ARCH=$(dpkg --print-architecture) + printStr yellow "update: pulldocker" + dl_get "update/soft_init/pulldocker-${ARCH}" /tmp + mv /tmp/pulldocker-${ARCH} /usr/bin/pulldocker + chmod +x /usr/bin/pulldocker + printStr yellow "scripts updated" + printf $GREEN_LINE +} +get_cpuid +#ota_script +#up_histb +up_vipupgrade +up_kaitongfrp +up_nasupgrade +#up_chatgpt +#up_alist +#up_justlist +#up_TestNAT +#up_ksrun +up_pulldocker +up_deb +up_installdisk + +_exit 0 "all upgraded successed" diff --git a/static/phpinfo.php b/static/phpinfo.php new file mode 100644 index 0000000..56a65a5 --- /dev/null +++ b/static/phpinfo.php @@ -0,0 +1,48 @@ +ID)) { return $conf; } $sqlite3Version = class_exists('SQLite3') ? SQLite3::version() : false; $conf[$this->ID] = array( 'sqlite3' => $sqlite3Version ? $sqlite3Version['versionString'] : false, 'sqliteLibversion' => \function_exists('sqlite_libversion') ? sqlite_libversion() : false, 'mysqliClientVersion' => \function_exists('mysqli_get_client_version') ? mysqli_get_client_version() : false, 'mongo' => class_exists('Mongo'), 'mongoDb' => class_exists('MongoDB'), 'postgreSql' => \function_exists('pg_connect'), 'paradox' => \function_exists('px_new'), 'msSql' => \function_exists('sqlsrv_server_info'), 'pdo' => class_exists('PDO') ? implode(',', PDO::getAvailableDrivers()) : false, ); return $conf; }); } } namespace InnStudio\Prober\Components\Database; class DatabaseConstants { protected $ID = 'database'; } namespace InnStudio\Prober\Components\Database; final class Database { public function __construct() { new Conf(); } } namespace InnStudio\Prober\Components\Nodes; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Rest\StatusCode; final class Fetch extends NodesApi { public function __construct() { EventsApi::on('init', function ($action) { switch ($action) { case 'nodes': EventsApi::emit('fetchNodesBefore'); $response = new RestResponse(EventsApi::emit('nodes', array())); $response->json()->end(); case 'node': EventsApi::emit('fetchNodeBefore'); $nodeId = filter_input(\INPUT_GET, 'nodeId', \FILTER_DEFAULT); $response = new RestResponse(); if ( ! $nodeId) { $response->setStatus(StatusCode::$BAD_REQUEST)->json()->end(); } $data = $this->getNodeData($nodeId); if ( ! $data) { $response->setStatus(StatusCode::$NO_CONTENT)->json()->end(); } $response->setData($data)->json()->end(); } return $action; }, 100); } private function getNodeData($nodeId) { foreach ($this->getNodes() as $item) { if ( ! isset($item['id']) || ! isset($item['url']) || $item['id'] !== $nodeId) { continue; } return $this->getRemoteContent("{$item['url']}?action=fetch"); } } private function getRemoteContent($url) { $content = ''; if (\function_exists('curl_init')) { $ch = curl_init(); curl_setopt_array($ch, array( \CURLOPT_URL => $url, \CURLOPT_RETURNTRANSFER => true, )); $content = curl_exec($ch); curl_close($ch); return json_decode($content, true) ?: null; } return json_decode(file_get_contents($url), true) ?: null; } } namespace InnStudio\Prober\Components\Nodes; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends NodesApi { public function __construct() { EventsApi::on('conf', function (array $conf) { if (XconfigApi::isDisabled($this->ID)) { return $conf; } $conf[$this->ID] = array( 'items' => $this->getNodes(), ); return $conf; }); } } namespace InnStudio\Prober\Components\Nodes; final class Nodes { public function __construct() { new Conf(); new Fetch(); } } namespace InnStudio\Prober\Components\Nodes; use InnStudio\Prober\Components\Xconfig\XconfigApi; class NodesApi { public $ID = 'nodes'; public function getNodes() { $items = XconfigApi::getNodes(); if ( ! $items || ! \is_array($items)) { return array(); } return array_filter(array_map(function ($item) { if (2 !== \count($item)) { return; } return array( 'id' => $item[0], 'url' => $item[1], ); }, $items)); } } namespace InnStudio\Prober\Components\ServerInfo; class ServerInfoConstants { protected $ID = 'serverInfo'; protected $FEATURE_SERVER_IP = 'serverIp'; } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Utils\UtilsDisk; use InnStudio\Prober\Components\Utils\UtilsTime; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Fetch extends ServerInfoConstants { public function __construct() { EventsApi::on('fetch', array($this, 'filter')); EventsApi::on('nodes', array($this, 'filter')); } public function filter(array $items) { if (XconfigApi::isDisabled($this->ID)) { return $items; } $items[$this->ID] = array( 'serverUtcTime' => UtilsTime::getUtcTime(), 'serverTime' => UtilsTime::getTime(), 'serverUptime' => UtilsTime::getUptime(), 'diskUsage' => array( 'value' => UtilsDisk::getTotal() - UtilsDisk::getFree(), 'max' => UtilsDisk::getTotal(), ), ); return $items; } } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Utils\UtilsServerIp; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class ServerInitIpv4 extends ServerInfoConstants { public function __construct() { EventsApi::on('init', function ($action) { if ('serverIpv4' !== $action) { return $action; } if (XconfigApi::isDisabled($this->ID)) { return $action; } if (XconfigApi::isDisabled($this->FEATURE_SERVER_IP)) { return $action; } $response = new RestResponse(); $response->setData(array( 'ip' => UtilsServerIp::getV4(), ))->json()->end(); }); } } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Rest\StatusCode; use InnStudio\Prober\Components\Utils\UtilsLocation; use InnStudio\Prober\Components\Utils\UtilsServerIp; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class ServerLocationIpv4 extends ServerInfoConstants { public function __construct() { EventsApi::on('init', function ($action) { if ('serverLocationIpv4' !== $action) { return $action; } if (XconfigApi::isDisabled($this->ID)) { return $action; } if (XconfigApi::isDisabled($this->FEATURE_SERVER_IP)) { return $action; } $response = new RestResponse(); $ip = UtilsServerIp::getV4(); if ( ! $ip) { $response->setStatus(StatusCode::$BAD_REQUEST)->json()->end(); } $response->setData(UtilsLocation::getLocation($ip))->json()->end(); }); } } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Utils\UtilsCpu; use InnStudio\Prober\Components\Utils\UtilsDisk; use InnStudio\Prober\Components\Utils\UtilsTime; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends ServerInfoConstants { public function __construct() { EventsApi::on('conf', function (array $conf) { if (XconfigApi::isDisabled($this->ID)) { return $conf; } $conf[$this->ID] = array( 'serverName' => $this->getServerInfo('SERVER_NAME'), 'serverUtcTime' => UtilsTime::getUtcTime(), 'serverTime' => UtilsTime::getTime(), 'serverUptime' => UtilsTime::getUptime(), 'serverIp' => XconfigApi::isDisabled('serverIp') ? '-' : $this->getServerInfo('SERVER_ADDR'), 'serverSoftware' => $this->getServerInfo('SERVER_SOFTWARE'), 'phpVersion' => \PHP_VERSION, 'cpuModel' => UtilsCpu::getModel(), 'serverOs' => php_uname(), 'scriptPath' => __FILE__, 'diskUsage' => array( 'value' => UtilsDisk::getTotal() - UtilsDisk::getFree(), 'max' => UtilsDisk::getTotal(), ), ); return $conf; }); } private function getServerInfo($key) { return isset($_SERVER[$key]) ? $_SERVER[$key] : ''; } } namespace InnStudio\Prober\Components\ServerInfo; final class ServerInfo { public function __construct() { new Conf(); new Fetch(); new ServerInitIpv4(); new ServerInitIpv6(); new ServerLocationIpv4(); } } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Utils\UtilsServerIp; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class ServerInitIpv6 extends ServerInfoConstants { public function __construct() { EventsApi::on('init', function ($action) { if ('serverIpv6' !== $action) { return $action; } if (XconfigApi::isDisabled($this->ID)) { return $action; } if (XconfigApi::isDisabled($this->FEATURE_SERVER_IP)) { return $action; } $response = new RestResponse(); $response->setData(array( 'ip' => UtilsServerIp::getV6(), ))->json()->end(); }); } } namespace InnStudio\Prober\Components\Bootstrap; use InnStudio\Prober\Components\Config\ConfigApi; use InnStudio\Prober\Components\Events\EventsApi; final class Conf extends BootstrapConstants { public function __construct() { EventsApi::on('conf', function (array $conf) { $conf[$this->ID] = array( 'isDev' => XPROBER_IS_DEV, 'version' => ConfigApi::$APP_VERSION, 'appName' => ConfigApi::$APP_NAME, 'appUrl' => ConfigApi::$APP_URL, 'appConfigUrls' => ConfigApi::$APP_CONFIG_URLS, 'appConfigUrlDev' => ConfigApi::$APP_CONFIG_URL_DEV, 'authorUrl' => ConfigApi::$AUTHOR_URL, 'authorName' => ConfigApi::$AUTHOR_NAME, 'authorization' => isset($_SERVER['HTTP_AUTHORIZATION']) ? $_SERVER['HTTP_AUTHORIZATION'] : '', ); return $conf; }); } } namespace InnStudio\Prober\Components\Bootstrap; use InnStudio\Prober\Components\Config\ConfigApi; use InnStudio\Prober\Components\Events\EventsApi; final class Render { public function __construct() { $appName = ConfigApi::$APP_NAME; $version = ConfigApi::$APP_VERSION; $scriptConf = json_encode(EventsApi::emit('conf', array())); $styleUrl = \defined('XPROBER_IS_DEV') && XPROBER_IS_DEV ? 'app.css' : "?action=style&v={$version}"; $scriptUrl = \defined('XPROBER_IS_DEV') && XPROBER_IS_DEV ? 'app.js' : "?action=script&v={$version}"; echo << + + + + + + +{$appName} v{$version} + + + + + +
+
⏳ Loading...
+
+ + +HTML; +} } namespace InnStudio\Prober\Components\Bootstrap; final class Bootstrap { public function __construct() { new Action(); new Conf(); new Render(); } } namespace InnStudio\Prober\Components\Bootstrap; class BootstrapConstants { protected $ID = 'bootstrap'; } namespace InnStudio\Prober\Components\Bootstrap; use InnStudio\Prober\Components\Events\EventsApi; final class Action { public function __construct() { $action = (string) filter_input(\INPUT_GET, 'action', \FILTER_DEFAULT); EventsApi::emit('init', $action); if ($action) { http_response_code(400); exit; } } } namespace InnStudio\Prober\Components\Xconfig; use InnStudio\Prober\Components\Utils\UtilsApi; final class XconfigApi { private static $conf; private static $filename = 'xconfig.json'; public static function isDisabled($id) { return \in_array($id, self::get('disabled') ?: array(), true); } public static function getNodes() { return self::get('nodes') ?: array(); } public static function get($id = null) { self::setConf(); if ($id) { return isset(self::$conf[$id]) ? self::$conf[$id] : null; } return self::$conf; } private static function getFilePath() { if ( ! \defined('\\XPROBER_DIR')) { return ''; } if (\defined('\\XPROBER_IS_DEV') && XPROBER_IS_DEV) { return \dirname(XPROBER_DIR) . '/' . self::$filename; } return XPROBER_DIR . '/' . self::$filename; } private static function setConf() { if (null !== self::$conf) { return; } if ( ! is_readable(self::getFilePath())) { self::$conf = null; return; } $conf = UtilsApi::jsonDecode(file_get_contents(self::getFilePath())); if ( ! $conf) { self::$conf = null; return; } self::$conf = $conf; } } namespace InnStudio\Prober\Components\Updater; use InnStudio\Prober\Components\Config\ConfigApi; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Rest\StatusCode; final class Updater { public function __construct() { EventsApi::on('init', function ($action) { if ('update' !== $action) { return $action; } $response = new RestResponse(); if ( ! is_writable(__FILE__)) { $response->setStatus(StatusCode::$INSUFFICIENT_STORAGE)->end(); } $code = ''; foreach (ConfigApi::$UPDATE_PHP_URLS as $url) { $code = (string) file_get_contents($url); if ('' !== trim($code)) { break; } } if ( ! $code) { $response->setStatus(StatusCode::$NOT_FOUND)->end(); } if (\defined('XPROBER_IS_DEV') && XPROBER_IS_DEV) { $response->end(); } if ((bool) file_put_contents(__FILE__, $code)) { if (\function_exists('opcache_invalidate')) { opcache_invalidate(__FILE__, true) || opcache_reset(); } $response->end(); } $response->setStatus(StatusCode::$INTERNAL_SERVER_ERROR)->end(); }); } } namespace InnStudio\Prober\Components\Fetch; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; final class Fetch { public function __construct() { EventsApi::on('init', function ($action) { if ('fetch' === $action) { EventsApi::emit('fetchBefore'); $response = new RestResponse(EventsApi::emit('fetch', array())); $response->json()->end(); } return $action; }, 100); } } namespace InnStudio\Prober\Components\ServerBenchmark; class ServerBenchmarkConstants { protected $ID = 'serverBenchmark'; } namespace InnStudio\Prober\Components\ServerBenchmark; use InnStudio\Prober\Components\Events\EventsApi; final class FetchBefore extends ServerBenchmarkApi { public function __construct() { EventsApi::on('fetchBefore', array($this, 'filter')); EventsApi::on('fetchNodesBefore', array($this, 'filter')); EventsApi::on('fetchNodeBefore', array($this, 'filter')); } public function filter() { while ($this->isRunning()) { sleep(2); } } } namespace InnStudio\Prober\Components\ServerBenchmark; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends ServerBenchmarkConstants { public function __construct() { EventsApi::on('conf', function (array $conf) { $conf[$this->ID] = array( 'disabledMyServerBenchmark' => XconfigApi::isDisabled('myServerBenchmark'), ); return $conf; }); } } namespace InnStudio\Prober\Components\ServerBenchmark; final class ServerBenchmark { public function __construct() { new Init(); new Conf(); new FetchBefore(); } } namespace InnStudio\Prober\Components\ServerBenchmark; use InnStudio\Prober\Components\Xconfig\XconfigApi; class ServerBenchmarkApi { public function getTmpRecorderPath() { return sys_get_temp_dir() . \DIRECTORY_SEPARATOR . 'xproberBenchmarkCool'; } public function setRecorder(array $data) { return (bool) file_put_contents($this->getTmpRecorderPath(), json_encode(array_merge($this->getRecorder(), $data))); } public function setExpired() { return (bool) $this->setRecorder(array( 'expired' => (int) $_SERVER['REQUEST_TIME'] + $this->cooldown(), )); } public function setIsRunning($isRunning) { return (bool) $this->setRecorder(array( 'isRunning' => true === (bool) $isRunning ? 1 : 0, )); } public function isRunning() { $recorder = $this->getRecorder(); return isset($recorder['isRunning']) ? 1 === (int) $recorder['isRunning'] : false; } public function getRemainingSeconds() { $recorder = $this->getRecorder(); $expired = isset($recorder['expired']) ? (int) $recorder['expired'] : 0; if ( ! $expired) { return 0; } return $expired > (int) $_SERVER['REQUEST_TIME'] ? $expired - (int) $_SERVER['REQUEST_TIME'] : 0; } public function getPointsByTime($time) { return pow(10, 3) - (int) ($time * pow(10, 3)); } public function getCpuPoints() { $data = 'inn-studio.com'; $hash = array('md5', 'sha512', 'sha256', 'crc32'); $start = microtime(true); $i = 0; while (microtime(true) - $start < .5) { foreach ($hash as $v) { hash($v, $data); } ++$i; } return $i; } public function getWritePoints() { $tmpDir = sys_get_temp_dir(); if ( ! is_writable($tmpDir)) { return 0; } $i = 0; $start = microtime(true); while (microtime(true) - $start < .5) { $filePath = "{$tmpDir}/innStudioWriteBenchmark:{$i}"; clearstatcache(true, $filePath); file_put_contents($filePath, $filePath); unlink($filePath); ++$i; } return $i; } public function getReadPoints() { $tmpDir = sys_get_temp_dir(); if ( ! is_readable($tmpDir)) { return 0; } $i = 0; $start = microtime(true); $filePath = "{$tmpDir}/innStudioIoBenchmark"; if ( ! file_exists($filePath)) { file_put_contents($filePath, 'innStudioReadBenchmark'); } while (microtime(true) - $start < .5) { clearstatcache(true, $filePath); file_get_contents($filePath); ++$i; } return $i; } public function getPoints() { return array( 'cpu' => $this->getMedian(array( $this->getCpuPoints(), $this->getCpuPoints(), $this->getCpuPoints(), )), 'write' => $this->getMedian(array( $this->getWritePoints(), $this->getWritePoints(), $this->getWritePoints(), )), 'read' => $this->getMedian(array( $this->getReadPoints(), $this->getReadPoints(), $this->getReadPoints(), )), ); } private function cooldown() { return (int) XconfigApi::get('serverBenchmarkCd') ?: 60; } private function getRecorder() { $path = $this->getTmpRecorderPath(); $defaults = array( 'expired' => 0, 'running' => 0, ); if ( ! @is_readable($path)) { return $defaults; } $data = (string) file_get_contents($path); if ( ! $data) { return $defaults; } $data = json_decode($data, true); if ( ! $data) { return $defaults; } return array_merge($defaults, $data); } private function getMedian(array $arr) { $count = \count($arr); sort($arr); $mid = floor(($count - 1) / 2); return ($arr[$mid] + $arr[$mid + 1 - $count % 2]) / 2; } } namespace InnStudio\Prober\Components\ServerBenchmark; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Rest\StatusCode; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Init extends ServerBenchmarkApi { public function __construct() { EventsApi::on('init', function ($action) { if (XconfigApi::isDisabled('myServerBenchmark')) { return $action; } if ('benchmark' !== $action) { return $action; } $this->render(); }); } private function render() { $remainingSeconds = $this->getRemainingSeconds(); $response = new RestResponse(); if ($remainingSeconds) { $response->setStatus(StatusCode::$TOO_MANY_REQUESTS); $response->setData(array( 'seconds' => $remainingSeconds, ))->json()->end(); } set_time_limit(0); $this->setExpired(); $this->setIsRunning(true); $marks = $this->getPoints(); $this->setIsRunning(false); $response->setData(array( 'marks' => $marks, ))->json()->end(); } } namespace InnStudio\Prober\Components\Timezone; use InnStudio\Prober\Components\Events\EventsApi; final class Timezone { public function __construct() { EventsApi::on('init', function ($action) { if ( ! \ini_get('date.timezone')) { date_default_timezone_set('PRC'); } return $action; }, 1); } } namespace InnStudio\Prober\Components\TemperatureSensor; use Exception; use InnStudio\Prober\Components\Config\ConfigApi; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Rest\StatusCode; final class TemperatureSensor { public function __construct() { EventsApi::on('init', function ($action) { if ('temperature-sensor' !== $action) { return $action; } $response = new RestResponse(); $items = $this->getItems(); if ($items) { $response->setData($items)->json()->end(); } $cpuTemp = $this->getCpuTemp(); if ( ! $cpuTemp) { $response->setStatus(StatusCode::$NO_CONTENT); } $items[] = array( 'id' => 'cpu', 'name' => 'CPU', 'celsius' => round((float) $cpuTemp / 1000, 2), ); $response->setData($items)->json()->end(); }); } private function curl($url) { if ( ! \function_exists('curl_init')) { return; } $ch = curl_init(); curl_setopt_array($ch, array( \CURLOPT_URL => $url, \CURLOPT_RETURNTRANSFER => true, )); $res = curl_exec($ch); curl_close($ch); return (string) $res; } private function getItems() { $items = array(); foreach (ConfigApi::$APP_TEMPERATURE_SENSOR_PORTS as $port) { $res = $this->curl(ConfigApi::$APP_TEMPERATURE_SENSOR_URL . ":{$port}"); if ( ! $res) { continue; } $item = json_decode($res, true); if ( ! $item || ! \is_array($item)) { continue; } $items = $item; break; } return $items; } private function getCpuTemp() { try { $path = '/sys/class/thermal/thermal_zone0/temp'; return file_exists($path) ? (int) file_get_contents($path) : 0; } catch (Exception $e) { return 0; } } } namespace InnStudio\Prober\Components\PhpExtensions; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends PhpExtensionsConstants { public function __construct() { EventsApi::on('conf', function (array $conf) { if (XconfigApi::isDisabled($this->ID)) { return $conf; } $jitEnabled = false; if (\function_exists('opcache_get_status')) { $status = opcache_get_status(); if (isset($status['jit']['enabled']) && true === $status['jit']['enabled']) { $jitEnabled = true; } } $conf[$this->ID] = array( 'redis' => \extension_loaded('redis') && class_exists('Redis'), 'sqlite3' => \extension_loaded('sqlite3') && class_exists('Sqlite3'), 'memcache' => \extension_loaded('memcache') && class_exists('Memcache'), 'memcached' => \extension_loaded('memcached') && class_exists('Memcached'), 'opcache' => \function_exists('opcache_get_status'), 'opcacheEnabled' => $this->isOpcEnabled(), 'opcacheJitEnabled' => $jitEnabled, 'swoole' => \extension_loaded('swoole') && \function_exists('swoole_version'), 'imagick' => \extension_loaded('imagick') && class_exists('Imagick'), 'gmagick' => \extension_loaded('gmagick'), 'exif' => \extension_loaded('exif') && \function_exists('exif_imagetype'), 'fileinfo' => \extension_loaded('fileinfo'), 'simplexml' => \extension_loaded('simplexml'), 'sockets' => \extension_loaded('sockets') && \function_exists('socket_accept'), 'mysqli' => \extension_loaded('mysqli') && class_exists('mysqli'), 'zip' => \extension_loaded('zip') && class_exists('ZipArchive'), 'mbstring' => \extension_loaded('mbstring') && \function_exists('mb_substr'), 'phalcon' => \extension_loaded('phalcon'), 'xdebug' => \extension_loaded('xdebug'), 'zendOptimizer' => \function_exists('zend_optimizer_version'), 'ionCube' => \extension_loaded('ioncube loader'), 'sourceGuardian' => \extension_loaded('sourceguardian'), 'ldap' => \function_exists('ldap_connect'), 'curl' => \function_exists('curl_init'), 'loadedExtensions' => XconfigApi::isDisabled('phpExtensionsLoaded') ? array() : get_loaded_extensions(), ); return $conf; }); } private function isOpcEnabled() { $isOpcEnabled = \function_exists('opcache_get_configuration'); if ($isOpcEnabled) { $isOpcEnabled = opcache_get_configuration(); $isOpcEnabled = isset($isOpcEnabled['directives']['opcache.enable']) && true === $isOpcEnabled['directives']['opcache.enable']; } return $isOpcEnabled; } } namespace InnStudio\Prober\Components\PhpExtensions; class PhpExtensionsConstants { protected $ID = 'phpExtensions'; } namespace InnStudio\Prober\Components\PhpExtensions; final class PhpExtensions { public function __construct() { new Conf(); } } namespace InnStudio\Prober\Components\NetworkStats; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Utils\UtilsApi; use InnStudio\Prober\Components\Utils\UtilsNetwork; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Fetch extends NetworkStatsConstants { public function __construct() { if ( ! UtilsApi::isWin()) { EventsApi::on('fetch', array($this, 'filter')); EventsApi::on('nodes', array($this, 'filter')); } } public function filter(array $items) { if (XconfigApi::isDisabled($this->ID)) { return $items; } $items[$this->ID] = array( 'networks' => UtilsNetwork::getStats(), 'timestamp' => time(), ); return $items; } } namespace InnStudio\Prober\Components\NetworkStats; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Utils\UtilsApi; use InnStudio\Prober\Components\Utils\UtilsNetwork; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends NetworkStatsConstants { public function __construct() { UtilsApi::isWin() || EventsApi::on('conf', function (array $conf) { if (XconfigApi::isDisabled($this->ID)) { return $conf; } $conf[$this->ID] = array( 'networks' => UtilsNetwork::getStats(), 'timestamp' => time(), ); return $conf; }); } } namespace InnStudio\Prober\Components\NetworkStats; final class NetworkStats { public function __construct() { new Conf(); new Fetch(); } } namespace InnStudio\Prober\Components\NetworkStats; class NetworkStatsConstants { protected $ID = 'networkStats'; } namespace InnStudio\Prober\Components\Config; class ConfigApi { public static $APP_VERSION = '8.16'; public static $APP_NAME = '海纳思系统探针'; public static $APP_URL = 'https://github.com/teasiu/x-prober'; public static $APP_CONFIG_URLS = array('https://raw.histb.eu.org/teasiu/x-prober/master/AppConfig.json'); public static $APP_CONFIG_URL_DEV = 'http://localhost:8000/AppConfig.json'; public static $APP_TEMPERATURE_SENSOR_URL = 'http://127.0.0.1'; public static $APP_TEMPERATURE_SENSOR_PORTS = array(2048, 4096); public static $AUTHOR_URL = 'https://www.ecoo.top'; public static $UPDATE_PHP_URLS = array('https://www.ecoo.top', 'https://bbs.histb.com'); public static $AUTHOR_NAME = '海纳思系统'; public static $LATEST_PHP_STABLE_VERSION = '8'; public static $LATEST_NGINX_STABLE_VERSION = '1.22.0'; } namespace InnStudio\Prober\Components\PhpInfo; use InnStudio\Prober\Components\Config\ConfigApi; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Rest\StatusCode; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class FetchLatestPhpVersion extends PhpInfoConstants { public function __construct() { EventsApi::on('init', function ($action) { if (XconfigApi::isDisabled($this->ID)) { return $action; } if ('latest-php-version' !== $action) { return $action; } $response = new RestResponse(); $content = file_get_contents('https://www.php.net/releases/?json'); if ( ! $content) { $response->setStatus(StatusCode::$NOT_FOUND)->end(); } $versions = json_decode($content, true); if ( ! $versions) { $response->setStatus(StatusCode::$NOT_FOUND)->end(); } $version = isset($versions[ConfigApi::$LATEST_PHP_STABLE_VERSION]['version']) ? $versions[ConfigApi::$LATEST_PHP_STABLE_VERSION]['version'] : ''; if ( ! $version) { $response->setStatus(StatusCode::$NOT_FOUND)->end(); } $response->setData(array( 'version' => $version, 'date' => $versions[ConfigApi::$LATEST_PHP_STABLE_VERSION]['date'], ))->json()->end(); }); } } namespace InnStudio\Prober\Components\PhpInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends PhpInfoConstants { public function __construct() { EventsApi::on('conf', function (array $conf) { if (XconfigApi::isDisabled($this->ID)) { return $conf; } $conf[$this->ID] = array( 'version' => \PHP_VERSION, 'sapi' => \PHP_SAPI, 'displayErrors' => (bool) \ini_get('display_errors'), 'errorReporting' => (int) \ini_get('error_reporting'), 'memoryLimit' => (string) \ini_get('memory_limit'), 'postMaxSize' => (string) \ini_get('post_max_size'), 'uploadMaxFilesize' => (string) \ini_get('upload_max_filesize'), 'maxInputVars' => (int) \ini_get('max_input_vars'), 'maxExecutionTime' => (int) \ini_get('max_execution_time'), 'defaultSocketTimeout' => (int) \ini_get('default_socket_timeout'), 'allowUrlFopen' => (bool) \ini_get('allow_url_fopen'), 'smtp' => (bool) \ini_get('SMTP'), 'disableFunctions' => XconfigApi::isDisabled('phpDisabledFunctions') ? array() : array_filter(explode(',', (string) \ini_get('disable_functions'))), 'disableClasses' => XconfigApi::isDisabled('phpDisabledClasses') ? array() : array_filter(explode(',', (string) \ini_get('disable_classes'))), ); return $conf; }); } } namespace InnStudio\Prober\Components\PhpInfo; final class PhpInfo { public function __construct() { new Conf(); new FetchLatestPhpVersion(); } } namespace InnStudio\Prober\Components\PhpInfo; class PhpInfoConstants { protected $ID = 'phpInfo'; } namespace InnStudio\Prober\Components\Ping; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends PingConstants { public function __construct() { EventsApi::on('conf', function (array $conf) { if (XconfigApi::isDisabled($this->ID)) { return $conf; } $conf[$this->ID] = array(); return $conf; }); } } namespace InnStudio\Prober\Components\Ping; class PingConstants { protected $ID = 'ping'; } namespace InnStudio\Prober\Components\Ping; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Ping extends PingConstants { public function __construct() { new Conf(); EventsApi::on('init', function ($action) { if (XconfigApi::isDisabled($this->ID)) { return $action; } if ($this->ID !== $action) { return $action; } $response = new RestResponse(array( 'time' => \defined('XPROBER_TIMER') ? microtime(true) - XPROBER_TIMER : 0, )); $response->json()->end(); }); } } namespace InnStudio\Prober\Components\Script; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Utils\UtilsApi; final class Script { public function __construct() { EventsApi::on('init', function ($action) { if ('script' !== $action) { return $action; } $this->output(); }); } private function output() { UtilsApi::setFileCacheHeader(); header('Content-type: application/javascript'); echo <<<'HTML' +!function(){var e={640:function(e,t,n){"use strict";var r=n(742),a={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var n,i,o,l,s,u,c=!1;t||(t={}),n=t.debug||!1;try{if(o=r(),l=document.createRange(),s=document.getSelection(),(u=document.createElement("span")).textContent=e,u.ariaHidden="true",u.style.all="unset",u.style.position="fixed",u.style.top=0,u.style.clip="rect(0, 0, 0, 0)",u.style.whiteSpace="pre",u.style.webkitUserSelect="text",u.style.MozUserSelect="text",u.style.msUserSelect="text",u.style.userSelect="text",u.addEventListener("copy",(function(r){if(r.stopPropagation(),t.format)if(r.preventDefault(),void 0===r.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var i=a[t.format]||a.default;window.clipboardData.setData(i,e)}else r.clipboardData.clearData(),r.clipboardData.setData(t.format,e);t.onCopy&&(r.preventDefault(),t.onCopy(r.clipboardData))})),document.body.appendChild(u),l.selectNodeContents(u),s.addRange(l),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");c=!0}catch(r){n&&console.error("unable to copy using execCommand: ",r),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),c=!0}catch(r){n&&console.error("unable to copy using clipboardData: ",r),n&&console.error("falling back to prompt"),i=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"\u2318":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(i,e)}}finally{s&&("function"==typeof s.removeRange?s.removeRange(l):s.removeAllRanges()),u&&document.body.removeChild(u),o()}return c}},448:function(e,t,n){"use strict";var r=n(294),a=n(840);function i(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n