Created
November 19, 2024 21:36
-
-
Save davecoutts/5f8113dfade564abdb9de2f3bcf6ff4c to your computer and use it in GitHub Desktop.
Install File Browser webserver serving an ephemeral temporary directory with no authentication. https://filebrowser.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----------------------------------------------------------------------------------------------- | |
# Install File Browser binary | |
#----------------------------------------------------------------------------------------------- | |
# https://filebrowser.org/installation | |
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash | |
ls -lha /usr/local/bin | |
#----------------------------------------------------------------------------------------------- | |
# Create configuration directory and json configuration file | |
# | |
# The web server will serve directory '/tmp/filebrowser' via https on port 8085 | |
#----------------------------------------------------------------------------------------------- | |
mkdir -p ~/.config/filebrowser | |
cat << EOF > ~/.config/filebrowser/filebrowser.json | |
{ | |
"port": 8085, | |
"address": "0.0.0.0", | |
"log": "stdout", | |
"database": "${HOME}/.config/filebrowser/filebrowser.db", | |
"root": "/tmp/filebrowser", | |
"cert": "${HOME}/.config/filebrowser/ssl_crt.pem", | |
"key": "${HOME}/.config/filebrowser/ssl_key.pem" | |
} | |
EOF | |
cat ~/.config/filebrowser/filebrowser.json | |
#----------------------------------------------------------------------------------------------- | |
# Create Systemctl service file. Set to auto start File Browser at system startup. | |
# | |
# Note the environment variable FB_NOAUTH turns off authentication | |
#----------------------------------------------------------------------------------------------- | |
cat << EOF | sudo tee /etc/systemd/system/filebrowser.service | |
[Unit] | |
Description=File Browser | |
After=network.target | |
[Service] | |
User=dave | |
Environment="FB_NOAUTH=true" | |
ExecStartPre=/usr/bin/mkdir -p /tmp/filebrowser | |
ExecStart=/usr/local/bin/filebrowser -c ${HOME}/.config/filebrowser/filebrowser.json | |
Restart=always | |
RestartSec=60 | |
StartLimitBurst=3 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
sudo systemctl daemon-reload | |
systemctl cat filebrowser.service | |
sudo systemctl enable filebrowser.service | |
#----------------------------------------------------------------------------------------------- | |
# Start and check the service | |
#----------------------------------------------------------------------------------------------- | |
sudo systemctl start filebrowser.service | |
systemctl status filebrowser.service | |
journalctl -xeu filebrowser.service | |
ls -lha ~/.config/filebrowser | |
#----------------------------------------------------------------------------------------------- | |
# Go to the web server address | |
#----------------------------------------------------------------------------------------------- | |
# https://yourhostname.lan:8085 | |
#----------------------------------------------------------------------------------------------- | |
# End | |
#----------------------------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment