├── README.md └── zfile.sh /README.md: -------------------------------------------------------------------------------- 1 | # 由来 2 | 3 | 前段时间偶然看到了赵大佬写的[Z-File](https://github.com/zhaojun1998/zfile),使用了一段时间之后,发现真的是一个特别方便的一个搭建下载站的程序。由于大佬没有去做命令行下的安装和升级的脚本,所以我就自己写了一个一键安装与管理脚本。(目前只支持linux下的一键安装) 4 | 5 | ## 代码功能 6 | 7 | * 安装Z-File运行环境 8 | * 安装Z-File 9 | * 卸载Z-File 10 | * 更新Z-File为最新版本 11 | * 安装旧版Z-File 12 | * 启动、停止、重启 13 | 14 | ## 使用教程 15 | 16 | ``` 17 | wget -P ~ https://raw.githubusercontent.com/iwayen/zfile-cli/master/zfile.sh && chmod +x zfile.sh && ./zfile.sh 18 | ``` 19 | 20 | # Z-File项目介绍 21 | 22 | ## Z-File 23 | 24 | 此项目是一个在线文件目录的程序, 支持各种对象存储和本地存储, 使用定位是个人放常用工具下载, 或做公共的文件库. 不会向多账户方向开发. 25 | 26 | 前端基于 [h5ai](https://larsjung.de/h5ai/) 的原有功能使用 Vue 重新开发了一遍. 后端采用 SpringBoot, 数据库采用内嵌数据库. 27 | 28 | 预览地址: [https://zfile.jun6.net](https://zfile.jun6.net) 29 | 30 | 文档地址: [http://docs.zhaojun.im/zfile](http://docs.zhaojun.im/zfile) 31 | 32 | ## 系统特色 33 | 34 | * 内存缓存 (免安装) 35 | * 内存数据库 (免安装) 36 | * 个性化配置 37 | * 自定义目录的 readme 说明文件 38 | * 自定义 JS, CSS 39 | * 文件夹密码 40 | * 支持在线浏览文本文件, 视频, 图片, 音乐. (支持 FLV 和 HLS) 41 | * 文件/目录二维码 42 | * 缓存动态开启, ~~缓存自动刷新 (v2.2 及以前版本支持)~~ 43 | * ~~全局搜索 (v2.2 及以前版本支持)~~ 44 | * 同时挂载多个存储策略 45 | * 支持 阿里云 OSS, FTP, 华为云 OBS, 本地存储, MINIO, OneDrive 国际/家庭/个人版, OneDrive 世纪互联版, 七牛云 KODO, 腾讯云 COS, 又拍云 USS. 46 | -------------------------------------------------------------------------------- /zfile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #================================================= 4 | # System Required: CentOS,Debian,Ubuntu 16+ 5 | # Description: Z-file管理脚本 6 | # Version: 0.1 7 | # Author: wayen 8 | # Blog: https://www.iwayen.cn/ 9 | # Github: https://github.com/iwayen/zfile-cli 10 | #================================================= 11 | 12 | #颜色设置 13 | Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m" 14 | 15 | #开始菜单 16 | start_menu(){ 17 | echo && echo -e " Z-file 管理脚本 ${Red_font_prefix}[v0.1]${Font_color_suffix} 18 | 19 | ${Red_font_prefix}务必在安装z-file前先安装java环境,可直接调用脚本安装${Font_color_suffix} 20 | 21 | ${Green_font_prefix}0.${Font_color_suffix} 更新Z-file至最新版本 22 | ————————————安装———————————— 23 | ${Green_font_prefix}1.${Font_color_suffix} 安装openjdk-8(java环境) 24 | ${Green_font_prefix}2.${Font_color_suffix} 安装最新版本Z-file 25 | ${Green_font_prefix}3.${Font_color_suffix} 安装旧版Z-file(自动替换目前的zfile) 26 | ————————————管理———————————— 27 | ${Green_font_prefix}4.${Font_color_suffix} 启动Z-file 28 | ${Green_font_prefix}5.${Font_color_suffix} 停止Z-file 29 | ${Green_font_prefix}6.${Font_color_suffix} 重启Z-file 30 | ${Green_font_prefix}7.${Font_color_suffix} 卸载Z-file 31 | ${Green_font_prefix}8.${Font_color_suffix} 退出脚本 32 | ————————————————————————————————" && echo 33 | 34 | read -p " 请输入数字 [0-8]:" num 35 | case "$num" in 36 | 0) 37 | Update_zfile 38 | start_menu 39 | ;; 40 | 1) 41 | install_jdk 42 | start_menu 43 | ;; 44 | 2) 45 | install_zfile_new 46 | start_menu 47 | ;; 48 | 3) 49 | install_zfile_last 50 | start_menu 51 | ;; 52 | 4) 53 | start_zfile 54 | ;; 55 | 5) 56 | stop_zfile 57 | ;; 58 | 6) 59 | restart_zfile 60 | ;; 61 | 7) 62 | uninstall_zfile 63 | ;; 64 | 8) 65 | exit 1 66 | ;; 67 | *) 68 | clear 69 | echo -e "${Error}:请输入正确数字 [0-7]" 70 | sleep 1s 71 | start_menu 72 | ;; 73 | esac 74 | } 75 | 76 | #清除之前的zfile 77 | clear_zfile(){ 78 | cd ~ 79 | if [ -d "zfile" ]; then 80 | ~/zfile/bin/stop.sh 81 | rm -rf ~/zfile 82 | fi 83 | } 84 | 85 | #卸载zfile 86 | uninstall_zfile(){ 87 | cd ~ 88 | if [ -d "zfile" ]; then 89 | ~/zfile/bin/stop.sh 90 | rm -rf ~/zfile 91 | rm -rf ~/.zfile* 92 | fi 93 | } 94 | 95 | #升级zfile 96 | Update_zfile(){ 97 | clear_zfile 98 | install_zfile_new 99 | start_zfile 100 | } 101 | 102 | #安装openjdk 103 | install_jdk(){ 104 | if [[ "${release}" == "centos" ]]; then 105 | sudo yum install -y java-1.8.0-openjdk unzip 106 | elif [[ "${release}" == "debian" ]]; then 107 | sudo apt update 108 | sudo apt install -y openjdk-8-jre-headless unzip 109 | elif [[ "${release}" == "ubuntu" ]]; then 110 | sudo apt update 111 | sudo apt install -y openjdk-8-jre-headless unzip 112 | fi 113 | } 114 | 115 | #安装最新版本Z-file 116 | install_zfile_new(){ 117 | clear_zfile 118 | cd ~ 119 | wget -P ~ https://c.jun6.net/ZFILE/zfile-release.war 120 | mkdir zfile && unzip zfile-release.war -d zfile && rm -rf zfile-release.war 121 | chmod +x ~/zfile/bin/*.sh 122 | start_zfile 123 | echo -e "安装成功,访问地址: ${Green_font_prefix}http://ip:8080${Font_color_suffix} 124 | 125 | ${Red_font_prefix}如无法访问,请检查服务器端口是否开放${Font_color_suffix}" 126 | } 127 | 128 | #安装Z-file 129 | install_zfile(){ 130 | clear_zfile 131 | cd ~ 132 | wget -P ~ https://c.jun6.net/ZFILE/zfile-"${1}".war 133 | mkdir zfile && unzip zfile-"${1}".war -d zfile && rm -rf zfile-"${1}".war 134 | chmod +x ~/zfile/bin/*.sh 135 | start_zfile 136 | echo -e "安装成功,访问地址 ${Green_font_prefix}http://ip:8080${Font_color_suffix} 137 | 138 | ${Red_font_prefix}如无法访问,请检查服务器端口是否开放${Font_color_suffix}" 139 | } 140 | 141 | #安装旧版Z-file 142 | install_zfile_last(){ 143 | echo && echo -e " Z-file 管理脚本 ${Red_font_prefix}[v0.1]${Font_color_suffix} 144 | 145 | ${Red_font_prefix}单盘与多盘互换时配置文件需要重新设置${Font_color_suffix} 146 | ${Red_font_prefix}但配置文件不会被删除,再次安装时可直接使用${Font_color_suffix} 147 | 148 | ————————————单盘———————————— 149 | ${Green_font_prefix}1.${Font_color_suffix} 安装Z-file v2.2(单盘版本) 150 | ————————————多盘———————————— 151 | ${Green_font_prefix}2.${Font_color_suffix} 安装Z-file v2.3(多盘版本) 152 | ${Green_font_prefix}3.${Font_color_suffix} 安装Z-file v2.4(多盘版本) 153 | ${Green_font_prefix}4.${Font_color_suffix} 安装Z-file v2.5(多盘版本) 154 | ${Green_font_prefix}5.${Font_color_suffix} 安装Z-file v2.6(多盘版本) 155 | ${Green_font_prefix}6.${Font_color_suffix} 安装Z-file v2.7(多盘版本) 156 | ${Green_font_prefix}7.${Font_color_suffix} 安装Z-file v2.8(多盘版本) 157 | ${Green_font_prefix}8.${Font_color_suffix} 安装Z-file v2.8.1(多盘版本) 158 | ${Green_font_prefix}9.${Font_color_suffix} 安装Z-file v2.9(多盘版本) 159 | ${Green_font_prefix}0.${Font_color_suffix} 退出脚本 160 | ————————————————————————————————" && echo 161 | 162 | read -p " 请输入数字 [0-3]:" num 163 | case "$num" in 164 | 0) 165 | exit 1 166 | ;; 167 | 1) 168 | clear_zfile 169 | install_zfile 2.2 170 | ;; 171 | 2) 172 | clear_zfile 173 | install_zfile 2.3 174 | ;; 175 | 3) 176 | clear_zfile 177 | install_zfile 2.4 178 | ;; 179 | 4) 180 | clear_zfile 181 | install_zfile 2.5 182 | ;; 183 | 5) 184 | clear_zfile 185 | install_zfile 2.6 186 | ;; 187 | 6) 188 | clear_zfile 189 | install_zfile 2.7 190 | ;; 191 | 7) 192 | clear_zfile 193 | install_zfile 2.8 194 | ;; 195 | 8) 196 | clear_zfile 197 | install_zfile 2.8.1 198 | ;; 199 | 9) 200 | clear_zfile 201 | install_zfile 2.9 202 | ;; 203 | *) 204 | clear 205 | echo -e "${Error}:请输入正确数字 [0-5]" 206 | sleep 1s 207 | install_zfile_last 208 | ;; 209 | esac 210 | } 211 | 212 | #启动Z-file 213 | start_zfile(){ 214 | ~/zfile/bin/start.sh 215 | } 216 | 217 | #停止Z-file 218 | stop_zfile(){ 219 | ~/zfile/bin/stop.sh 220 | } 221 | 222 | #重启Z-file 223 | restart_zfile(){ 224 | ~/zfile/bin/restart.sh 225 | } 226 | 227 | #检查系统 228 | check_sys(){ 229 | if [[ -f /etc/redhat-release ]]; then 230 | release="centos" 231 | elif cat /etc/issue | grep -q -E -i "debian"; then 232 | release="debian" 233 | elif cat /etc/issue | grep -q -E -i "ubuntu"; then 234 | release="ubuntu" 235 | elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then 236 | release="centos" 237 | elif cat /proc/version | grep -q -E -i "debian"; then 238 | release="debian" 239 | elif cat /proc/version | grep -q -E -i "ubuntu"; then 240 | release="ubuntu" 241 | elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then 242 | release="centos" 243 | fi 244 | } 245 | 246 | check_sys 247 | [[ ${release} != "debian" ]] && [[ ${release} != "ubuntu" ]] && [[ ${release} != "centos" ]] && echo -e "${Error} 本脚本不支持当前系统 ${release} !" && exit 1 248 | start_menu 249 | --------------------------------------------------------------------------------