Feature: Add Alpine Version
This commit is contained in:
parent
7bbdb8cc57
commit
3bd99f0cfb
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Copyright (c) 2021-2025 community-scripts ORG
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
# Author: tteck (tteckster) | Co-Author: MickLesk
|
# Author: tteck (tteckster) | Co-Author: MickLesk
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
|
||||||
function header_info {
|
function header_info {
|
||||||
clear
|
clear
|
||||||
@ -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,24 @@ 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}')
|
IP=$(hostname -I | awk '{print $1}')
|
||||||
DEFAULT_PORT=8080
|
DEFAULT_PORT=8080
|
||||||
|
|
||||||
|
# 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 +66,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 +82,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,9 +98,10 @@ 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"
|
||||||
@ -107,6 +130,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
|
||||||
@ -121,7 +145,25 @@ 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
|
||||||
|
rc-service filebrowser start
|
||||||
|
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