mirror of
https://github.com/tteck/Proxmox.git
synced 2024-11-22 08:13:11 +01:00
Update filebrowser.sh
- Uninstall by re-executing the script - Option to use No Authentication
This commit is contained in:
parent
8bc37d93b7
commit
8b0f6b27fe
@ -6,6 +6,7 @@
|
||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||
|
||||
function header_info {
|
||||
clear
|
||||
cat <<"EOF"
|
||||
_______ __ ____
|
||||
/ ____(_) /__ / __ )_________ _ __________ _____
|
||||
@ -28,24 +29,21 @@ HOLD="-"
|
||||
CM="${GN}✓${CL}"
|
||||
APP="FileBrowser"
|
||||
hostname="$(hostname)"
|
||||
set -o errexit
|
||||
set -o errtrace
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
shopt -s expand_aliases
|
||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||
trap die ERR
|
||||
|
||||
function error_exit() {
|
||||
trap - ERR
|
||||
local reason="Unknown failure occured."
|
||||
local msg="${1:-$reason}"
|
||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
||||
echo -e "$flag $msg" 1>&2
|
||||
exit $EXIT
|
||||
}
|
||||
clear
|
||||
header_info
|
||||
if [ -f /root/filebrowser.db ]; then
|
||||
read -r -p "Would you like to uninstall ${APP} on $hostname.? <y/N> " prompt
|
||||
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
systemctl disable -q --now filebrowser.service
|
||||
rm -rf /usr/local/bin/filebrowser /root/filebrowser.db /etc/systemd/system/filebrowser.service
|
||||
echo "$APP Removed"
|
||||
sleep 2
|
||||
clear
|
||||
exit
|
||||
else
|
||||
clear
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
while true; do
|
||||
read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn
|
||||
case $yn in
|
||||
@ -54,7 +52,6 @@ while true; do
|
||||
*) echo "Please answer yes or no." ;;
|
||||
esac
|
||||
done
|
||||
clear
|
||||
header_info
|
||||
function msg_info() {
|
||||
local msg="$1"
|
||||
@ -66,17 +63,27 @@ function msg_ok() {
|
||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||
}
|
||||
|
||||
read -r -p "Would you like to use No Authentication? <y/N> " prompt
|
||||
msg_info "Installing ${APP}"
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g')
|
||||
curl -fsSL https://github.com/filebrowser/filebrowser/releases/download/$RELEASE/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null
|
||||
filebrowser config init -a '0.0.0.0' &>/dev/null
|
||||
filebrowser config set -a '0.0.0.0' &>/dev/null
|
||||
filebrowser users add admin changeme --perm.admin &>/dev/null
|
||||
|
||||
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
filebrowser config init -a '0.0.0.0' &>/dev/null
|
||||
filebrowser config set -a '0.0.0.0' &>/dev/null
|
||||
filebrowser config init --auth.method=noauth &>/dev/null
|
||||
filebrowser config set --auth.method=noauth &>/dev/null
|
||||
filebrowser users add ID 1 --perm.admin &>/dev/null
|
||||
else
|
||||
filebrowser config init -a '0.0.0.0' &>/dev/null
|
||||
filebrowser config set -a '0.0.0.0' &>/dev/null
|
||||
filebrowser users add admin changeme --perm.admin &>/dev/null
|
||||
fi
|
||||
msg_ok "Installed ${APP} on $hostname"
|
||||
|
||||
msg_info "Creating Service"
|
||||
service_path="/etc/systemd/system/filebrowser.service"
|
||||
echo "[Unit]
|
||||
cat <<EOF >/etc/systemd/system/filebrowser.service
|
||||
[Unit]
|
||||
Description=Filebrowser
|
||||
After=network-online.target
|
||||
|
||||
@ -86,9 +93,9 @@ WorkingDirectory=/root/
|
||||
ExecStart=/usr/local/bin/filebrowser -r /
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target" >$service_path
|
||||
|
||||
systemctl enable --now filebrowser.service &>/dev/null
|
||||
WantedBy=default.target
|
||||
EOF
|
||||
systemctl enable -q --now filebrowser.service
|
||||
msg_ok "Created Service"
|
||||
|
||||
msg_ok "Completed Successfully!\n"
|
||||
|
Loading…
Reference in New Issue
Block a user