mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-04-19 22:08:07 +00:00
Feature: Filebrowser: support now alpine (#2997)
* Feature: Filebrowser LXC: support now alpine * add alpine bash path to website
This commit is contained in:
parent
f6a6ca5e26
commit
6de4a8107c
@ -24,6 +24,17 @@
|
|||||||
"os": null,
|
"os": null,
|
||||||
"version": null
|
"version": null
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "alpine",
|
||||||
|
"script": "misc/filebrowser.sh",
|
||||||
|
"resources": {
|
||||||
|
"cpu": null,
|
||||||
|
"ram": null,
|
||||||
|
"hdd": null,
|
||||||
|
"os": null,
|
||||||
|
"version": null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"default_credentials": {
|
"default_credentials": {
|
||||||
|
@ -14,6 +14,7 @@ function header_info {
|
|||||||
/_/ /_/_/\___/_____/_/ \____/|__/|__/____/\___/_/
|
/_/ /_/_/\___/_____/_/ \____/|__/|__/____/\___/_/
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
YW=$(echo "\033[33m")
|
YW=$(echo "\033[33m")
|
||||||
GN=$(echo "\033[1;92m")
|
GN=$(echo "\033[1;92m")
|
||||||
RD=$(echo "\033[01;31m")
|
RD=$(echo "\033[01;31m")
|
||||||
@ -25,11 +26,31 @@ INFO="${BL}ℹ️${CL}"
|
|||||||
|
|
||||||
APP="FileBrowser"
|
APP="FileBrowser"
|
||||||
INSTALL_PATH="/usr/local/bin/filebrowser"
|
INSTALL_PATH="/usr/local/bin/filebrowser"
|
||||||
SERVICE_PATH="/etc/systemd/system/filebrowser.service"
|
|
||||||
DB_PATH="/usr/local/community-scripts/filebrowser.db"
|
DB_PATH="/usr/local/community-scripts/filebrowser.db"
|
||||||
IP=$(hostname -I | awk '{print $1}')
|
|
||||||
DEFAULT_PORT=8080
|
DEFAULT_PORT=8080
|
||||||
|
|
||||||
|
# Get first non-loopback IP & Detect primary network interface dynamically
|
||||||
|
IFACE=$(ip -4 route | awk '/default/ {print $5; exit}')
|
||||||
|
IP=$(ip -4 addr show "$IFACE" | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1)
|
||||||
|
|
||||||
|
[[ -z "$IP" ]] && IP=$(hostname -I | awk '{print $1}')
|
||||||
|
[[ -z "$IP" ]] && IP="127.0.0.1"
|
||||||
|
|
||||||
|
|
||||||
|
# Detect OS
|
||||||
|
if [[ -f "/etc/alpine-release" ]]; then
|
||||||
|
OS="Alpine"
|
||||||
|
SERVICE_PATH="/etc/init.d/filebrowser"
|
||||||
|
PKG_MANAGER="apk add --no-cache"
|
||||||
|
elif [[ -f "/etc/debian_version" ]]; then
|
||||||
|
OS="Debian"
|
||||||
|
SERVICE_PATH="/etc/systemd/system/filebrowser.service"
|
||||||
|
PKG_MANAGER="apt-get install -y"
|
||||||
|
else
|
||||||
|
echo -e "${CROSS} Unsupported OS detected. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
header_info
|
header_info
|
||||||
|
|
||||||
function msg_info() {
|
function msg_info() {
|
||||||
@ -52,8 +73,15 @@ if [ -f "$INSTALL_PATH" ]; then
|
|||||||
read -r -p "Would you like to uninstall ${APP}? (y/N): " uninstall_prompt
|
read -r -p "Would you like to uninstall ${APP}? (y/N): " uninstall_prompt
|
||||||
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
|
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Uninstalling ${APP}"
|
msg_info "Uninstalling ${APP}"
|
||||||
systemctl disable -q --now filebrowser.service
|
if [[ "$OS" == "Debian" ]]; then
|
||||||
rm -f "$INSTALL_PATH" "$DB_PATH" "$SERVICE_PATH"
|
systemctl disable --now filebrowser.service &>/dev/null
|
||||||
|
rm -f "$SERVICE_PATH"
|
||||||
|
else
|
||||||
|
rc-service filebrowser stop &>/dev/null
|
||||||
|
rc-update del filebrowser &>/dev/null
|
||||||
|
rm -f "$SERVICE_PATH"
|
||||||
|
fi
|
||||||
|
rm -f "$INSTALL_PATH" "$DB_PATH"
|
||||||
msg_ok "${APP} has been uninstalled."
|
msg_ok "${APP} has been uninstalled."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -61,7 +89,8 @@ if [ -f "$INSTALL_PATH" ]; then
|
|||||||
read -r -p "Would you like to update ${APP}? (y/N): " update_prompt
|
read -r -p "Would you like to update ${APP}? (y/N): " update_prompt
|
||||||
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
|
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Updating ${APP}"
|
msg_info "Updating ${APP}"
|
||||||
curl -fsSL https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null
|
wget -qO- https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null
|
||||||
|
chmod +x "$INSTALL_PATH"
|
||||||
msg_ok "Updated ${APP}"
|
msg_ok "Updated ${APP}"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
@ -76,15 +105,19 @@ 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} on ${OS}"
|
||||||
apt-get install -y curl &>/dev/null
|
$PKG_MANAGER wget tar curl &>/dev/null
|
||||||
curl -fsSL https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null
|
wget -qO- https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null
|
||||||
|
chmod +x "$INSTALL_PATH"
|
||||||
msg_ok "Installed ${APP}"
|
msg_ok "Installed ${APP}"
|
||||||
|
|
||||||
msg_info "Creating FileBrowser directory"
|
msg_info "Creating FileBrowser directory"
|
||||||
mkdir -p /usr/local/community-scripts
|
mkdir -p /usr/local/community-scripts
|
||||||
chown root:root /usr/local/community-scripts
|
chown root:root /usr/local/community-scripts
|
||||||
chmod 755 /usr/local/community-scripts
|
chmod 755 /usr/local/community-scripts
|
||||||
|
touch "$DB_PATH"
|
||||||
|
chown root:root "$DB_PATH"
|
||||||
|
chmod 644 "$DB_PATH"
|
||||||
msg_ok "Directory created successfully"
|
msg_ok "Directory created successfully"
|
||||||
|
|
||||||
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
|
||||||
@ -107,6 +140,7 @@ if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
msg_info "Creating service"
|
msg_info "Creating service"
|
||||||
|
if [[ "$OS" == "Debian" ]]; then
|
||||||
cat <<EOF > "$SERVICE_PATH"
|
cat <<EOF > "$SERVICE_PATH"
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Filebrowser
|
Description=Filebrowser
|
||||||
@ -115,13 +149,33 @@ After=network-online.target
|
|||||||
[Service]
|
[Service]
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=/usr/local/community-scripts
|
WorkingDirectory=/usr/local/community-scripts
|
||||||
ExecStart=/usr/local/bin/filebrowser -r / -d "$DB_PATH" -p "$PORT"
|
ExecStartPre=/bin/touch /usr/local/community-scripts/filebrowser.db
|
||||||
|
ExecStartPre=/usr/local/bin/filebrowser config set -a "0.0.0.0" -p 9000 -d /usr/local/community-scripts/filebrowser.db
|
||||||
|
ExecStart=/usr/local/bin/filebrowser -r / -d /usr/local/community-scripts/filebrowser.db -p 9000
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
systemctl enable -q --now filebrowser.service
|
systemctl enable -q --now filebrowser
|
||||||
|
else
|
||||||
|
cat <<EOF > "$SERVICE_PATH"
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
command="/usr/local/bin/filebrowser"
|
||||||
|
command_args="-r / -d $DB_PATH -p $PORT"
|
||||||
|
command_background=true
|
||||||
|
pidfile="/var/run/filebrowser.pid"
|
||||||
|
directory="/usr/local/community-scripts"
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need net
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
chmod +x "$SERVICE_PATH"
|
||||||
|
rc-update add filebrowser default &>/dev/null
|
||||||
|
rc-service filebrowser start &>/dev/null
|
||||||
|
fi
|
||||||
msg_ok "Service created successfully"
|
msg_ok "Service created successfully"
|
||||||
|
|
||||||
echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:$PORT${CL}"
|
echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:$PORT${CL}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user