mirror of https://github.com/tteck/Proxmox.git
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
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
|
||||||
function header_info {
|
function header_info {
|
||||||
|
clear
|
||||||
cat <<"EOF"
|
cat <<"EOF"
|
||||||
_______ __ ____
|
_______ __ ____
|
||||||
/ ____(_) /__ / __ )_________ _ __________ _____
|
/ ____(_) /__ / __ )_________ _ __________ _____
|
||||||
|
@ -28,24 +29,21 @@ HOLD="-"
|
||||||
CM="${GN}✓${CL}"
|
CM="${GN}✓${CL}"
|
||||||
APP="FileBrowser"
|
APP="FileBrowser"
|
||||||
hostname="$(hostname)"
|
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
|
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
|
while true; do
|
||||||
read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn
|
read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn
|
||||||
case $yn in
|
case $yn in
|
||||||
|
@ -54,7 +52,6 @@ while true; do
|
||||||
*) echo "Please answer yes or no." ;;
|
*) echo "Please answer yes or no." ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
clear
|
|
||||||
header_info
|
header_info
|
||||||
function msg_info() {
|
function msg_info() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
|
@ -66,17 +63,27 @@ function msg_ok() {
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read -r -p "Would you like to use No Authentication? <y/N> " prompt
|
||||||
msg_info "Installing ${APP}"
|
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')
|
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
|
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
|
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
filebrowser users add admin changeme --perm.admin &>/dev/null
|
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_ok "Installed ${APP} on $hostname"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
service_path="/etc/systemd/system/filebrowser.service"
|
cat <<EOF >/etc/systemd/system/filebrowser.service
|
||||||
echo "[Unit]
|
[Unit]
|
||||||
Description=Filebrowser
|
Description=Filebrowser
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
|
|
||||||
|
@ -86,9 +93,9 @@ WorkingDirectory=/root/
|
||||||
ExecStart=/usr/local/bin/filebrowser -r /
|
ExecStart=/usr/local/bin/filebrowser -r /
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target" >$service_path
|
WantedBy=default.target
|
||||||
|
EOF
|
||||||
systemctl enable --now filebrowser.service &>/dev/null
|
systemctl enable -q --now filebrowser.service
|
||||||
msg_ok "Created Service"
|
msg_ok "Created Service"
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
msg_ok "Completed Successfully!\n"
|
||||||
|
|
Loading…
Reference in New Issue