11#! /usr/bin/env bash
22
3- # Copyright (c) 2021-2025 tteck
4- # Author: tteck (tteckster)
5- # License: MIT
6- # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
3+ # Copyright (c) 2021-2025 community-scripts ORG
4+ # Author: tteck (tteckster) | Co-Author: MickLesk
5+ # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
76
87function header_info {
98 clear
109 cat << "EOF "
1110 _______ __ ____
1211 / ____(_) /__ / __ )_________ _ __________ _____
1312 / /_ / / / _ \/ __ / ___/ __ \ | /| / / ___/ _ \/ ___/
14- / __/ / / / __/ /_/ / / / /_/ / |/ |/ (__ ) __/ /
15- /_/ /_/_/\___/_____/_/ \____/|__/|__/____/\___/_/
16-
13+ / __/ / / / __/ /_/ / / / /_/ / |/ |/ (__ ) __/ /
14+ /_/ /_/_/\___/_____/_/ \____/|__/|__/____/\___/_/
1715EOF
1816}
19- IP=$( hostname -I | awk ' {print $1}' )
2017YW=$( echo " \033[33m" )
21- BL=$( echo " \033[36m" )
22- RD=$( echo " \033[01;31m" )
23- BGN=$( echo " \033[4;92m" )
2418GN=$( echo " \033[1;92m" )
25- DGN=$( echo " \033[32m" )
19+ RD=$( echo " \033[01;31m" )
20+ BL=$( echo " \033[36m" )
2621CL=$( echo " \033[m" )
27- BFR=" \\ r\\ 033[K"
28- HOLD=" -"
29- CM=" ${GN} ✓${CL} "
22+ CM=" ${GN} ✔️${CL} "
23+ CROSS=" ${RD} ✖️${CL} "
24+ INFO=" ${BL} ℹ️${CL} "
25+
3026APP=" FileBrowser"
31- hostname=" $( hostname) "
32- header_info
33- if [ -f /root/filebrowser.db ]; then
34- read -r -p " Would you like to uninstall ${APP} on $hostname .? <y/N> " prompt
35- if [[ " ${prompt,,} " =~ ^(y| yes)$ ]]; then
36- systemctl disable -q --now filebrowser.service
37- rm -rf /usr/local/bin/filebrowser /root/filebrowser.db /etc/systemd/system/filebrowser.service
38- echo " $APP Removed"
39- sleep 2
40- clear
41- exit
42- else
43- clear
44- exit
45- fi
46- fi
47- while true ; do
48- read -p " This will Install ${APP} on $hostname . Proceed(y/n)?" yn
49- case $yn in
50- [Yy]* ) break ;;
51- [Nn]* ) exit ;;
52- * ) echo " Please answer yes or no." ;;
53- esac
54- done
27+ INSTALL_PATH=" /usr/local/bin/filebrowser"
28+ SERVICE_PATH=" /etc/systemd/system/filebrowser.service"
29+ DB_PATH=" /root/filebrowser.db"
30+ IP=$( hostname -I | awk ' {print $1}' )
5531header_info
32+
5633function msg_info() {
5734 local msg=" $1 "
58- echo -ne " ${HOLD } ${YW}${msg} ..."
35+ echo -e " ${INFO } ${YW}${msg} ...${CL} "
5936}
6037
6138function msg_ok() {
6239 local msg=" $1 "
63- echo -e " ${BFR} ${ CM} ${GN}${msg}${CL} "
40+ echo -e " ${CM} ${GN}${msg}${CL} "
6441}
6542
66- read -r -p " Would you like to use No Authentication? <y/N> " prompt
67- msg_info " Installing ${APP} "
68- apt-get install -y curl & > /dev/null
69- RELEASE=$( curl -fsSL https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep -o ' "tag_name": ".*"' | sed ' s/"//g' | sed ' s/tag_name: //g' )
70- curl -fsSL https://github.com/filebrowser/filebrowser/releases/download/$RELEASE /linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin & > /dev/null
43+ function msg_error() {
44+ local msg=" $1 "
45+ echo -e " ${CROSS} ${RD}${msg}${CL} "
46+ }
7147
72- if [[ " ${prompt,,} " =~ ^(y| yes)$ ]]; then
73- filebrowser config init -a ' 0.0.0.0' & > /dev/null
74- filebrowser config set -a ' 0.0.0.0' & > /dev/null
75- filebrowser config init --auth.method=noauth & > /dev/null
76- filebrowser config set --auth.method=noauth & > /dev/null
77- filebrowser users add ID 1 --perm.admin & > /dev/null
78- else
79- filebrowser config init -a ' 0.0.0.0' & > /dev/null
80- filebrowser config set -a ' 0.0.0.0' & > /dev/null
81- filebrowser users add admin helper-scripts.com --perm.admin & > /dev/null
48+ if [ -f " $INSTALL_PATH " ]; then
49+ echo -e " ${YW} ⚠️ ${APP} is already installed.${CL} "
50+ read -r -p " Would you like to uninstall ${APP} ? (y/N): " uninstall_prompt
51+ if [[ " ${uninstall_prompt,,} " =~ ^(y| yes)$ ]]; then
52+ msg_info " Uninstalling ${APP} "
53+ systemctl disable -q --now filebrowser.service
54+ rm -f " $INSTALL_PATH " " $DB_PATH " " $SERVICE_PATH "
55+ msg_ok " ${APP} has been uninstalled."
56+ exit 0
57+ fi
58+
59+ read -r -p " Would you like to update ${APP} ? (y/N): " update_prompt
60+ if [[ " ${update_prompt,,} " =~ ^(y| yes)$ ]]; then
61+ msg_info " Updating ${APP} "
62+ curl -fsSL https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin & > /dev/null
63+ msg_ok " Updated ${APP} "
64+ exit 0
65+ else
66+ echo -e " ${YW} ⚠️ Update skipped. Exiting.${CL} "
67+ exit 0
68+ fi
8269fi
83- msg_ok " Installed ${APP} on $hostname "
8470
85- msg_info " Creating Service"
86- cat << EOF >/etc/systemd/system/filebrowser.service
71+ echo -e " ${YW} ⚠️ ${APP} is not installed.${CL} "
72+ read -r -p " Would you like to install ${APP} ? (y/n): " install_prompt
73+ if [[ " ${install_prompt,,} " =~ ^(y| yes)$ ]]; then
74+ msg_info " Installing ${APP} "
75+ apt-get install -y curl & > /dev/null
76+ curl -fsSL https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin & > /dev/null
77+ msg_ok " Installed ${APP} "
78+
79+ read -r -p " Would you like to use No Authentication? (y/N): " auth_prompt
80+ if [[ " ${auth_prompt,,} " =~ ^(y| yes)$ ]]; then
81+ msg_info " Configuring No Authentication"
82+ filebrowser config init -a ' 0.0.0.0' & > /dev/null
83+ filebrowser config set -a ' 0.0.0.0' --auth.method=noauth & > /dev/null
84+ msg_ok " No Authentication configured"
85+ else
86+ msg_info " Setting up default authentication"
87+ filebrowser config init -a ' 0.0.0.0' & > /dev/null
88+ filebrowser config set -a ' 0.0.0.0' & > /dev/null
89+ filebrowser users add admin helper-scripts.com --perm.admin & > /dev/null
90+ msg_ok " Default authentication configured (admin:helper-scripts.com)"
91+ fi
92+
93+ msg_info " Creating service"
94+ cat << EOF >/etc/systemd/system/filebrowser.service
8795[Unit]
8896Description=Filebrowser
8997After=network-online.target
@@ -96,9 +104,11 @@ ExecStart=/usr/local/bin/filebrowser -r /
96104[Install]
97105WantedBy=default.target
98106EOF
99- systemctl enable -q --now filebrowser.service
100- msg_ok " Created Service"
107+ systemctl enable -q --now filebrowser.service
108+ msg_ok " Service created successfully "
101109
102- msg_ok " Completed Successfully!\n"
103- echo -e " ${APP} should be reachable by going to the following URL.
104- ${BL} http://$IP :8080${CL} \n"
110+ echo -e " ${CM} ${GN}${APP} is reachable at: ${BL} http://$IP :8080${CL} "
111+ else
112+ echo -e " ${YW} ⚠️ Installation skipped. Exiting.${CL} "
113+ exit 0
114+ fi
0 commit comments