├── .gitignore ├── .github └── FUNDING.yml ├── shells ├── image.jpg ├── common.sh ├── box.sh ├── kodi.sh ├── sony.sh └── tv.sh ├── dockerinfo ├── start.sh ├── docker-compose.yml ├── Dockerfile └── docker-CLI.yml ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://wkdaily.cpolar.cn/01 2 | -------------------------------------------------------------------------------- /shells/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wukongdaily/tvhelper-docker/HEAD/shells/image.jpg -------------------------------------------------------------------------------- /dockerinfo/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 启动SSH服务 4 | /usr/sbin/sshd 5 | 6 | # 启动ADB server 7 | adb start-server 8 | 9 | # 保持容器运行 10 | tail -f /dev/null -------------------------------------------------------------------------------- /shells/common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 定义红色文本 3 | RED='\033[0;31m' 4 | # 无颜色 5 | NC='\033[0m' 6 | GREEN='\e[38;5;154m' 7 | YELLOW="\e[93m" 8 | BLUE="\e[96m" 9 | # 赞助 10 | sponsor() { 11 | echo 12 | echo -e "${GREEN}悟空的赞赏码如下⬇${BLUE}" 13 | echo -e "${BLUE} https://wkdaily.cpolar.cn/upload/221342134.jpg${NC}" 14 | echo 15 | qrencode -t ANSIUTF8 'https://wkdaily.cpolar.cn/upload/221342134.jpg' 16 | echo 17 | } -------------------------------------------------------------------------------- /dockerinfo/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' # 使用docker-compose文件版本3.8 2 | 3 | services: 4 | tvhelper: 5 | build: . # 构建Dockerfile所在的当前目录 6 | image: wukongdaily/box:latest # 指定构建完成后的镜像名称和标签 7 | ports: 8 | - "2299:22" # 将容器的22端口映射到宿主机的2299端口,以便通过SSH访问 9 | volumes: 10 | - /tmp/upload/tvhelper_data:/tvhelper/shells/data # 根据需要映射数据卷,此处假设您希望持久化的数据位于./data目录 11 | restart: unless-stopped # 除非明确要求停止,否则总是重启容器 12 | environment: 13 | - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools 14 | -------------------------------------------------------------------------------- /dockerinfo/Dockerfile: -------------------------------------------------------------------------------- 1 | # 使用Alpine Linux作为基础镜像 2 | FROM alpine:latest 3 | 4 | # 安装ADB、Bash、Curl以及OpenSSH服务 5 | RUN apk update && apk add --no-cache android-tools bash curl openssh libqrencode-tools \ 6 | && rm -rf /var/cache/apk/* 7 | 8 | # 配置SSH服务 9 | RUN echo "root:password" | chpasswd \ 10 | && ssh-keygen -A \ 11 | && echo "cd /tvhelper/shells" >> /root/.profile \ 12 | && echo 'export PATH="$PATH:/usr/lib/android-sdk/platform-tools"' >> /root/.profile 13 | 14 | 15 | RUN git clone https://github.com/wukongdaily/tvhelper-docker.git /tvhelper 16 | 17 | # 为 /tvhelper/shells 目录下所有.sh文件设置可执行权限 18 | RUN find /tvhelper/shells -type f -iname "*.sh" -exec chmod +x {} \; 19 | 20 | # 设置SSH服务以允许远程登录 21 | RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \ 22 | && sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config 23 | 24 | # 开放22端口用于SSH连接 25 | EXPOSE 22 26 | 27 | # 设置工作目录 28 | WORKDIR /tvhelper/shells 29 | 30 | # 创建并设置启动脚本 31 | COPY start.sh /start.sh 32 | RUN chmod +x /start.sh 33 | 34 | # 使用start.sh作为容器的启动命令 35 | CMD ["/start.sh"] 36 | -------------------------------------------------------------------------------- /dockerinfo/docker-CLI.yml: -------------------------------------------------------------------------------- 1 | #Linux 电脑使用 2 | docker run -d \ 3 | --restart unless-stopped \ 4 | --name tvhelper \ 5 | -p 2299:22 \ 6 | -v "/tmp/upload/tvhelper_data:/tvhelper/shells/data" \ 7 | -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools \ 8 | wukongdaily/box:latest 9 | 10 | #Windows电脑使用-CMD写法 11 | docker run -d ^ 12 | --restart unless-stopped ^ 13 | --name tvhelper ^ 14 | -p 2299:22 ^ 15 | -v "%USERPROFILE%\Documents\tvhelper_data:/tvhelper/shells/data" ^ 16 | -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools ^ 17 | wukongdaily/box:latest 18 | 19 | 20 | #macOS苹果电脑写法 21 | docker run -d \ 22 | --restart unless-stopped \ 23 | --name tvhelper \ 24 | -p 2299:22 \ 25 | -v "$HOME/Documents/tvhelper_data:/tvhelper/shells/data" \ 26 | -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools \ 27 | wukongdaily/box:latest 28 | 29 | #群晖Synology NAS的写法 30 | #!/bin/sh 31 | synology_docker_storage=$(docker info 2>/dev/null | grep "Docker Root Dir" | cut -d: -f2 | xargs | sed 's/@//g') 32 | docker run -d \ 33 | --restart unless-stopped \ 34 | --name tvhelper \ 35 | -p 2299:22 \ 36 | -v "$synology_docker_storage:/tvhelper/shells/data" \ 37 | -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools \ 38 | wukongdaily/box:latest 39 | 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 盒子助手Docker版 V1.1.4 2 | ![拉取次数](https://img.shields.io/badge/Docker%20拉取次数-10万+-FF9900?&logo=docker&logoColor=blue&labelColor=000000&style=for-the-badge) 3 | [![Bilibili](https://img.shields.io/badge/Bilibili-123456?logo=bilibili&logoColor=fff&labelColor=fb7299&style=for-the-badge)](https://www.bilibili.com/video/BV1ChhdztEfZ/) 4 | [![YouTube](https://img.shields.io/badge/YouTube-123456?logo=youtube&labelColor=ff0000&style=for-the-badge)](https://youtu.be/DKFRZ8wevMo) 5 | ## 🤔 这是什么? 6 | 7 | 该项目可以让你使用电脑、NAS等一切能运行docker的设备变成盒子的ADB安装助手。让你的盒子用起来更加得心应手。
8 | docker主页: https://hub.docker.com/r/wukongdaily/box/tags 9 | 10 | ## 💡 特色功能 11 | 12 | - 💻 支持`一键修改安卓原生电视盒子/TV的NTP服务器地址` 13 | - 💻 支持`一键安装/data目录下所有apk/xapk/apkm (适合流媒体app)` 14 | - 💻 支持`SSH连接 且容器内ADB服务均已准备就绪,无需额外安装` 15 | - 🔑 支持`安装装机必备app 尤其是文件管理器和三方市场、图标等` 16 | - 🐋 支持`Docker compose和 docker cli`一键部署 17 | - 📕 支持`为国行Sony电视安装时下流行的流媒体应用` 18 | - ❓ 兼容`ARMv7/ARM64/x86_64 双平台设备 19 | - ❓ 其他功能和特点会持续迭代 20 | - MacOS(Apple芯片/Intel芯片)✅ 21 | - Windows 10/11 ✅ 22 | - Linux发行版 ✅ 23 | - NAS系统(群晖、威联通等)✅ 24 | - 软路由iStoreOS/OpenWrt/ImmortalWrt/eSir_OpenWrt等一切能用docker的op系统 ✅ 25 | 26 | 27 | ## 🚀 快速上手 28 | 29 | ### 1. 安装`Docker`和`Docker compose` 30 | 31 | - `Docker`安装教程:[https://docs.docker.com/engine/install/](https://docs.docker.com/engine/install/) 32 | - `Docker compose`安装教程:[https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/) 33 | - `个人普通电脑`安装教程:https://docs.docker.com/get-docker/ 34 | - docker 根目录剩余空间 至少大于1GB 35 | 36 | 37 | ### 2. 下载image(多平台统一) 38 | 39 | ```bash 40 | docker pull wukongdaily/box:latest 41 | ``` 42 | 43 | ### 3. 容器系统默认账号密码或环境变量 44 | 45 | - 容器内运行的就是Ubuntu系统。 46 | - ssh用户名和密码分别是:`root`和`password` 47 | - 推荐ssh端口映射到主机端口为2299。 48 | - 推荐把/data映射到宿主机某个目录 方便上传apk或xapk、apkm 49 | - 注意!映射ssh端口这一步并非是必须的,如果你需要用ssh连接容器则自行设置。 50 | - 根据自己的需求来映射,2299也不是固定的,映射的端口号多少都可以,只要跟主机不冲突即可。
51 | > 调用形式举例 52 | 53 | `ssh root@宿主机ip地址 -p 2299` 54 | 55 | > SSH常见错误举例和新手指南详见 56 | 57 | https://github.com/wukongdaily/HowToUseSSH
58 | - 容器内的环境变量 59 | - `PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools` 60 | 61 | 62 | ### 4. 运行 63 | - Windows电脑使用-CMD写法,注意不是powershell 且注意💡续行符^后不能有空格。数据目录默认映射到 【我的文档】 无需调整任何代码 64 | ```bash 65 | docker run -d ^ 66 | --restart unless-stopped ^ 67 | --name tvhelper ^ 68 | -p 2299:2299 ^ 69 | -p 2280:2280 ^ 70 | -p 15000:15000 ^ 71 | -v "%USERPROFILE%\Documents\tvhelper_data:/data" ^ 72 | -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools ^ 73 | wukongdaily/box:latest 74 | 75 | ``` 76 | ### 随后的步骤是执行tv.sh 如图 切换到Exec 选项 77 | image 78 | 79 | ### 执行后如图所示 出现一个菜单 你可以使用15000端口的网页 上传流媒体的apk、apkm、xapk 80 | image 81 | 82 | 83 | 84 | 85 | - Linux 使用下列命令,数据目录默认映射到linux的`/tmp/upload/`下 86 | ```bash 87 | docker run -d \ 88 | --restart unless-stopped \ 89 | --name tvhelper \ 90 | -p 2299:2299 \ 91 | -p 2280:2280 \ 92 | -p 15000:15000 \ 93 | -v "/tmp/upload/tvhelper_data:/data" \ 94 | -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools \ 95 | wukongdaily/box:latest 96 | ``` 97 | - macOS苹果电脑写法,数据目录默认映射到mac电脑文稿目录下 98 | ```bash 99 | docker run -d \ 100 | --restart unless-stopped \ 101 | --name tvhelper \ 102 | -p 2299:2299 \ 103 | -p 2280:2280 \ 104 | -p 15000:15000 \ 105 | -v "$HOME/Documents/tvhelper_data:/data" \ 106 | -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools \ 107 | wukongdaily/box:latest 108 | ``` 109 | 110 | - UNRAID 写法,注意容器内的data目录默认映射到 /mnt/user/appdata/,你可以适当修改成别的空间的路径。 111 | ```bash 112 | docker run -d \ 113 | --name='tvhelper' \ 114 | --net='bridge' \ 115 | -e HOST_OS="Unraid" \ 116 | -e HOST_HOSTNAME="unraid" \ 117 | -e HOST_CONTAINERNAME="tvhelper" \ 118 | -e 'PATH'='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools' \ 119 | -l net.unraid.docker.managed=dockerman \ 120 | -p '2299:2299/tcp' \ 121 | -p '2280:2280/tcp' \ 122 | -p '15000:15000/tcp' \ 123 | -v '/mnt/user/appdata/':'/tvhelper/shells/data':'rw' 'wukongdaily/box' 124 | ``` 125 | 126 | 127 | ## CasaOS docker compose 128 | ```bash 129 | version: '3.8' # 使用docker-compose文件版本3.8 130 | 131 | services: 132 | tvhelper: 133 | build: . # 构建Dockerfile所在的当前目录 134 | image: wukongdaily/box:latest # 指定构建完成后的镜像名称和标签 135 | ports: 136 | - "2299:2299" # 用于ssh 137 | - "2280:2280" # 用于重定向到盒子助手资讯页 138 | - "15000:15000" # 将容器的15000端口映射到宿主机的15000端口,以便通过浏览器dufs文件服务器 上传xapk或者apk 139 | volumes: 140 | - /tmp/upload/tvhelper_data:/data # 根据需要映射数据卷,此处假设您希望持久化的数据位于./data目录 141 | restart: unless-stopped # 除非明确要求停止,否则总是重启容器 142 | environment: 143 | - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools 144 | 145 | ``` 146 | 147 | ### 5. 如何导入本地镜像tar 148 | - 若需离线包 可在工作流里自行构建 fork该项目后 在action中构建即可 几秒后就构建成功 在release中下载离线包 149 | https://github.com/wukongdaily/DockerTarBuilder/ 150 | - docker离线包的格式是tar.gz 通常无需解压 docker load的过程就会解压了。 151 | 152 | #### Windows 举例 153 | ```bash 154 | docker load < "%USERPROFILE%\Documents\tvhelper-amd64.tar.gz" 155 | ``` 156 | 157 | #### Linux/OpenWrt 举例 158 | ```bash 159 | docker load < /mnt/sata1.3-1/tvhelper.tar.gz 160 | ``` 161 | 162 | ### 辅助视频教程⬇️ 163 | 164 | [在线教学视频 长视频](https://youtu.be/xAk-3TxeXxQ) 165 | 166 | 167 | 168 | ## 🗂️ 鸣谢 169 | 170 | 本项目的开发参照了以下项目,感谢这些开源项目的作者: 171 | ### DUFS 172 | https://github.com/sigoden/dufs 173 | ### TVBox 174 | https://github.com/takagen99/Box 175 | ### Sun-Panel 176 | https://github.com/hslr-s/sun-panel 177 | 178 | ## ❤️用真金白银鼓励作者 179 | 180 | [![点击这里赞助我](https://img.shields.io/badge/点击这里赞助我-支持作者的项目-orange?logo=github&style=for-the-badge)](https://wkdaily.cpolar.cn/01) 181 | 182 | https://wkdaily.cpolar.cn/01 183 | -------------------------------------------------------------------------------- /shells/box.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # wget -O box.sh https://cafe.cpolar.cn/wkdaily/tvhelper-docker/raw/branch/master/shells/box.sh && chmod +x box.sh && ./box.sh 3 | #******************************************************** 4 | source common.sh 5 | apk_path="/tvhelper/apks/" 6 | # 定义红色文本 7 | RED='\033[0;31m' 8 | # 无颜色 9 | NC='\033[0m' 10 | GREEN='\e[38;5;154m' 11 | YELLOW="\e[93m" 12 | BLUE="\e[96m" 13 | 14 | # 菜单选项数组 15 | declare -a menu_options 16 | declare -A commands 17 | 18 | 19 | # 判断adb是否连接成功 20 | check_adb_connected() { 21 | # 获取 adb devices 输出,跳过第一行(标题行),并检查每一行的状态 22 | local connected_devices=$(adb devices | awk 'NR>1 {print $2}' | grep 'device$') 23 | # 检查是否有设备已连接并且状态为 'device',即已授权 24 | if [[ -n $connected_devices ]]; then 25 | # ADB 已连接并且设备已授权 26 | return 0 27 | else 28 | # ADB 设备未连接或未授权 29 | return 1 30 | fi 31 | } 32 | 33 | # 连接adb 34 | connect_adb() { 35 | adb disconnect >/dev/null 2>&1 36 | echo -e "${YELLOW}请手动输入电视盒子的完整IP地址:${NC}" 37 | read ip 38 | echo -e "${BLUE}首次使用,盒子上可能会提示授权弹框,给您半分钟时间来操作...【允许】${NC}" 39 | adb connect ${ip} 40 | 41 | # 循环检测连接状态 42 | for ((i = 1; i <= 30; i++)); do 43 | echo -e "${YELLOW}第${i}次尝试连接ADB,请在设备上点击【允许】按钮...${NC}" 44 | device_status=$(adb devices | grep "${ip}:5555" | awk '{print $2}') 45 | if [[ "$device_status" == "device" ]]; then 46 | echo -e "${GREEN}ADB 已经连接成功啦,你可以放心操作了${NC}" 47 | return 0 48 | fi 49 | sleep 1 # 每次检测间隔1秒 50 | done 51 | echo -e "${RED}连接超时,或者您点击了【取消】,请确认电视盒子的IP地址是否正确。如果问题持续存在,请检查设备的USB调试设置是否正确并重新连接adb${NC}" 52 | } 53 | 54 | # 显示当前时区 55 | show_timezone() { 56 | adb shell getprop persist.sys.timezone 57 | } 58 | 59 | #断开adb连接 60 | disconnect_adb() { 61 | adb disconnect >/dev/null 2>&1 62 | echo "ADB 已经断开" 63 | } 64 | 65 | get_status() { 66 | if check_adb_connected; then 67 | adb_status="${GREEN}已连接且已授权${NC}" 68 | else 69 | adb_status="${RED}未连接${NC}" 70 | fi 71 | echo -e "* 与电视盒子的连接状态:$adb_status" 72 | } 73 | 74 | # 获取电视盒子型号 75 | get_tvbox_model_name() { 76 | if check_adb_connected; then 77 | # 获取设备型号 78 | local model=$(adb shell getprop ro.product.model) 79 | # 获取设备制造商 80 | local manufacturer=$(adb shell getprop ro.product.manufacturer) 81 | # 清除换行符 82 | model=$(echo $model | tr -d '\r' | tr -d '\n') 83 | manufacturer=$(echo $manufacturer | tr -d '\r' | tr -d '\n') 84 | echo -e "* 当前电视盒子型号:${BLUE}$manufacturer $model${NC}" 85 | else 86 | echo -e "* 当前电视盒子型号:${BLUE}请先连接ADB${NC}" 87 | fi 88 | } 89 | 90 | # 获取电视盒子时区 91 | get_tvbox_timezone() { 92 | if check_adb_connected; then 93 | # 获取设备时区 94 | device_timezone=$(adb shell getprop persist.sys.timezone) 95 | # 获取设备系统时间,格式化为“年月日 时:分” 96 | device_time=$(adb shell date "+%Y年%m月%d日 %H:%M") 97 | 98 | echo -e "* 当前电视盒子时区:${YELLOW}$device_timezone${NC}" 99 | echo -e "* 当前电视盒子时间:${YELLOW}$device_time${NC}" 100 | else 101 | echo -e "* 当前电视盒子时区:${BLUE}请先连接ADB${NC}" 102 | echo -e "* 当前电视盒子时间:${BLUE}请先连接ADB${NC}" 103 | fi 104 | } 105 | 106 | 107 | # 安装apk 108 | install_apk() { 109 | local apk_local_path=$1 110 | local package_name=$2 111 | local filename=$(basename "$apk_local_path") 112 | if check_adb_connected; then 113 | # 卸载旧版本的APK(如果存在) 114 | adb uninstall "$package_name" >/dev/null 2>&1 115 | echo -e "${GREEN}正在推送和安装${filename},请耐心等待...${NC}" 116 | 117 | # 模拟安装进度 118 | echo -ne "${BLUE}" 119 | while true; do 120 | echo -n ".." 121 | sleep 1 122 | done & 123 | 124 | # 保存进度指示进程的PID 125 | PROGRESS_PID=$! 126 | install_result=$(adb install -r $apk_local_path 2>&1) 127 | 128 | # 安装完成后,终止进度指示进程 129 | kill $PROGRESS_PID 130 | wait $PROGRESS_PID 2>/dev/null 131 | echo -e "${NC}\n" 132 | 133 | # 检查安装结果 134 | if [[ $install_result == *"Success"* ]]; then 135 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 136 | else 137 | echo -e "${RED}APK安装失败:$install_result${NC}" 138 | fi 139 | else 140 | connect_adb 141 | fi 142 | } 143 | 144 | # 安装TVBox 145 | install_tvbox() { 146 | install_apk "${apk_path}TVBox.apk" "com.github.tvbox.osc.wk" 147 | } 148 | 149 | # 菜单 150 | menu_options=( 151 | "连接ADB" 152 | "断开ADB" 153 | "安装TVBox(编译时间:2024-06-28)" 154 | "赞助|打赏" 155 | ) 156 | 157 | commands=( 158 | ["连接ADB"]="connect_adb" 159 | ["断开ADB"]="disconnect_adb" 160 | ["安装TVBox(编译时间:2024-02-28)"]="install_tvbox" 161 | ["赞助|打赏"]="sponsor" 162 | 163 | ) 164 | 165 | # 处理菜单 166 | handle_choice() { 167 | local choice=$1 168 | # 检查输入是否为空 169 | if [[ -z $choice ]]; then 170 | echo -e "${RED}输入不能为空,请重新选择。${NC}" 171 | return 172 | fi 173 | 174 | # 检查输入是否为数字 175 | if ! [[ $choice =~ ^[0-9]+$ ]]; then 176 | echo -e "${RED}请输入有效数字!${NC}" 177 | return 178 | fi 179 | 180 | # 检查数字是否在有效范围内 181 | if [[ $choice -lt 1 ]] || [[ $choice -gt ${#menu_options[@]} ]]; then 182 | echo -e "${RED}选项超出范围!${NC}" 183 | echo -e "${YELLOW}请输入 1 到 ${#menu_options[@]} 之间的数字。${NC}" 184 | return 185 | fi 186 | 187 | local selected_option="${menu_options[$choice - 1]}" 188 | local command_to_run="${commands[$selected_option]}" 189 | 190 | # 检查是否存在对应的命令 191 | if [ -z "$command_to_run" ]; then 192 | echo -e "${RED}无效选项,请重新选择。${NC}" 193 | return 194 | fi 195 | 196 | # 使用eval执行命令 197 | eval "$command_to_run" 198 | } 199 | 200 | show_menu() { 201 | current_date=$(date +%Y%m%d) 202 | mkdir -p /tvhelper/shells/data 203 | clear 204 | echo "***********************************************************************" 205 | echo -e "* ${YELLOW}TVBOX助手 Docker版 (${current_date})${NC} " 206 | echo -e "* ${RED}请确保电视盒子和Docker宿主机处于${NC}${BLUE}同一网段${NC}\n* ${RED}且电视盒子开启了${NC}${BLUE}USB调试模式(adb开关)${NC} " 207 | echo "* Developed by @wukongdaily " 208 | echo "**********************************************************************" 209 | echo 210 | echo "$(get_status)" 211 | echo "$(get_tvbox_model_name)" 212 | echo "$(get_tvbox_timezone)" 213 | echo 214 | echo "**********************************************************************" 215 | echo "请选择操作:" 216 | for i in "${!menu_options[@]}"; do 217 | echo -e "${BLUE}$((i + 1)). ${menu_options[i]}${NC}" 218 | done 219 | } 220 | 221 | while true; do 222 | show_menu 223 | read -p "请输入选项的序号(输入q退出): " choice 224 | if [[ $choice == 'q' ]]; then 225 | break 226 | fi 227 | handle_choice $choice 228 | echo "按任意键继续..." 229 | read -n 1 # 等待用户按键 230 | done 231 | -------------------------------------------------------------------------------- /shells/kodi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # wget -O kodi.sh https://cafe.cpolar.cn/wkdaily/tvhelper-docker/raw/branch/master/shells/kodi.sh && chmod +x kodi.sh && ./kodi.sh 3 | 4 | #******************************************************** 5 | source common.sh 6 | # 定义红色文本 7 | RED='\033[0;31m' 8 | # 无颜色 9 | NC='\033[0m' 10 | GREEN='\e[38;5;154m' 11 | YELLOW="\e[93m" 12 | BLUE="\e[96m" 13 | 14 | # 菜单选项数组 15 | declare -a menu_options 16 | declare -A commands 17 | 18 | # 判断adb是否连接成功 19 | check_adb_connected() { 20 | # 获取 adb devices 输出,跳过第一行(标题行),并检查每一行的状态 21 | local connected_devices=$(adb devices | awk 'NR>1 {print $2}' | grep 'device$') 22 | # 检查是否有设备已连接并且状态为 'device',即已授权 23 | if [[ -n $connected_devices ]]; then 24 | # ADB 已连接并且设备已授权 25 | return 0 26 | else 27 | # ADB 设备未连接或未授权 28 | return 1 29 | fi 30 | } 31 | 32 | 33 | 34 | # 连接adb 35 | connect_adb() { 36 | adb disconnect >/dev/null 2>&1 37 | echo -e "${YELLOW}请手动输入电视盒子的完整IP地址:${NC}" 38 | read ip 39 | echo -e "${BLUE}首次使用,盒子上可能会提示授权弹框,给您半分钟时间来操作...【允许】${NC}" 40 | adb connect ${ip} 41 | 42 | # 循环检测连接状态 43 | for ((i = 1; i <= 30; i++)); do 44 | echo -e "${YELLOW}第${i}次尝试连接ADB,请在设备上点击【允许】按钮...${NC}" 45 | device_status=$(adb devices | grep "${ip}:5555" | awk '{print $2}') 46 | if [[ "$device_status" == "device" ]]; then 47 | echo -e "${GREEN}ADB 已经连接成功啦,你可以放心操作了${NC}" 48 | return 0 49 | fi 50 | sleep 1 # 每次检测间隔1秒 51 | done 52 | echo -e "${RED}连接超时,或者您点击了【取消】,请确认电视盒子的IP地址是否正确。如果问题持续存在,请检查设备的USB调试设置是否正确并重新连接adb${NC}" 53 | } 54 | 55 | # 显示当前时区 56 | show_timezone() { 57 | adb shell getprop persist.sys.timezone 58 | } 59 | 60 | #断开adb连接 61 | disconnect_adb() { 62 | adb disconnect >/dev/null 2>&1 63 | echo "ADB 已经断开" 64 | } 65 | 66 | # 向电视盒子输入英文 67 | input_text() { 68 | echo -e "${BLUE}注意注意注意!请弹出键盘后再执行!每次输入会自动清空上次结果${NC}" 69 | if check_adb_connected; then 70 | while true; do 71 | echo "请输入英文、数字或特定字符(如IP地址等) 输入q退出。输入【qk】删除20个字符。" 72 | read str 73 | if [[ $str == "q" ]]; then 74 | echo -e "${GREEN}退出输入模式。${NC}" 75 | break # 当用户输入q时退出循环 76 | elif [[ $str == "qk" ]]; then 77 | # 删除20个字符 78 | for i in {1..20}; do 79 | adb shell input keyevent KEYCODE_DEL 80 | done 81 | echo -e "${RED}哈哈!你可真够懒的!已帮你删除20个字符。继续输入或者输入q退出。${NC}" 82 | elif [[ $str =~ [^a-zA-Z0-9\.\-\/\:] ]]; then 83 | echo -e "${RED}adb不支持输入中文,请重新输入${NC}" 84 | else 85 | # 输入文本 86 | adb shell input text "${str}" 87 | echo -e "${GREEN}[OK] 已发送! 继续输入或者输入q退出。${NC}" 88 | fi 89 | done 90 | else 91 | connect_adb 92 | fi 93 | } 94 | 95 | get_status() { 96 | if check_adb_connected; then 97 | adb_status="${GREEN}已连接且已授权${NC}" 98 | else 99 | adb_status="${RED}未连接${NC}" 100 | fi 101 | echo -e "* 与电视盒子的连接状态:$adb_status" 102 | } 103 | 104 | # 获取电视盒子型号 105 | get_tvbox_model_name() { 106 | if check_adb_connected; then 107 | # 获取设备型号 108 | local model=$(adb shell getprop ro.product.model) 109 | # 获取设备制造商 110 | local manufacturer=$(adb shell getprop ro.product.manufacturer) 111 | # 清除换行符 112 | model=$(echo $model | tr -d '\r' | tr -d '\n') 113 | manufacturer=$(echo $manufacturer | tr -d '\r' | tr -d '\n') 114 | echo -e "* 当前电视盒子型号:${BLUE}$manufacturer $model${NC}" 115 | else 116 | echo -e "* 当前电视盒子型号:${BLUE}请先连接ADB${NC}" 117 | fi 118 | } 119 | 120 | # 获取电视盒子时区 121 | get_tvbox_timezone() { 122 | if check_adb_connected; then 123 | # 获取设备时区 124 | device_timezone=$(adb shell getprop persist.sys.timezone) 125 | # 获取设备系统时间,格式化为“年月日 时:分” 126 | device_time=$(adb shell date "+%Y年%m月%d日 %H:%M") 127 | 128 | echo -e "* 当前电视盒子时区:${YELLOW}$device_timezone${NC}" 129 | echo -e "* 当前电视盒子时间:${YELLOW}$device_time${NC}" 130 | else 131 | echo -e "* 当前电视盒子时区:${BLUE}请先连接ADB${NC}" 132 | echo -e "* 当前电视盒子时间:${BLUE}请先连接ADB${NC}" 133 | fi 134 | } 135 | 136 | # 设置KODI为简体中文 137 | set_kodi_to_chinese() { 138 | # 确保Kodi已经关闭 139 | adb shell am force-stop org.xbmc.kodi 140 | # Kodi的Add-ons目录路径,请根据实际情况进行修改 141 | KODI_ADDONS_PATH="/sdcard/Android/data/org.xbmc.kodi/files/.kodi/addons/" 142 | 143 | # 创建本地临时目录用于解压 144 | TEMP_DIR="/tmp/kodi_addons" 145 | mkdir -p "$TEMP_DIR" 146 | 147 | echo -e "${GREEN}解压中文语言包到本地临时目录...${NC}" 148 | unzip -o /tvhelper/kodi/resource.language.zh_cn-10.0.64.zip -d "$TEMP_DIR" 149 | 150 | # 1、推送整个解压后的文件夹到Kodi的Add-ons目录 151 | adb push "$TEMP_DIR" "$KODI_ADDONS_PATH" 152 | 153 | echo -e "${GREEN}中文语言包已安装至KODI,开始配置语言....${NC}" 154 | # 修改guisettings.xml以使用中文语言包 155 | local KODI_SETTINGS_PATH="/sdcard/Android/data/org.xbmc.kodi/files/.kodi/userdata/guisettings.xml" 156 | 157 | # 2、上传配置文件——更新 158 | adb push /tvhelper/kodi/guisettings.xml $KODI_SETTINGS_PATH 159 | echo -e "${GREEN}Kodi的字体和语言设置已更新,正在为您尝试打开KODI,请根据提示完成KODI初始化。${NC}" 160 | sleep 2 161 | # 重启Kodi 162 | #adb shell am start -a android.intent.action.MAIN -n org.xbmc.kodi/.Main 163 | adb shell monkey -p org.xbmc.kodi 1 >/dev/null 2>&1 164 | 165 | } 166 | 167 | # 安装apk 168 | install_apk() { 169 | local apk_local_path=$1 170 | local package_name=$2 171 | local filename=$(basename "$apk_local_path") 172 | 173 | # 检查APK文件是否存在 174 | if [ ! -f "$apk_local_path" ]; then 175 | echo -e "${RED}错误: APK文件不存在,请更新docker镜像后重试。${NC}" 176 | return 1 177 | fi 178 | 179 | if check_adb_connected; then 180 | # 卸载旧版本的APK(如果存在) 181 | echo -e "${GREEN}正在推送和安装${filename},请耐心等待...${NC}" 182 | adb uninstall "$package_name" >/dev/null 2>&1 183 | 184 | # 模拟安装进度 185 | echo -ne "${BLUE}" 186 | while true; do 187 | echo -n ".." 188 | sleep 1 189 | done & 190 | 191 | # 保存进度指示进程的PID 192 | PROGRESS_PID=$! 193 | install_result=$(adb install -r $apk_local_path 2>&1) 194 | 195 | # 安装完成后,终止进度指示进程 196 | kill $PROGRESS_PID 197 | wait $PROGRESS_PID 2>/dev/null 198 | echo -e "${NC}\n" 199 | 200 | # 检查安装结果 201 | if [[ $install_result == *"Success"* ]]; then 202 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 203 | set_kodi_to_chinese 204 | else 205 | echo -e "${RED}APK安装失败:$install_result${NC}" 206 | fi 207 | else 208 | connect_adb 209 | fi 210 | } 211 | 212 | # 安装KODI 213 | install_kodi() { 214 | install_apk "/tvhelper/kodi/kodi.apk" "org.xbmc.kodi" 215 | } 216 | 217 | # 菜单 218 | menu_options=( 219 | "连接ADB" 220 | "断开ADB" 221 | "安装KODI 20.5 并设置中文" 222 | #"设置KODI的语言为简体中文" 223 | "赞助|打赏" 224 | ) 225 | 226 | commands=( 227 | ["连接ADB"]="connect_adb" 228 | ["断开ADB"]="disconnect_adb" 229 | ["安装KODI 20.5 并设置中文"]="install_kodi" 230 | ["设置KODI的语言为简体中文"]="set_kodi_to_chinese" 231 | ["赞助|打赏"]="sponsor" 232 | ) 233 | 234 | # 处理菜单 235 | handle_choice() { 236 | local choice=$1 237 | # 检查输入是否为空 238 | if [[ -z $choice ]]; then 239 | echo -e "${RED}输入不能为空,请重新选择。${NC}" 240 | return 241 | fi 242 | 243 | # 检查输入是否为数字 244 | if ! [[ $choice =~ ^[0-9]+$ ]]; then 245 | echo -e "${RED}请输入有效数字!${NC}" 246 | return 247 | fi 248 | 249 | # 检查数字是否在有效范围内 250 | if [[ $choice -lt 1 ]] || [[ $choice -gt ${#menu_options[@]} ]]; then 251 | echo -e "${RED}选项超出范围!${NC}" 252 | echo -e "${YELLOW}请输入 1 到 ${#menu_options[@]} 之间的数字。${NC}" 253 | return 254 | fi 255 | 256 | local selected_option="${menu_options[$choice - 1]}" 257 | local command_to_run="${commands[$selected_option]}" 258 | 259 | # 检查是否存在对应的命令 260 | if [ -z "$command_to_run" ]; then 261 | echo -e "${RED}无效选项,请重新选择。${NC}" 262 | return 263 | fi 264 | 265 | # 使用eval执行命令 266 | eval "$command_to_run" 267 | } 268 | 269 | show_menu() { 270 | current_date=$(date +%Y%m%d) 271 | mkdir -p /tvhelper/shells/data 272 | clear 273 | echo "***********************************************************************" 274 | echo -e "* ${YELLOW}KODI设置助手Docker版 (${current_date})${NC} " 275 | echo -e "* ${GREEN}KODI太复杂了 必须得上手段了${NC} " 276 | echo -e "* ${RED}请确保电视盒子和Docker宿主机处于${NC}${BLUE}同一网段${NC}\n* ${RED}且电视盒子开启了${NC}${BLUE}USB调试模式(adb开关)${NC} " 277 | echo "* Developed by @wukongdaily " 278 | echo "**********************************************************************" 279 | echo 280 | echo "$(get_status)" 281 | echo "$(get_tvbox_model_name)" 282 | echo "$(get_tvbox_timezone)" 283 | echo 284 | echo "**********************************************************************" 285 | echo "请选择操作:" 286 | for i in "${!menu_options[@]}"; do 287 | echo -e "${BLUE}$((i + 1)). ${menu_options[i]}${NC}" 288 | done 289 | } 290 | 291 | while true; do 292 | show_menu 293 | read -p "请输入选项的序号(输入q退出): " choice 294 | if [[ $choice == 'q' ]]; then 295 | break 296 | fi 297 | handle_choice $choice 298 | echo "按任意键继续..." 299 | read -n 1 # 等待用户按键 300 | done 301 | -------------------------------------------------------------------------------- /shells/sony.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # wget -O sony.sh https://cafe.cpolar.cn/wkdaily/tvhelper-docker/raw/branch/master/shells/sony.sh && chmod +x sony.sh && ./sony.sh 3 | #******************************************************** 4 | source common.sh 5 | # 定义红色文本 6 | RED='\033[0;31m' 7 | # 无颜色 8 | NC='\033[0m' 9 | GREEN='\e[38;5;154m' 10 | YELLOW="\e[93m" 11 | BLUE="\e[96m" 12 | 13 | # 菜单选项数组 14 | declare -a menu_options 15 | declare -A commands 16 | 17 | # 检查输入是否为整数 18 | is_integer() { 19 | if [[ $1 =~ ^-?[0-9]+$ ]]; then 20 | return 0 # 0代表true/成功 21 | else 22 | return 1 # 非0代表false/失败 23 | fi 24 | } 25 | 26 | # 判断adb是否连接成功 27 | check_adb_connected() { 28 | # 获取 adb devices 输出,跳过第一行(标题行),并检查每一行的状态 29 | local connected_devices=$(adb devices | awk 'NR>1 {print $2}' | grep 'device$') 30 | # 检查是否有设备已连接并且状态为 'device',即已授权 31 | if [[ -n $connected_devices ]]; then 32 | # ADB 已连接并且设备已授权 33 | return 0 34 | else 35 | # ADB 设备未连接或未授权 36 | return 1 37 | fi 38 | } 39 | 40 | # 连接adb 41 | connect_adb() { 42 | adb disconnect >/dev/null 2>&1 43 | echo -e "${BLUE}请手动输入电视盒子的IP地址:${NC}" 44 | read ip 45 | echo -e "${BLUE}首次使用,盒子上可能会提示授权弹框,给您半分钟时间来操作...【允许】${NC}" 46 | adb connect ${ip} 47 | 48 | # 循环检测连接状态 49 | for ((i = 1; i <= 30; i++)); do 50 | echo -e "${YELLOW}第${i}次尝试连接ADB,请在设备上点击【允许】按钮...${NC}" 51 | device_status=$(adb devices | grep "${ip}:5555" | awk '{print $2}') 52 | if [[ "$device_status" == "device" ]]; then 53 | echo -e "${GREEN}ADB 已经连接成功啦,你可以放心操作了${NC}" 54 | return 0 55 | fi 56 | sleep 1 # 每次检测间隔1秒 57 | done 58 | echo -e "${RED}连接超时,或者您点击了【取消】,请确认电视盒子的IP地址是否正确。如果问题持续存在,请检查设备的USB调试设置是否正确并重新连接adb${NC}" 59 | } 60 | 61 | # 显示当前时区 62 | show_timezone() { 63 | adb shell getprop persist.sys.timezone 64 | } 65 | 66 | 67 | disconnect_adb() { 68 | adb disconnect >/dev/null 2>&1 69 | echo "ADB 已经断开" 70 | } 71 | 72 | 73 | get_status() { 74 | if check_adb_connected; then 75 | adb_status="${GREEN}已连接且已授权${NC}" 76 | else 77 | adb_status="${RED}未连接${NC}" 78 | fi 79 | echo -e "* 与电视盒子的连接状态:$adb_status" 80 | } 81 | 82 | # 获取电视盒子型号 83 | get_tvbox_model_name() { 84 | if check_adb_connected; then 85 | # 获取设备型号 86 | local model=$(adb shell getprop ro.product.model) 87 | # 获取设备制造商 88 | local manufacturer=$(adb shell getprop ro.product.manufacturer) 89 | # 清除换行符 90 | model=$(echo $model | tr -d '\r' | tr -d '\n') 91 | manufacturer=$(echo $manufacturer | tr -d '\r' | tr -d '\n') 92 | echo -e "* 当前电视盒子型号:${BLUE}$manufacturer $model${NC}" 93 | else 94 | echo -e "* 当前电视盒子型号:${BLUE}请先连接ADB${NC}" 95 | fi 96 | } 97 | 98 | # 获取电视盒子时区 99 | get_tvbox_timezone() { 100 | if check_adb_connected; then 101 | # 获取设备时区 102 | device_timezone=$(adb shell getprop persist.sys.timezone) 103 | # 获取设备系统时间,格式化为“年月日 时:分” 104 | device_time=$(adb shell date "+%Y年%m月%d日 %H:%M") 105 | 106 | echo -e "* 当前电视盒子时区:${YELLOW}$device_timezone${NC}" 107 | echo -e "* 当前电视盒子时间:${YELLOW}$device_time${NC}" 108 | else 109 | echo -e "* 当前电视盒子时区:${BLUE}请先连接ADB${NC}" 110 | echo -e "* 当前电视盒子时间:${BLUE}请先连接ADB${NC}" 111 | fi 112 | } 113 | 114 | 115 | # 安装Netflix 116 | install_netflix() { 117 | local app_name_dir="netflix" 118 | install_app_bundle $app_name_dir 119 | } 120 | 121 | # 安装Disney+ 122 | install_disney() { 123 | local app_name_dir="disney" 124 | install_app_bundle $app_name_dir 125 | } 126 | 127 | # 安装Fire TV版本Youtube 128 | install_youtube() { 129 | local apk_local_path="/tvhelper/apks/youtube.apk" 130 | if check_adb_connected; then 131 | echo -e "${GREEN}正在推送和安装fire tv版youtube,请耐心等待...${NC}" 132 | 133 | # 模拟安装进度 134 | echo -ne "${BLUE}" 135 | while true; do 136 | echo -n ".." 137 | sleep 1 138 | done & 139 | 140 | # 保存进度指示进程的PID 141 | PROGRESS_PID=$! 142 | install_result=$(adb install -r $apk_local_path 2>&1) 143 | 144 | # 安装完成后,终止进度指示进程 145 | kill $PROGRESS_PID 146 | wait $PROGRESS_PID 2>/dev/null 147 | echo -e "${NC}\n" 148 | 149 | # 检查安装结果 150 | if [[ $install_result == *"Success"* ]]; then 151 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 152 | else 153 | echo -e "${RED}APK安装失败:$install_result${NC}" 154 | fi 155 | else 156 | connect_adb 157 | fi 158 | } 159 | 160 | # 安装HBO GO 161 | install_hbogo() { 162 | local app_name_dir="hbogo" 163 | install_app_bundle $app_name_dir 164 | } 165 | 166 | # 安装appletv+ 167 | install_appletv() { 168 | local app_name_dir="appletv" 169 | install_app_bundle $app_name_dir 170 | } 171 | # 安装mytvsuper 172 | install_mytvsuper() { 173 | local app_name_dir="mytvsuper" 174 | install_app_bundle $app_name_dir 175 | } 176 | 177 | # 下载单独apk 178 | # 保存在/tmp/应用名称的文件夹下 179 | download_apk() { 180 | local apk_download_url=$1 181 | local app_name_dir=$2 182 | local filename=$(basename "$apk_download_url") 183 | # 下载APK文件到临时目录 184 | mkdir -p "/tmp/${app_name_dir}" 185 | wget -O "/tmp/${app_name_dir}/${filename}" "$apk_download_url" 186 | } 187 | 188 | # 根据文件夹名称,安装文件夹中全部apk 189 | install_app_bundle() { 190 | local app_name_dir=$1 191 | if check_adb_connected; then 192 | echo -e "${GREEN}正在推送和安装${app_name_dir},请耐心等待...${NC}" 193 | 194 | # 模拟安装进度 195 | echo -ne "${BLUE}" 196 | while true; do 197 | echo -n ".." 198 | sleep 1 199 | done & 200 | 201 | # 保存进度指示进程的PID 202 | PROGRESS_PID=$! 203 | install_result=$(adb install-multiple -r /tvhelper/sony/${app_name_dir}/*.apk 2>&1) 204 | 205 | # 安装完成后,终止进度指示进程 206 | kill $PROGRESS_PID 207 | wait $PROGRESS_PID 2>/dev/null 208 | echo -e "${NC}\n" 209 | 210 | # 检查安装结果 211 | if [[ $install_result == *"Success"* ]]; then 212 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 213 | else 214 | echo -e "${RED}APK安装失败:$install_result${NC}" 215 | fi 216 | else 217 | connect_adb 218 | fi 219 | } 220 | 221 | # 安装apk 222 | install_apk() { 223 | local apk_local_path=$1 224 | if check_adb_connected; then 225 | echo -e "${GREEN}正在推送和安装apk,请耐心等待...${NC}" 226 | 227 | # 模拟安装进度 228 | echo -ne "${BLUE}" 229 | while true; do 230 | echo -n ".." 231 | sleep 1 232 | done & 233 | 234 | # 保存进度指示进程的PID 235 | PROGRESS_PID=$! 236 | install_result=$(adb install -r $apk_local_path 2>&1) 237 | 238 | # 安装完成后,终止进度指示进程 239 | kill $PROGRESS_PID 240 | wait $PROGRESS_PID 2>/dev/null 241 | echo -e "${NC}\n" 242 | 243 | # 检查安装结果 244 | if [[ $install_result == *"Success"* ]]; then 245 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 246 | else 247 | echo -e "${RED}APK安装失败:$install_result${NC}" 248 | fi 249 | else 250 | connect_adb 251 | fi 252 | } 253 | 254 | 255 | # 菜单 256 | menu_options=( 257 | "连接ADB" 258 | "断开ADB" 259 | "安装Netflix最新版" 260 | "安装Apple TV+最新版" 261 | "安装Disney+最新版" 262 | "安装HBO GO最新版" 263 | "安装myTVSuper最新版" 264 | "安装Youtube-FireTV版" 265 | "赞助|打赏" 266 | ) 267 | 268 | commands=( 269 | ["连接ADB"]="connect_adb" 270 | ["断开ADB"]="disconnect_adb" 271 | ["安装Netflix最新版"]="install_netflix" 272 | ["安装Disney+最新版"]="install_disney" 273 | ["安装Youtube-FireTV版"]="install_youtube" 274 | ["安装HBO GO最新版"]="install_hbogo" 275 | ["安装Apple TV+最新版"]="install_appletv" 276 | ["安装myTVSuper最新版"]="install_mytvsuper" 277 | ["赞助|打赏"]="sponsor" 278 | ) 279 | 280 | # 处理菜单 281 | handle_choice() { 282 | local choice=$1 283 | # 检查输入是否为空 284 | if [[ -z $choice ]]; then 285 | echo -e "${RED}输入不能为空,请重新选择。${NC}" 286 | return 287 | fi 288 | 289 | # 检查输入是否为数字 290 | if ! [[ $choice =~ ^[0-9]+$ ]]; then 291 | echo -e "${RED}请输入有效数字!${NC}" 292 | return 293 | fi 294 | 295 | # 检查数字是否在有效范围内 296 | if [[ $choice -lt 1 ]] || [[ $choice -gt ${#menu_options[@]} ]]; then 297 | echo -e "${RED}选项超出范围!${NC}" 298 | echo -e "${YELLOW}请输入 1 到 ${#menu_options[@]} 之间的数字。${NC}" 299 | return 300 | fi 301 | 302 | local selected_option="${menu_options[$choice - 1]}" 303 | local command_to_run="${commands[$selected_option]}" 304 | 305 | # 检查是否存在对应的命令 306 | if [ -z "$command_to_run" ]; then 307 | echo -e "${RED}无效选项,请重新选择。${NC}" 308 | return 309 | fi 310 | 311 | # 使用eval执行命令 312 | eval "$command_to_run" 313 | } 314 | 315 | show_menu() { 316 | current_date=$(date +%Y%m%d) 317 | mkdir -p /tvhelper/shells/data 318 | clear 319 | echo "***********************************************************************" 320 | echo -e "* ${YELLOW}Sony电视专用助手Docker版 (${current_date})${NC} " 321 | echo -e "* ${RED}请确保电视盒子和Docker宿主机处于${NC}${BLUE}同一网段${NC}\n* ${RED}且电视盒子开启了${NC}${BLUE}USB调试模式(adb开关)${NC} " 322 | echo "* Developed by @wukongdaily " 323 | echo "**********************************************************************" 324 | echo 325 | echo "$(get_status)" 326 | echo "$(get_tvbox_model_name)" 327 | echo "$(get_tvbox_timezone)" 328 | echo 329 | echo "**********************************************************************" 330 | echo "请选择操作:" 331 | for i in "${!menu_options[@]}"; do 332 | echo -e "${BLUE}$((i + 1)). ${menu_options[i]}${NC}" 333 | done 334 | } 335 | 336 | while true; do 337 | show_menu 338 | read -p "请输入选项的序号(输入q退出): " choice 339 | if [[ $choice == 'q' ]]; then 340 | break 341 | fi 342 | handle_choice $choice 343 | echo "按任意键继续..." 344 | read -n 1 # 等待用户按键 345 | done 346 | -------------------------------------------------------------------------------- /shells/tv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # wget -O tv.sh https://cafe.cpolar.cn/wkdaily/tvhelper-docker/raw/branch/master/shells/tv.sh && chmod +x tv.sh && ./tv.sh 3 | source common.sh 4 | apk_path="/tvhelper/apks/" 5 | # 定义红色文本 6 | RED='\033[0;31m' 7 | # 无颜色 8 | NC='\033[0m' 9 | GREEN='\e[38;5;154m' 10 | YELLOW="\e[93m" 11 | BLUE="\e[96m" 12 | 13 | # 菜单选项数组 14 | declare -a menu_options 15 | declare -A commands 16 | # 安装原生tv必备菜单 17 | declare -a item_options 18 | declare -A commands_essentials 19 | # 替换或恢复系统桌面 20 | declare -a tv_model_options 21 | declare -A tv_model_commands 22 | 23 | # 设置全局快捷键p 24 | cp -f "$0" /usr/local/bin/t 25 | chmod +x /usr/local/bin/t 26 | 27 | 28 | get_docker_version() { 29 | # 尝试从 /etc/environment 读取 APP_VERSION 30 | if [ -f /etc/environment ]; then 31 | source /etc/environment 32 | fi 33 | if [ -n "$APP_VERSION" ]; then 34 | version=$APP_VERSION 35 | else 36 | # 若 /etc/environment 中的 APP_VERSION 为空,使用默认值 37 | version="1.0.6" 38 | fi 39 | echo $version 40 | } 41 | 42 | # 使用get_docker_version函数 43 | docker_version=$(get_docker_version) 44 | 45 | show_user_tips() { 46 | read -p "按 Enter 键继续..." 47 | } 48 | 49 | # 检查输入是否为整数 50 | is_integer() { 51 | if [[ $1 =~ ^-?[0-9]+$ ]]; then 52 | return 0 # 0代表true/成功 53 | else 54 | return 1 # 非0代表false/失败 55 | fi 56 | } 57 | 58 | # 判断adb是否连接成功 59 | check_adb_connected() { 60 | # 获取 adb devices 输出,跳过第一行(标题行),并检查每一行的状态 61 | local connected_devices=$(adb devices | awk 'NR>1 {print $2}' | grep 'device$') 62 | # 检查是否有设备已连接并且状态为 'device',即已授权 63 | if [[ -n $connected_devices ]]; then 64 | # ADB 已连接并且设备已授权 65 | return 0 66 | else 67 | # ADB 设备未连接或未授权 68 | return 1 69 | fi 70 | } 71 | 72 | # 函数用于检查IP地址的合法性 73 | is_valid_ip() { 74 | if [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 75 | IFS='.' read -ra ip_parts <<<"$1" 76 | for i in "${ip_parts[@]}"; do 77 | if ((i < 0 || i > 255)); then 78 | return 1 79 | fi 80 | done 81 | return 0 82 | else 83 | return 1 84 | fi 85 | } 86 | #连接adb并记录上次的ip 87 | connect_adb() { 88 | adb disconnect >/dev/null 2>&1 89 | history_file="/tvhelper/shells/history" 90 | if [[ -f "$history_file" ]]; then 91 | last_ip=$(tail -n 1 "$history_file") 92 | last_name=$(head -n 1 "$history_file") 93 | # 检查历史中的IP地址是否合法 94 | if is_valid_ip "$last_ip"; then 95 | echo -e "上次连接的设备是 ${GREEN}${last_name}${NC}IP地址为 ${GREEN}${last_ip}${NC}\n您是否要再次连接到此设备?确认请直接回车,否定输入n再回车[Y/n]" 96 | read answer 97 | if [[ "$answer" == "N" || "$answer" == "n" ]]; then 98 | echo -e "${YELLOW}请手动输入电视盒子的完整IP地址:${NC}" 99 | read ip 100 | else 101 | ip=$last_ip 102 | fi 103 | else 104 | echo -e "${RED}历史记录中的IP地址不合法,请手动输入电视盒子的完整IP地址:${NC}" 105 | read ip 106 | fi 107 | else 108 | echo -e "${YELLOW}请手动输入电视盒子的完整IP地址:${NC}" 109 | read ip 110 | fi 111 | 112 | echo -e "${BLUE}首次使用,盒子上可能会提示授权弹框,给您半分钟时间来操作...【允许】${NC}" 113 | adb connect ${ip} 114 | 115 | for ((i = 1; i <= 30; i++)); do 116 | echo -e "${YELLOW}第${i}次尝试连接ADB,请在设备上点击【允许】按钮...${NC}" 117 | device_status=$(adb devices | grep "${ip}:5555" | awk '{print $2}') 118 | if [[ "$device_status" == "device" ]]; then 119 | echo -e "${GREEN}ADB 已经连接成功啦,你可以放心操作了${NC}" 120 | # 连接成功后,写入名称和IP地址到历史文件 121 | echo "$(get_history_name)" >"$history_file" 122 | echo "${ip}" >>"$history_file" 123 | return 0 124 | fi 125 | sleep 1 126 | done 127 | echo -e "${RED}连接超时,或者您点击了【取消】,请确认电视盒子的IP地址是否正确。如果问题持续存在,请检查设备的USB调试设置是否正确并重新连接adb${NC}" 128 | } 129 | 130 | # 一键修改NTP服务器地址 131 | modify_ntp() { 132 | echo -e "${BLUE}它的作用在于:解决安卓原生TV时间不正确和网络受限问题${NC}" 133 | if check_adb_connected; then 134 | adb shell settings put global ntp_server ntp3.aliyun.com 135 | adb shell settings put global captive_portal_mode 1 136 | adb shell settings put global captive_portal_detection_enabled 1 137 | # 设置一个返回204 空内容的服务器 138 | adb shell settings put global captive_portal_use_https 0 139 | adb shell settings put global captive_portal_http_url http://connect.rom.miui.com/generate_204 140 | echo -e "${GREEN}NTP服务器地址已经成功修改为国内,重启后请检查盒子的系统时间和时区${NC}" 141 | echo -e "${RED}正在重启您的电视盒子或者电视机,请稍后.......${NC}" 142 | # 5秒倒计时 143 | for i in {5..1}; do 144 | echo -e "${RED}$i${NC} 秒后将重启设备" 145 | sleep 1 146 | done 147 | adb shell reboot & 148 | sleep 2 # 给点时间让重启命令发出 149 | disconnect_adb 150 | exit 151 | else 152 | echo "没有检测到已连接的设备。请先连接ADB" 153 | connect_adb 154 | fi 155 | } 156 | 157 | # 显示当前时区 158 | show_timezone() { 159 | adb shell getprop persist.sys.timezone 160 | } 161 | 162 | #断开adb连接 163 | disconnect_adb() { 164 | adb disconnect >/dev/null 2>&1 165 | echo "ADB 已经断开" 166 | } 167 | 168 | # 添加主机名映射(解决安卓原生TV首次连不上wifi的问题) 169 | add_dhcp_domain() { 170 | echo -e "${BLUE}它的作用在于:解决安卓原生TV首次使用连不上wifi的问题${NC}" 171 | local domain_name="time.android.com" 172 | local domain_ip="203.107.6.88" 173 | 174 | # 检查是否存在相同的域名记录 175 | existing_records=$(uci show dhcp | grep "dhcp.@domain\[[0-9]\+\].name='$domain_name'") 176 | if [ -z "$existing_records" ]; then 177 | # 添加新的域名记录 178 | uci add dhcp domain 179 | uci set "dhcp.@domain[-1].name=$domain_name" 180 | uci set "dhcp.@domain[-1].ip=$domain_ip" 181 | uci commit dhcp 182 | echo 183 | echo "已添加新的域名记录" 184 | else 185 | echo "相同的域名记录已存在,无需重复添加" 186 | fi 187 | echo -e "\n" 188 | echo -e "time.android.com 203.107.6.88 " 189 | } 190 | 191 | show_nf_info() { 192 | echo -e "${BLUE}播放Netflix影片的时候 屏幕左上角显示影片信息,再次执行则消失${NC}" 193 | echo -e "${GREEN}Netflix INFO键已发送! 继续输入【m】模拟INFO键 或者输入q退出。${NC}" 194 | if check_adb_connected; then 195 | while true; do 196 | read str 197 | if [[ $str == "q" ]]; then 198 | echo -e "${GREEN}退出输入模式。${NC}" 199 | break # 当用户输入q时退出循环 200 | elif [[ $str == "m" ]]; then 201 | adb shell input keyevent KEYCODE_F8 202 | echo -e "${GREEN}Netflix INFO键已发送! 继续输入【m】模拟INFO键 或者输入q退出。${NC}" 203 | else 204 | echo -e "${RED}请输入m或者输入q退出${NC}" 205 | fi 206 | done 207 | else 208 | connect_adb 209 | fi 210 | } 211 | 212 | show_menu_keycode() { 213 | echo -e "${BLUE}使用背景:${NC}\n${YELLOW}许多国产App还保留了菜单键的功能\n而原生TV盒子系统似乎逐渐放弃适配菜单键\n因此很多盒子附带的遥控器不会标配菜单键\n\n所以开发此功能,它会模拟触发菜单键\n请在盒子上观察是否有效,可反复执行${NC}" 214 | echo -e "${GREEN}菜单键已发送! 继续输入字母【m】模拟菜单键 或者输入q退出。${NC}" 215 | if check_adb_connected; then 216 | while true; do 217 | 218 | read str 219 | if [[ $str == "q" ]]; then 220 | echo -e "${GREEN}退出输入模式。${NC}" 221 | break # 当用户输入q时退出循环 222 | elif [[ $str == "m" ]]; then 223 | adb shell input keyevent KEYCODE_MENU 224 | echo -e "${GREEN}菜单键已发送! 继续输入m模拟菜单键 或者输入q退出。${NC}" 225 | else 226 | echo -e "${RED}请输入m或者输入q退出${NC}" 227 | fi 228 | done 229 | else 230 | connect_adb 231 | fi 232 | } 233 | 234 | # 向电视盒子输入英文 235 | input_text() { 236 | echo -e "${BLUE}注意注意注意!请弹出键盘后再执行!每次输入会自动清空上次结果${NC}" 237 | if check_adb_connected; then 238 | while true; do 239 | echo -e "仅支持英文字符和常规简单网址 不能支持 & * ? ,不建议重度使用此功能,重度使用请使用蓝牙键盘\n${YELLOW}如果输入clash订阅地址强烈建议使用第10项,${NC}\n ADB不适合处理特殊字符,且Openwrt下的adb版本也较低) \n输入【q】退出。输入【qk】删除20个字符。输入【blue】搜索蓝牙键盘。请您输入" 240 | read str 241 | 242 | if [[ $str == "q" ]]; then 243 | echo -e "${GREEN}退出输入模式。${NC}" 244 | break # 当用户输入q时退出循环 245 | elif [[ $str == "qk" ]]; then 246 | # 删除20个字符 247 | for i in {1..20}; do 248 | adb shell input keyevent KEYCODE_DEL 249 | done 250 | echo -e "${RED}哈哈!你可真够懒的!已帮你删除20个字符。继续输入或者输入q退出。${NC}" 251 | elif [[ $str == "blue" ]]; then 252 | # 蓝牙 253 | adb shell input keyevent KEYCODE_PAIRING 254 | echo -e "${YELLOW}已进入蓝牙配对模式。请在电视屏幕或显示器上根据提示配对您的蓝牙键盘${NC}" 255 | else 256 | after_str=$(convert_str "$str") 257 | if adb shell input text "$after_str"; then 258 | echo -e "${GREEN}[OK] 已发送! 继续输入或者输入q退出。${NC}" 259 | else 260 | # 如果adb命令失败,提醒用户 261 | echo -e "${RED}输入有误或adb命令执行失败,请检查设备连接或输入的字符。${NC}" 262 | fi 263 | fi 264 | done 265 | else 266 | connect_adb 267 | fi 268 | } 269 | 270 | convert_str() { 271 | local str="$1" 272 | # 直接处理特殊字符,对于不确定的转义尝试去除反斜线 273 | local ss=$(echo "$str" | 274 | sed 's/[?]/\\\?/g' | 275 | sed 's/[<]/\\]/\\>/g' | 277 | sed 's/[|]/\\\|/g' | 278 | sed 's/[~]/\\\~/g' | 279 | sed 's/[\^]/\\\^/g' | 280 | sed 's/ \$/$$/g' | 281 | sed 's/ __/__ /g') 282 | echo "$ss" 283 | } 284 | 285 | # 安装apk 286 | install_apk() { 287 | local local_path=$1 288 | local package_name=$2 289 | local filename=$(basename "$local_path") 290 | 291 | if check_adb_connected; then 292 | # 卸载旧版本的APK(如果存在) 293 | adb uninstall "$package_name" >/dev/null 2>&1 294 | echo -e "${GREEN}正在推送和安装${filename},请耐心等待...${NC}" 295 | 296 | # 模拟安装进度 297 | echo -ne "${BLUE}" 298 | while true; do 299 | echo -n ".." 300 | sleep 1 301 | done & 302 | 303 | # 保存进度指示进程的PID 304 | PROGRESS_PID=$! 305 | install_result=$(adb install -r $local_path 2>&1) 306 | 307 | # 安装完成后,终止进度指示进程 308 | kill $PROGRESS_PID 309 | wait $PROGRESS_PID 2>/dev/null 310 | echo -e "${NC}\n" 311 | 312 | # 检查安装结果 313 | if [[ $install_result == *"Success"* ]]; then 314 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 315 | else 316 | echo -e "${RED}APK安装失败:$install_result${NC}" 317 | fi 318 | else 319 | connect_adb 320 | fi 321 | } 322 | 323 | # 批量安装apk功能 324 | install_all_apks() { 325 | if check_adb_connected; then 326 | # 获取/tmp/upload目录下的apk文件列表 327 | apk_files=($(ls /tvhelper/shells/data/*.apk 2>/dev/null)) 328 | total_files=${#apk_files[@]} 329 | 330 | # 检查是否有APK文件 331 | if [ "$total_files" -eq "0" ]; then 332 | echo -e "${RED}/tvhelper/shells/data/ 目录下不包含任何apk文件,请先拷贝apk文件到此目录.${NC}" 333 | return 1 334 | fi 335 | 336 | echo -e "${GREEN}================文件列表================${NC}" 337 | for apk_file in "${apk_files[@]}"; do 338 | filename=$(basename "$apk_file") 339 | echo -e "${GREEN}$filename${NC}" 340 | done 341 | echo -e "${GREEN}========================================${NC}" 342 | echo 343 | echo -e "${BLUE}发现 $total_files 个APK. 开始安装...\n安装过程若出现弹框,请点击详情后选择【仍然安装】即可${NC}" 344 | echo 345 | # 安装APK文件并显示进度 346 | for apk_file in "${apk_files[@]}"; do 347 | filename=$(basename "$apk_file") 348 | echo -ne "${YELLOW}Installing: $filename${NC} ${GREEN}" 349 | echo 350 | 351 | # 模拟安装进度 352 | while true; do 353 | echo -n ".." 354 | sleep 1 355 | done & 356 | 357 | # 保存进度指示进程的PID 358 | PROGRESS_PID=$! 359 | 360 | # 执行实际的APK安装命令,并捕获输出 361 | install_result=$(adb install -r "$apk_file" 2>&1) 362 | 363 | # 安装完成后,终止进度指示进程 364 | kill $PROGRESS_PID >/dev/null 2>&1 365 | wait $PROGRESS_PID 2>/dev/null 366 | echo -e "${NC}\nInstallation result: $install_result" 367 | done 368 | 369 | echo -e "${GREEN}所有APK安装完毕.${NC}" 370 | else 371 | connect_adb 372 | fi 373 | } 374 | 375 | # 安装订阅助手 376 | install_subhelper_apk() { 377 | echo -e "${BLUE}电视订阅助手使用指南 前往观看:https://youtu.be/9NpYtPsJlGk ${NC}" 378 | install_apk "${apk_path}subhelp14.apk" "com.wukongdaily.myclashsub" 379 | } 380 | 381 | # 安装play商店图标 382 | show_playstore_icon() { 383 | echo -e "${BLUE}这个apk仅用于google tv系统。因为google tv系统在首页并不会显示自家的谷歌商店图标${NC}" 384 | install_apk "${apk_path}play-icon.apk" "com.android.vending.wk" 385 | } 386 | 387 | # 安装文件管理器 388 | install_file_manager_plus() { 389 | install_apk "${apk_path}File_Manager_Plus.apk" "com.alphainventor.filemanager" 390 | } 391 | 392 | # 安装Downloader 393 | install_downloader() { 394 | install_apk "${apk_path}downloader.apk" "com.esaba.downloader" 395 | } 396 | 397 | # 安装emotn store 398 | install_emotn_store() { 399 | echo -e "${BLUE}emotn_store使用指南1 前往观看:https://youtu.be/_S693NITNrs ${NC}" 400 | echo -e "${YELLOW}emotn_store使用指南2 前往观看:https://youtu.be/lMhhIn4CQts ${NC}" 401 | echo -e "${BLUE}安装过程若出现弹框,请点击详情后选择【仍然安装】即可${NC}" 402 | install_apk "${apk_path}emotn.apk" "com.overseas.store.appstore" 403 | } 404 | 405 | # 安装当贝市场 406 | install_dbmarket() { 407 | echo -e "${BLUE}安装过程若出现弹框,请点击详情后选择【仍然安装】即可${NC}" 408 | install_apk "${apk_path}dangbeimarket.apk" "com.dangbeimarket" 409 | } 410 | 411 | # 安装网络获取的apk 412 | install_web_apk() { 413 | local apk_download_url=$1 414 | local package_name=$2 415 | local filename=$(basename "$apk_download_url") 416 | # 下载APK文件到临时目录 417 | wget -O /tmp/$filename "$apk_download_url" 418 | if check_adb_connected; then 419 | # 卸载旧版本的APK(如果存在) 420 | adb uninstall "$package_name" >/dev/null 2>&1 421 | echo -e "${GREEN}正在推送和安装apk,请耐心等待...${NC}" 422 | 423 | # 模拟安装进度 424 | echo -ne "${BLUE}" 425 | while true; do 426 | echo -n ".." 427 | sleep 1 428 | done & 429 | 430 | # 保存进度指示进程的PID 431 | PROGRESS_PID=$! 432 | install_result=$(adb install -r /tmp/$filename 2>&1) 433 | 434 | # 安装完成后,终止进度指示进程 435 | kill $PROGRESS_PID 436 | wait $PROGRESS_PID 2>/dev/null 437 | echo -e "${NC}\n" 438 | 439 | # 检查安装结果 440 | if [[ $install_result == *"Success"* ]]; then 441 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 442 | else 443 | echo -e "${RED}APK安装失败:$install_result${NC}" 444 | fi 445 | rm -rf /tmp/"$filename" 446 | echo -e "${YELLOW}临时文件/tmp/${filename}已清理${NC}" 447 | else 448 | connect_adb 449 | fi 450 | } 451 | 452 | # 安装my-tv 453 | # release地址、包名、apk命名前缀 454 | install_mytv_latest_apk() { 455 | echo -e "${BLUE}项目主页:https://github.com/lizongying/my-tv ${NC}" 456 | install_apk "${apk_path}mytv.apk" "com.lizongying.mytv" 457 | } 458 | 459 | # 安装bbll 460 | # release地址、包名、apk命名前缀 461 | install_BBLL_latest_apk() { 462 | echo -e "${BLUE}项目主页:https://github.com/xiaye13579/BBLL ${NC}" 463 | install_apk "${apk_path}bbll.apk" "com.xx.blbl" 464 | } 465 | 466 | #根据apk地址和包名 安装apk 467 | install_apk_by_url() { 468 | local releases_url=$1 469 | local package_name=$2 470 | local name_prefix=$3 471 | 472 | # 使用get_apk_url函数获取APK的下载链接 473 | local apk_url=$(get_apk_url_by_name_prefix "$releases_url" "$name_prefix") 474 | if [ -z "$apk_url" ]; then 475 | echo "APK download URL could not be found." 476 | return 1 477 | fi 478 | 479 | # 从URL中提取文件名 480 | local filename=$(basename "$apk_url") 481 | echo -e "${YELLOW}已获取最新版下载地址:\n$apk_url${NC}" 482 | 483 | # 使用curl下载APK文件并保存到/tmp目录 484 | echo -e "${GREEN}Downloading APK to /tmp/$filename ... ${NC}" 485 | curl -L "$apk_url" -o /tmp/"$filename" 486 | 487 | if [ $? -eq 0 ]; then 488 | echo -e "${GREEN}APK downloaded successfully to /tmp/$filename ${NC}" 489 | if check_adb_connected; then 490 | # 卸载旧版本的APK 491 | adb uninstall "$package_name" >/dev/null 2>&1 492 | echo -e "${GREEN}正在推送和安装$filename 请耐心等待...${NC}" 493 | # 模拟安装进度 494 | echo -ne "${BLUE}" 495 | while true; do 496 | echo -n ".." 497 | sleep 1 498 | done & 499 | 500 | # 保存进度指示进程的PID 501 | PROGRESS_PID=$! 502 | 503 | # 安装新版本的APK 504 | install_result=$(adb install /tmp/"$filename" 2>&1) 505 | 506 | # 安装完成后,终止进度指示进程 507 | kill $PROGRESS_PID 508 | wait $PROGRESS_PID 2>/dev/null 509 | echo -e "${NC}\n" 510 | 511 | # 检查安装结果 512 | if [[ $install_result == *"Success"* ]]; then 513 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 514 | else 515 | echo -e "${RED}APK安装失败:$install_result${NC}" 516 | fi 517 | rm -rf /tmp/"$filename" 518 | echo -e "${YELLOW}临时文件/tmp/${filename}已清理${NC}" 519 | else 520 | connect_adb 521 | fi 522 | else 523 | echo "Failed to download APK." 524 | return 1 525 | fi 526 | } 527 | 528 | #根据release地址和命名前缀获取apk地址 529 | get_apk_url_by_name_prefix() { 530 | if [ $# -eq 0 ]; then 531 | echo "需要提供GitHub releases页面的URL作为参数。" 532 | return 1 533 | fi 534 | 535 | local releases_url=$1 536 | local name_prefix=$2 537 | 538 | # 使用curl获取重定向的URL 539 | latest_url=$(curl -Ls -o /dev/null -w "%{url_effective}" "$releases_url") 540 | 541 | # 使用sed从URL中提取tag值,并保留前导字符'v' 542 | tag=$(echo $latest_url | sed 's|.*/v|v|') 543 | 544 | # 检查是否成功获取到tag 545 | if [ -z "$tag" ]; then 546 | echo "未找到最新的release tag。" 547 | return 1 548 | fi 549 | 550 | # 拼接APK下载链接 551 | local repo_path=$(echo "$releases_url" | sed -n 's|https://github.com/\(.*\)/releases/latest|\1|p') 552 | apk_download_url="https://github.com/${repo_path}/releases/download/${tag}/${name_prefix}${tag}.apk" 553 | 554 | echo "$apk_download_url" 555 | } 556 | 557 | get_status() { 558 | if check_adb_connected; then 559 | adb_status="${GREEN}已连接且已授权${NC}" 560 | else 561 | adb_status="${RED}未连接${NC}" 562 | fi 563 | echo -e "* 与电视盒子的连接状态:$adb_status" 564 | } 565 | 566 | # 获取电视盒子型号 567 | get_tvbox_model_name() { 568 | if check_adb_connected; then 569 | # 获取设备型号 570 | local model=$(adb shell getprop ro.product.model) 571 | # 获取设备制造商 572 | local manufacturer=$(adb shell getprop ro.product.manufacturer) 573 | # 清除换行符 574 | model=$(echo $model | tr -d '\r' | tr -d '\n') 575 | manufacturer=$(echo $manufacturer | tr -d '\r' | tr -d '\n') 576 | echo -e "* 当前电视盒子型号:${BLUE}$manufacturer $model${NC}" 577 | else 578 | echo -e "* 当前电视盒子型号:${BLUE}请先连接ADB${NC}" 579 | fi 580 | } 581 | 582 | # 获取历史记录中盒子的名称 583 | get_history_name() { 584 | if check_adb_connected; then 585 | # 获取设备型号 586 | local model=$(adb shell getprop ro.product.model) 587 | # 获取设备制造商 588 | local manufacturer=$(adb shell getprop ro.product.manufacturer) 589 | # 清除换行符 590 | model=$(echo $model | tr -d '\r' | tr -d '\n') 591 | manufacturer=$(echo $manufacturer | tr -d '\r' | tr -d '\n') 592 | echo "$manufacturer $model " 593 | else 594 | echo -e "" 595 | fi 596 | } 597 | 598 | # 获取电视盒子时区 599 | get_tvbox_timezone() { 600 | if check_adb_connected; then 601 | # 获取设备时区 602 | device_timezone=$(adb shell getprop persist.sys.timezone) 603 | # 获取设备系统时间,格式化为“年月日 时:分” 604 | device_time=$(adb shell date "+%Y年%m月%d日 %H:%M") 605 | 606 | echo -e "* 当前电视盒子时区:${YELLOW}$device_timezone${NC}" 607 | echo -e "* 当前电视盒子时间:${YELLOW}$device_time${NC}" 608 | else 609 | echo -e "* 当前电视盒子时区:${BLUE}请先连接ADB${NC}" 610 | echo -e "* 当前电视盒子时间:${BLUE}请先连接ADB${NC}" 611 | fi 612 | } 613 | 614 | # 安装mix apps 用于显示全部app 615 | install_mixapps() { 616 | local xapk_local_path="${apk_path}mix.xapk" 617 | local xapkname=$(basename "$xapk_local_path") 618 | local extract_to="/tmp/mix/" 619 | mkdir -p "$extract_to" 620 | if unzip -o "$xapk_local_path" -d "$extract_to"; then 621 | echo "XAPK文件解压成功,准备安装..." 622 | else 623 | echo "XAPK文件解压失败,请检查文件是否损坏或尝试重新下载。" 624 | return 1 # 返回一个错误状态 625 | fi 626 | apk_files=$(find "$extract_to" -type f -name "*.apk") 627 | echo -e "解压后的多个apk:\n$apk_files" 628 | echo -ne "${YELLOW}正在安装: $xapkname${NC} ${GREEN}" 629 | echo 630 | 631 | # 模拟安装进度 632 | while true; do 633 | echo -n ".." 634 | sleep 1 635 | done & 636 | # 保存进度指示进程的PID 637 | PROGRESS_PID=$! 638 | # 执行实际的APK安装命令,并捕获输出 639 | install_result=$(adb install-multiple $apk_files 2>&1) 640 | # 安装完成后,终止进度指示进程 641 | kill $PROGRESS_PID >/dev/null 2>&1 642 | wait $PROGRESS_PID 2>/dev/null 643 | echo -e "${NC}\nInstallation result: $install_result" 644 | 645 | if [ $? -eq 0 ]; then 646 | echo -e "${GREEN} 安装成功 ${NC}" 647 | # 安装成功后,删除解压的文件和原始XAPK文件 648 | echo -e "${RED}正在删除临时文件...${NC}" 649 | rm -rf "$extract_to" # 删除解压目录 650 | echo -e "${GREEN}临时文件删除完成,行啦,在盒子上查看吧!${NC}" 651 | else 652 | echo -e "${RED}安装失败${NC}" 653 | fi 654 | } 655 | # 进入KODI助手 656 | kodi_helper() { 657 | wget -O kodi.sh https://cafe.cpolar.cn/wkdaily/tvhelper-docker/raw/branch/master/shells/kodi.sh && chmod +x kodi.sh && ./kodi.sh 658 | } 659 | 660 | # 安装fire tv版本youtube 661 | install_youtube_firetv() { 662 | echo -e "${BLUE}Fire TV版本Youtube无需谷歌框架 可用于所有安卓5.0以上电视盒子 ${NC}" 663 | local apk_local_path="/tvhelper/apks/youtube.apk" 664 | if check_adb_connected; then 665 | echo -e "${GREEN}正在推送和安装fire tv版youtube,请耐心等待...${NC}" 666 | 667 | # 模拟安装进度 668 | echo -ne "${BLUE}" 669 | while true; do 670 | echo -n ".." 671 | sleep 1 672 | done & 673 | 674 | # 保存进度指示进程的PID 675 | PROGRESS_PID=$! 676 | install_result=$(adb install -r $apk_local_path 2>&1) 677 | 678 | # 安装完成后,终止进度指示进程 679 | kill $PROGRESS_PID 680 | wait $PROGRESS_PID 2>/dev/null 681 | echo -e "${NC}\n" 682 | 683 | # 检查安装结果 684 | if [[ $install_result == *"Success"* ]]; then 685 | echo -e "${GREEN}APK安装成功!请在盒子上查看${NC}" 686 | else 687 | echo -e "${RED}APK安装失败:$install_result${NC}" 688 | fi 689 | else 690 | connect_adb 691 | fi 692 | } 693 | 694 | # 进入tvbox安装助手 695 | enter_tvbox_helper() { 696 | wget -O box.sh https://cafe.cpolar.cn/wkdaily/tvhelper-docker/raw/branch/master/shells/box.sh && chmod +x box.sh && ./box.sh 697 | } 698 | 699 | # 进入sony电视助手 700 | enter_sonytv() { 701 | wget -O sony.sh https://cafe.cpolar.cn/wkdaily/tvhelper-docker/raw/branch/master/shells/sony.sh && chmod +x sony.sh && ./sony.sh 702 | } 703 | 704 | # 更新脚本 705 | update_sh() { 706 | break 707 | echo "正在更新脚本..." 708 | # 下载最新的脚本到临时文件 709 | wget -O /tmp/script.sh https://cafe.cpolar.cn/wkdaily/tvhelper-docker/raw/branch/master/shells/tv.sh 710 | # 替换当前脚本 711 | if [ -f /tmp/script.sh ]; then 712 | chmod +x /tmp/script.sh 713 | cp /tmp/script.sh /tvhelper/shells/tv.sh 714 | echo "脚本更新成功。即将重新启动脚本。" 715 | # 使用 exec 来重新启动脚本,替换当前进程 716 | exec /tvhelper/shells/tv.sh 717 | else 718 | echo "更新失败。" 719 | fi 720 | } 721 | 722 | # 菜单 723 | menu_options=( 724 | "连接ADB" 725 | "断开ADB" 726 | "安装Android原生TV必备精选Apps" 727 | "一键修改NTP(限原生TV,需重启)" 728 | "安装Play商店图标(仅google tv使用)" 729 | "自定义批量安装data目录下的所有apk" 730 | "替换系统桌面" 731 | "进入KODI助手" 732 | "进入TVBox安装助手" 733 | "进入Sony电视助手" 734 | "向TV端输入文字(限英文)" 735 | "显示Netflix影片码率" 736 | "模拟菜单键" 737 | "更新脚本" 738 | "赞助|打赏" 739 | ) 740 | 741 | commands=( 742 | ["连接ADB"]="connect_adb" 743 | ["断开ADB"]="disconnect_adb" 744 | ["安装Android原生TV必备精选Apps"]="android_tv_essentials" 745 | ["一键修改NTP(限原生TV,需重启)"]="modify_ntp" 746 | ["向TV端输入文字(限英文)"]="input_text" 747 | ["显示Netflix影片码率"]="show_nf_info" 748 | ["模拟菜单键"]="show_menu_keycode" 749 | ["安装Play商店图标(仅google tv使用)"]="show_playstore_icon" 750 | ["自定义批量安装data目录下的所有apk"]="install_all_apks" 751 | ["进入KODI助手"]="kodi_helper" 752 | ["进入TVBox安装助手"]="enter_tvbox_helper" 753 | ["进入Sony电视助手"]="enter_sonytv" 754 | ["更新脚本"]="update_sh" 755 | ["赞助|打赏"]="sponsor" 756 | ["替换系统桌面"]="replace_system_ui_menu" 757 | ) 758 | # 安装原生tv必备apps 759 | item_options=( 760 | "安装电视订阅助手" 761 | "安装Emotn Store应用商店" 762 | "安装当贝市场" 763 | "安装my-tv(lizongying)" 764 | "安装BBLL(xiaye13579)" 765 | "安装文件管理器+" 766 | "安装Downloader" 767 | "安装Mix-Apps用于显示全部应用" 768 | "返回主菜单" 769 | ) 770 | 771 | commands_essentials=( 772 | ["安装电视订阅助手"]="install_subhelper_apk" 773 | ["安装Emotn Store应用商店"]="install_emotn_store" 774 | ["安装当贝市场"]="install_dbmarket" 775 | ["安装my-tv(lizongying)"]="install_mytv_latest_apk" 776 | ["安装BBLL(xiaye13579)"]="install_BBLL_latest_apk" 777 | ["安装文件管理器+"]="install_file_manager_plus" 778 | ["安装Downloader"]="install_downloader" 779 | ["安装Mix-Apps用于显示全部应用"]="install_mixapps" 780 | ) 781 | 782 | # 替换或恢复系统桌面 783 | tv_model_options=( 784 | "替换/恢复 索尼Sony电视系统桌面" 785 | "替换/恢复 小米(盒子/电视)系统桌面" 786 | "替换/恢复 小米盒子国际版系统桌面" 787 | "替换/恢复 GoogleTV系统桌面" 788 | "替换/恢复 安卓原生TV系统桌面(原生类型TV通用)" 789 | "返回主菜单" 790 | ) 791 | 792 | tv_model_commands=( 793 | ["替换/恢复 索尼Sony电视系统桌面"]="replace_sony_ui" 794 | ["替换/恢复 小米(盒子/电视)系统桌面"]="replace_xiaomi_ui" 795 | ["替换/恢复 小米盒子国际版系统桌面"]="replace_xiaomi_global_ui" 796 | ["替换/恢复 GoogleTV系统桌面"]="toggle_googletv_system_ui" 797 | ["替换/恢复 安卓原生TV系统桌面(原生类型TV通用)"]="replace_normal_androidtv_ui" 798 | ) 799 | 800 | # 定义安卓原生TV必备子菜单函数 801 | android_tv_essentials() { 802 | while true; do 803 | echo -e "${GREEN}原生TV必备精选Apps:${NC}" 804 | for i in "${!item_options[@]}"; do 805 | echo " ($((i + 1))) ${item_options[$i]}" 806 | done 807 | 808 | echo "请选择一个选项,或按q返回主菜单:" 809 | read -r choice 810 | 811 | # 检查输入是否为退出命令 812 | if [[ "$choice" == "q" ]]; then 813 | break 814 | fi 815 | 816 | # 检查输入是否为数字 817 | if ! [[ $choice =~ ^[0-9]+$ ]]; then 818 | echo -e " ${RED}请输入有效数字!${NC}" 819 | continue 820 | fi 821 | 822 | # 检查数字是否在有效范围内 823 | if [[ $choice -lt 1 ]] || [[ $choice -gt ${#item_options[@]} ]]; then 824 | echo -e " ${RED}选项超出范围!${NC}" 825 | echo -e " ${YELLOW}请输入 1 到 ${#item_options[@]} 之间的数字。${NC}" 826 | continue 827 | fi 828 | 829 | # 处理返回主菜单 830 | if [[ $choice -eq ${#item_options[@]} ]]; then 831 | break 832 | fi 833 | 834 | local selected_option="${item_options[$((choice - 1))]}" 835 | command_item_run="${commands_essentials["$selected_option"]}" 836 | 837 | # 检查是否存在对应的命令并执行 838 | if [ -z "$command_item_run" ]; then 839 | echo -e " ${RED}无效选项,请重新选择。${NC}" 840 | else 841 | eval "$command_item_run" 842 | fi 843 | done 844 | } 845 | 846 | # 根据品牌替换系统桌面 847 | replace_system_ui_menu() { 848 | local apk_path="/tvhelper/apks/ui.apk" 849 | # 检查APK文件是否存在 850 | if [ ! -f "$apk_path" ]; then 851 | echo -e "${RED}错误: 要替换的桌面APK文件不存在,请更新docker镜像后重试。${NC}" 852 | return 1 853 | fi 854 | while true; do 855 | echo -e "${GREEN}目前支持替换桌面的电视盒子或电视品牌如下:${NC}" 856 | for i in "${!tv_model_options[@]}"; do 857 | echo " ($((i + 1))) ${tv_model_options[$i]}" 858 | done 859 | 860 | echo "请选择一个选项,或按q返回主菜单:" 861 | read -r choice 862 | 863 | # 检查输入是否为退出命令 864 | if [[ "$choice" == "q" ]]; then 865 | break 866 | fi 867 | 868 | # 检查输入是否为数字 869 | if ! [[ $choice =~ ^[0-9]+$ ]]; then 870 | echo -e " ${RED}请输入有效数字!${NC}" 871 | continue 872 | fi 873 | 874 | # 检查数字是否在有效范围内 875 | if [[ $choice -lt 1 ]] || [[ $choice -gt ${#tv_model_options[@]} ]]; then 876 | echo -e " ${RED}选项超出范围!${NC}" 877 | echo -e " ${YELLOW}请输入 1 到 ${#tv_model_options[@]} 之间的数字。${NC}" 878 | continue 879 | fi 880 | 881 | # 处理返回主菜单 882 | if [[ $choice -eq ${#tv_model_options[@]} ]]; then 883 | break 884 | fi 885 | 886 | local selected_option="${tv_model_options[$((choice - 1))]}" 887 | local command_item_run="${tv_model_commands["$selected_option"]}" 888 | 889 | # 检查是否存在对应的命令并执行 890 | if [ -z "$command_item_run" ]; then 891 | echo -e " ${RED}无效选项,请重新选择。${NC}" 892 | else 893 | eval "$command_item_run" 894 | fi 895 | done 896 | } 897 | 898 | replace_xiaomi_ui() { 899 | local system_ui_package="com.mitv.tvhome" 900 | toggle_system_ui "${system_ui_package}" 901 | } 902 | 903 | replace_xiaomi_global_ui() { 904 | local system_ui_package="com.google.android.tvlauncher" 905 | toggle_system_ui "${system_ui_package}" 906 | } 907 | 908 | replace_sony_ui() { 909 | local system_ui_package="com.dangbei.TVHomeLauncher" 910 | toggle_system_ui "${system_ui_package}" 911 | } 912 | 913 | replace_xiaomi_global_ui() { 914 | replace_normal_androidtv_ui 915 | } 916 | 917 | replace_normal_androidtv_ui() { 918 | local system_ui_package="com.google.android.tvlauncher" 919 | toggle_system_ui "${system_ui_package}" 920 | } 921 | 922 | check_emotnui_installed(){ 923 | local package_name="com.oversea.aslauncher" 924 | local apk_path="/tvhelper/apks/ui.apk" 925 | 926 | # 检查APK文件是否存在 927 | if [ ! -f "$apk_path" ]; then 928 | echo -e "${RED}错误: APK文件不存在,请更新docker镜像后重试,确保docker镜像版本 >= 1.0.3${NC}" 929 | return 1 930 | fi 931 | 932 | # 检查 com.oversea.aslauncher 是否已安装 933 | if ! adb shell pm list packages | grep -q "$package_name"; then 934 | echo -e "${GREEN}EmotnUI 未安装,开始安装...请稍后${NC}" 935 | # 安装 com.oversea.aslauncher 应用 936 | if adb install -r "$apk_path" >/dev/null 2>&1; then 937 | echo -e "${GREEN}第三方桌面安装成功${NC}" 938 | else 939 | echo -e "${RED}应用安装失败,请检查APK文件路径和设备连接状态。若apk不存在请更新docker镜像。${NC}" 940 | return 941 | fi 942 | else 943 | echo -e "${GREEN}第三方桌面EmotnUI已安装。${NC}" 944 | fi 945 | } 946 | 947 | toggle_googletv_system_ui() { 948 | local system_ui_package="com.google.android.apps.tv.launcherx" 949 | local system_setup_package="com.google.android.tungsten.setupwraith" 950 | #判断emotnui是否安装 951 | check_emotnui_installed 952 | 953 | # 检查系统桌面是否已被禁用 954 | if adb shell pm list packages -d | grep -q "$system_ui_package"; then 955 | # 若已被禁用,则启用系统桌面 956 | if adb shell pm enable "$system_ui_package" >/dev/null 2>&1 && adb shell pm enable "$system_setup_package" >/dev/null 2>&1; then 957 | echo -e "${GREEN}恭喜您,您的系统桌面又回来啦! 请按HOME键确认。${NC}" 958 | adb shell input keyevent KEYCODE_HOME 959 | else 960 | echo -e "${RED}启用系统桌面或其他应用失败,请检查设备连接状态和权限。${NC}" 961 | fi 962 | 963 | else 964 | # 若未被禁用,则禁用系统桌面 965 | if adb shell pm disable-user --user 0 "$system_ui_package" >/dev/null 2>&1 && 966 | adb shell pm disable-user --user 0 "$system_setup_package" >/dev/null 2>&1; then 967 | echo -e "${GREEN}恭喜您,新桌面替换成功。点击HOME键 查看新桌面哦。${NC}" 968 | adb shell input keyevent KEYCODE_HOME 969 | else 970 | echo -e "${RED}禁用系统桌面失败,请检查设备连接状态和权限。${NC}" 971 | fi 972 | 973 | fi 974 | } 975 | 976 | # 替换或恢复系统桌面 977 | toggle_system_ui() { 978 | local system_ui_package=$1 979 | #判断emotnui是否安装 980 | check_emotnui_installed 981 | 982 | # 检查系统桌面是否已被禁用 983 | if adb shell pm list packages -d | grep -q "$system_ui_package"; then 984 | # 若已被禁用,则启用系统桌面 985 | if adb shell pm enable "$system_ui_package" >/dev/null 2>&1; then 986 | echo -e "${GREEN}恭喜您,您的系统桌面又回来啦! 请按HOME键确认。${NC}" 987 | adb shell input keyevent KEYCODE_HOME 988 | else 989 | echo -e "${RED}启用系统桌面失败,请检查设备连接状态和权限。${NC}" 990 | fi 991 | else 992 | # 若未被禁用,则禁用系统桌面 993 | if adb shell pm disable-user --user 0 "$system_ui_package" >/dev/null 2>&1; then 994 | echo -e "${GREEN}恭喜您,新桌面替换成功。点击HOME键 查看新桌面哦。${NC}" 995 | adb shell input keyevent KEYCODE_HOME 996 | else 997 | echo -e "${RED}禁用系统桌面失败,请检查设备连接状态和权限。${NC}" 998 | fi 999 | fi 1000 | } 1001 | 1002 | # 处理菜单 1003 | handle_choice() { 1004 | local choice=$1 1005 | # 检查输入是否为空 1006 | if [[ -z $choice ]]; then 1007 | echo -e "${RED}输入不能为空,请重新选择。${NC}" 1008 | return 1009 | fi 1010 | 1011 | # 检查输入是否为数字 1012 | if ! [[ $choice =~ ^[0-9]+$ ]]; then 1013 | echo -e "${RED}请输入有效数字!${NC}" 1014 | return 1015 | fi 1016 | 1017 | # 检查数字是否在有效范围内 1018 | if [[ $choice -lt 1 ]] || [[ $choice -gt ${#menu_options[@]} ]]; then 1019 | echo -e "${RED}选项超出范围!${NC}" 1020 | echo -e "${YELLOW}请输入 1 到 ${#menu_options[@]} 之间的数字。${NC}" 1021 | return 1022 | fi 1023 | 1024 | local selected_option="${menu_options[$choice - 1]}" 1025 | local command_to_run="${commands[$selected_option]}" 1026 | 1027 | # 检查是否存在对应的命令 1028 | if [ -z "$command_to_run" ]; then 1029 | echo -e "${RED}无效选项,请重新选择。${NC}" 1030 | return 1031 | fi 1032 | 1033 | # 使用eval执行命令 1034 | eval "$command_to_run" 1035 | } 1036 | 1037 | show_menu() { 1038 | mkdir -p /tvhelper/shells/data 1039 | clear 1040 | echo "***********************************************************************" 1041 | echo -e "* ${YELLOW}盒子助手Docker版 (v${docker_version})${NC} " 1042 | echo -e "* ${GREEN}base Alpine Linux${NC} " 1043 | echo -e "* ${RED}请确保电视盒子和Docker宿主机处于${NC}${BLUE}同一网段${NC}\n* ${RED}且电视盒子开启了${NC}${BLUE}USB调试模式(adb开关)${NC} " 1044 | echo "**********************************************************************" 1045 | echo "$(get_status)" 1046 | echo "$(get_tvbox_model_name)" 1047 | echo "$(get_tvbox_timezone)" 1048 | echo "**********************************************************************" 1049 | echo "请选择操作:" 1050 | for i in "${!menu_options[@]}"; do 1051 | echo -e "${BLUE}$((i + 1)). ${menu_options[i]}${NC}" 1052 | done 1053 | } 1054 | 1055 | while true; do 1056 | show_menu 1057 | read -p "请输入选项的序号(输入q退出): " choice 1058 | if [[ $choice == 'q' ]]; then 1059 | disconnect_adb 1060 | break 1061 | fi 1062 | handle_choice $choice 1063 | echo "按任意键继续..." 1064 | read -n 1 # 等待用户按键 1065 | done 1066 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------