├── README.md ├── LICENSE └── filebrowser.sh /README.md: -------------------------------------------------------------------------------- 1 | # filebrowser 2 | Filebrowser 一键安装脚本 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /filebrowser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red='\e[91m' 4 | green='\e[92m' 5 | yellow='\e[93m' 6 | none='\e[0m' 7 | 8 | [[ $(id -u) != 0 ]] && echo -e " \n哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}\n" && exit 1 9 | 10 | cmd="apt-get" 11 | 12 | sys_bit=$(uname -m) 13 | 14 | # 笨笨的检测方法 15 | if [[ -f /usr/bin/apt-get || -f /usr/bin/yum ]] && [[ -f /bin/systemctl ]]; then 16 | 17 | if [[ -f /usr/bin/yum ]]; then 18 | 19 | cmd="yum" 20 | 21 | fi 22 | 23 | else 24 | 25 | echo -e " \n哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}\n" && exit 1 26 | 27 | fi 28 | 29 | if [[ $sys_bit == "i386" || $sys_bit == "i686" ]]; then 30 | filebrowser="linux-386-filebrowser.tar.gz" 31 | elif [[ $sys_bit == "x86_64" ]]; then 32 | filebrowser="linux-386-filebrowser.tar.gz" 33 | elif [[ $sys_bit == "aarch64" ]]; then 34 | filebrowser="linux-arm64-filebrowser.tar.gz" 35 | else 36 | echo -e " \n$red毛支持你的系统....$none\n" && exit 1 37 | fi 38 | 39 | install() { 40 | $cmd install wget -y 41 | ver=$(curl -s https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep 'tag_name' | cut -d\" -f4) 42 | Filebrowser_download_link="https://github.com/filebrowser/filebrowser/releases/download/$ver/$filebrowser" 43 | mkdir -p /tmp/Filebrowser 44 | if ! wget --no-check-certificate --no-cache -O "/tmp/Filebrowser.tar.gz" $Filebrowser_download_link; then 45 | echo -e "$red 下载 Filebrowser 失败!$none" && exit 1 46 | fi 47 | tar zxf /tmp/Filebrowser.tar.gz -C /tmp/Filebrowser 48 | cp -f /tmp/Filebrowser/filebrowser /usr/bin/filebrowser 49 | chmod +x /usr/bin/filebrowser 50 | if [[ -f /usr/bin/filebrowser ]]; then 51 | cat >/lib/systemd/system/filebrowser.service <<-EOF 52 | [Unit] 53 | Description=Filebrowser Service 54 | After=network.target 55 | Wants=network.target 56 | 57 | [Service] 58 | Type=simple 59 | PIDFile=/var/run/filebrowser.pid 60 | ExecStart=/usr/bin/filebrowser -c /etc/filebrowser/filebrowser.json 61 | Restart=on-failure 62 | 63 | [Install] 64 | WantedBy=multi-user.target 65 | EOF 66 | 67 | mkdir -p /etc/filebrowser 68 | cat >/etc/filebrowser/filebrowser.json <<-EOF 69 | { 70 | "port": 9184, 71 | "baseURL": "", 72 | "address": "", 73 | "log": "stdout", 74 | "database": "/etc/filebrowser/database.db", 75 | "root": "/etc/filebrowser/" 76 | } 77 | EOF 78 | 79 | get_ip 80 | systemctl enable filebrowser 81 | systemctl start filebrowser 82 | 83 | clear 84 | echo -e " 85 | Filebrowser 安装完成啦! 86 | 87 | 预览地址: ${yellow}http://${ip}:9184/$none 88 | 89 | 用户名: ${green}admin$none 90 | 91 | 密码: ${green}admin$none 92 | 93 | $red重要提示,大佬赶紧的打开预览地址登录 并修改密码啊啊啊啊啊$none 94 | 95 | 脚本帮助说明: https://233blog.com/post/26/ 96 | " 97 | else 98 | echo -e " \n$red安装失败...$none\n" 99 | fi 100 | rm -rf /tmp/Filebrowser 101 | rm -rf /tmp/Filebrowser.tar.gz 102 | } 103 | uninstall() { 104 | if [[ -f /usr/bin/filebrowser && -f /etc/filebrowser/filebrowser.json ]]; then 105 | Filebrowser_pid=$(pgrep "filebrowser") 106 | [ $Filebrowser_pid ] && systemctl stop filebrowser 107 | systemctl disable filebrowser >/dev/null 2>&1 108 | rm -rf /usr/bin/filebrowser 109 | rm -rf /etc/filebrowser 110 | rm -rf /lib/systemd/system/filebrowser.service 111 | echo -e " \n$green卸载完成...$none\n" && exit 1 112 | else 113 | echo -e " \n$red大胸弟...你貌似毛有安装 Filebrowser ....卸载个鸡鸡哦...$none\n" && exit 1 114 | fi 115 | } 116 | get_ip() { 117 | ip=$(curl -s ipinfo.io/ip) 118 | } 119 | error() { 120 | 121 | echo -e "\n$red 输入错误!$none\n" 122 | 123 | } 124 | while :; do 125 | echo 126 | echo "........... Filebrowser 快速一键安装 by 233blog.com .........." 127 | echo 128 | echo "帮助说明: https://233blog.com/post/26/" 129 | echo 130 | echo " 1. 安装" 131 | echo 132 | echo " 2. 卸载" 133 | echo 134 | read -p "请选择[1-2]:" choose 135 | case $choose in 136 | 1) 137 | install 138 | break 139 | ;; 140 | 2) 141 | uninstall 142 | break 143 | ;; 144 | *) 145 | error 146 | ;; 147 | esac 148 | done 149 | --------------------------------------------------------------------------------