@@ -28,6 +28,8 @@ INSTALL_PATH="/usr/local/bin/filebrowser"
2828SERVICE_PATH=" /etc/systemd/system/filebrowser.service"
2929DB_PATH=" /var/lib/filebrowser/filebrowser.db"
3030IP=$( hostname -I | awk ' {print $1}' )
31+ DEFAULT_PORT=8080
32+
3133header_info
3234
3335function msg_info() {
@@ -52,7 +54,6 @@ if [ -f "$INSTALL_PATH" ]; then
5254 msg_info " Uninstalling ${APP} "
5355 systemctl disable -q --now filebrowser.service
5456 rm -f " $INSTALL_PATH " " $DB_PATH " " $SERVICE_PATH "
55-
5657 msg_ok " ${APP} has been uninstalled."
5758 exit 0
5859 fi
@@ -70,6 +71,9 @@ if [ -f "$INSTALL_PATH" ]; then
7071fi
7172
7273echo -e " ${YW} ⚠️ ${APP} is not installed.${CL} "
74+ read -r -p " Enter port number (Default: ${DEFAULT_PORT} ): " PORT
75+ PORT=${PORT:- $DEFAULT_PORT }
76+
7377read -r -p " Would you like to install ${APP} ? (y/n): " install_prompt
7478if [[ " ${install_prompt,,} " =~ ^(y| yes)$ ]]; then
7579 msg_info " Installing ${APP} "
@@ -86,27 +90,27 @@ if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
8690 read -r -p " Would you like to use No Authentication? (y/N): " auth_prompt
8791 if [[ " ${auth_prompt,,} " =~ ^(y| yes)$ ]]; then
8892 msg_info " Configuring No Authentication"
89- filebrowser config init -a ' 0.0.0.0' -- database /var/lib/filebrowser/filebrowser.db & > /dev/null
90- filebrowser config set -a ' 0.0.0.0' -- auth.method=noauth --database /var/lib/filebrowser/filebrowser.db & > /dev/null
93+ filebrowser config init -a ' 0.0.0.0' -p " $PORT " -- database " $DB_PATH " & > /dev/null
94+ filebrowser config set -a ' 0.0.0.0' -p " $PORT " -- auth.method=noauth --database " $DB_PATH " & > /dev/null
9195 msg_ok " No Authentication configured"
9296 else
9397 msg_info " Setting up default authentication"
94- filebrowser config init -a ' 0.0.0.0' -- database /var/lib/filebrowser/filebrowser.db & > /dev/null
95- filebrowser config set -a ' 0.0.0.0' -- database /var/lib/filebrowser/filebrowser.db & > /dev/null
96- filebrowser users add admin helper-scripts.com --perm.admin --database /var/lib/filebrowser/filebrowser.db & > /dev/null
98+ filebrowser config init -a ' 0.0.0.0' -p " $PORT " -- database " $DB_PATH " & > /dev/null
99+ filebrowser config set -a ' 0.0.0.0' -p " $PORT " -- database " $DB_PATH " & > /dev/null
100+ filebrowser users add admin helper-scripts.com --perm.admin --database " $DB_PATH " & > /dev/null
97101 msg_ok " Default authentication configured (admin:helper-scripts.com)"
98102 fi
99103
100104 msg_info " Creating service"
101- cat << EOF >/etc/systemd/system/filebrowser.service
105+ cat << EOF > " $SERVICE_PATH "
102106[Unit]
103107Description=Filebrowser
104108After=network-online.target
105109
106110[Service]
107111User=root
108112WorkingDirectory=/var/lib/filebrowser/
109- ExecStart=/usr/local/bin/filebrowser -r / --database /var/lib/filebrowser/filebrowser.db
113+ ExecStart=/usr/local/bin/filebrowser -r / --database " $DB_PATH " -p " $PORT "
110114Restart=always
111115
112116[Install]
115119 systemctl enable -q --now filebrowser.service
116120 msg_ok " Service created successfully"
117121
118- echo -e " ${CM} ${GN}${APP} is reachable at: ${BL} http://$IP :8080 ${CL} "
122+ echo -e " ${CM} ${GN}${APP} is reachable at: ${BL} http://$IP :$PORT ${CL} "
119123else
120124 echo -e " ${YW} ⚠️ Installation skipped. Exiting.${CL} "
121125 exit 0
0 commit comments