mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-04-24 23:28:06 +00:00
Feature: Add optional Port for Filebrowser (#2224)
This commit is contained in:
parent
a1dd57ded6
commit
865e6fd3d7
@ -28,6 +28,8 @@ INSTALL_PATH="/usr/local/bin/filebrowser"
|
|||||||
SERVICE_PATH="/etc/systemd/system/filebrowser.service"
|
SERVICE_PATH="/etc/systemd/system/filebrowser.service"
|
||||||
DB_PATH="/var/lib/filebrowser/filebrowser.db"
|
DB_PATH="/var/lib/filebrowser/filebrowser.db"
|
||||||
IP=$(hostname -I | awk '{print $1}')
|
IP=$(hostname -I | awk '{print $1}')
|
||||||
|
DEFAULT_PORT=8080
|
||||||
|
|
||||||
header_info
|
header_info
|
||||||
|
|
||||||
function msg_info() {
|
function msg_info() {
|
||||||
@ -52,7 +54,6 @@ if [ -f "$INSTALL_PATH" ]; then
|
|||||||
msg_info "Uninstalling ${APP}"
|
msg_info "Uninstalling ${APP}"
|
||||||
systemctl disable -q --now filebrowser.service
|
systemctl disable -q --now filebrowser.service
|
||||||
rm -f "$INSTALL_PATH" "$DB_PATH" "$SERVICE_PATH"
|
rm -f "$INSTALL_PATH" "$DB_PATH" "$SERVICE_PATH"
|
||||||
|
|
||||||
msg_ok "${APP} has been uninstalled."
|
msg_ok "${APP} has been uninstalled."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -70,6 +71,9 @@ if [ -f "$INSTALL_PATH" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${YW}⚠️ ${APP} is not installed.${CL}"
|
echo -e "${YW}⚠️ ${APP} is not installed.${CL}"
|
||||||
|
read -r -p "Enter port number (Default: ${DEFAULT_PORT}): " PORT
|
||||||
|
PORT=${PORT:-$DEFAULT_PORT}
|
||||||
|
|
||||||
read -r -p "Would you like to install ${APP}? (y/n): " install_prompt
|
read -r -p "Would you like to install ${APP}? (y/n): " install_prompt
|
||||||
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Installing ${APP}"
|
msg_info "Installing ${APP}"
|
||||||
@ -86,19 +90,19 @@ if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
|||||||
read -r -p "Would you like to use No Authentication? (y/N): " auth_prompt
|
read -r -p "Would you like to use No Authentication? (y/N): " auth_prompt
|
||||||
if [[ "${auth_prompt,,}" =~ ^(y|yes)$ ]]; then
|
if [[ "${auth_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Configuring No Authentication"
|
msg_info "Configuring No Authentication"
|
||||||
filebrowser config init -a '0.0.0.0' --database /var/lib/filebrowser/filebrowser.db &>/dev/null
|
filebrowser config init -a '0.0.0.0' -p "$PORT" --database "$DB_PATH" &>/dev/null
|
||||||
filebrowser config set -a '0.0.0.0' --auth.method=noauth --database /var/lib/filebrowser/filebrowser.db &>/dev/null
|
filebrowser config set -a '0.0.0.0' -p "$PORT" --auth.method=noauth --database "$DB_PATH" &>/dev/null
|
||||||
msg_ok "No Authentication configured"
|
msg_ok "No Authentication configured"
|
||||||
else
|
else
|
||||||
msg_info "Setting up default authentication"
|
msg_info "Setting up default authentication"
|
||||||
filebrowser config init -a '0.0.0.0' --database /var/lib/filebrowser/filebrowser.db &>/dev/null
|
filebrowser config init -a '0.0.0.0' -p "$PORT" --database "$DB_PATH" &>/dev/null
|
||||||
filebrowser config set -a '0.0.0.0' --database /var/lib/filebrowser/filebrowser.db &>/dev/null
|
filebrowser config set -a '0.0.0.0' -p "$PORT" --database "$DB_PATH" &>/dev/null
|
||||||
filebrowser users add admin helper-scripts.com --perm.admin --database /var/lib/filebrowser/filebrowser.db &>/dev/null
|
filebrowser users add admin helper-scripts.com --perm.admin --database "$DB_PATH" &>/dev/null
|
||||||
msg_ok "Default authentication configured (admin:helper-scripts.com)"
|
msg_ok "Default authentication configured (admin:helper-scripts.com)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_info "Creating service"
|
msg_info "Creating service"
|
||||||
cat <<EOF >/etc/systemd/system/filebrowser.service
|
cat <<EOF > "$SERVICE_PATH"
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Filebrowser
|
Description=Filebrowser
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
@ -106,7 +110,7 @@ After=network-online.target
|
|||||||
[Service]
|
[Service]
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=/var/lib/filebrowser/
|
WorkingDirectory=/var/lib/filebrowser/
|
||||||
ExecStart=/usr/local/bin/filebrowser -r / --database /var/lib/filebrowser/filebrowser.db
|
ExecStart=/usr/local/bin/filebrowser -r / --database "$DB_PATH" -p "$PORT"
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
@ -115,7 +119,7 @@ EOF
|
|||||||
systemctl enable -q --now filebrowser.service
|
systemctl enable -q --now filebrowser.service
|
||||||
msg_ok "Service created successfully"
|
msg_ok "Service created successfully"
|
||||||
|
|
||||||
echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:8080${CL}"
|
echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:$PORT${CL}"
|
||||||
else
|
else
|
||||||
echo -e "${YW}⚠️ Installation skipped. Exiting.${CL}"
|
echo -e "${YW}⚠️ Installation skipped. Exiting.${CL}"
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user