refined autoremove support

This commit is contained in:
2018-11-18 09:42:41 +02:00
parent 375628255d
commit 9e20d4e115
6 changed files with 55 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
# FLEES
A very small file sharing website.
A small file sharing website.
The name comes from mispronouncing "files" very badly.
@@ -16,14 +16,15 @@ The name comes from mispronouncing "files" very badly.
- generate and manage shares with `code/flees-manager.py`
- configure service with data/config.json
- Change your app_secret_key !!
- Change your public_url
- uid = user id for new files
- workers = parallel processes (i.e. one upload reserves a process)
- timeout = timeout for processes, single upload might take a long time!
- max_zip_size = zipping a share with more data is not allowed
- Change your `app_secret_key` !!
- Change your `public_url`
- Change your `timezone`
- `uid` = user id for new files
- `workers` = parallel processes (i.e. one upload reserves a process)
- `timeout` = timeout for processes, single upload might take a long time!
- `max_zip_size` = zipping a share with more data is not allowed
- configure bind host and port in .env
- proxy with nginx, match body size and timeout to your needs:
- proxy with nginx, match bind port, body size and timeout to your needs:
```
location /flees/ {
proxy_pass http://localhost:8136/;
@@ -36,7 +37,6 @@ location /flees/ {
}
```
- configure local port in `docker-compose.yaml`
- change website colors in code/static/css/colors.css
- Check `flees-manager.py rest` command to get direct links to various
@@ -96,11 +96,13 @@ Operation is one of download, direct_download, zip_download, or upload
- @app.route('/files/<name>/<token>', methods=['GET'])
Return plain text list of files in the share
- @app.route('/list/<name>/<token>', methods=['GET'])
Login to a share with a token
List share contents for the browser
- @app.route('/list/<name>', methods=['GET'])
List share contents for the browser
- @app.route('/logout/<name>', methods=['GET'])
Logout from share. Only for browser.
- @app.route('/ls/<name>/<token>', methods=['GET'])
List share contents for the console client
- @app.route('/direct/<name>/<token>/<filename>', methods=['GET'])
Download a file using the filename token (if direct download enabled)
- @app.route('/download/<name>/<token>/<filename>', methods=['GET'])

View File

@@ -1,5 +1,6 @@
FROM alpine:3.5
RUN apk add --update \
tzdata \
python3 \
python3-dev \
py3-pip \

View File

@@ -14,7 +14,7 @@ from utils.utils import *
from utils.crypt import *
__FLEES_VERSION__ = "20181104.0"
__FLEES_VERSION__ = "20181118.0"
app = Flask(__name__)
app.config.from_object(__name__)
config_values = read_config(app)

View File

@@ -1,11 +1,34 @@
import subprocess,json
import json
import os
import subprocess
config = json.load(open('data/config.json','rt'))
config = json.load(open(os.environ['FLEES_CONFIG'],'rt'))
subprocess.call([
'gunicorn',
'-b','0.0.0.0:80',
'--timeout',str(config['timeout']),
'-w',str(config['workers']),
'app:app'
])
TZ = "Etc/UTC"
if 'timezone' in config:
TZ = config['timezone']
assert os.path.exists('/usr/share/zoneinfo/' + TZ), "Invalid timezone '%s'. See /usr/share/zoneinfo/*"%( TZ, )
with open('/etc/timezone', 'wt') as fp:
fp.write(TZ)
fp.close()
if os.path.exists('/etc/localtime'):
os.remove('/etc/localtime')
os.symlink(
'/usr/share/zoneinfo/' + TZ,
'/etc/localtime'
)
env = os.environ.copy()
env['TZ'] = TZ
subprocess.call(
[
'gunicorn',
'-b','0.0.0.0:80',
'--timeout',str(config['timeout']),
'-w',str(config['workers']),
'app:app'
],
env = env
)

View File

@@ -1,6 +1,5 @@
import os
from datetime import datetime
from dateutil.relativedelta import relativedelta
from flask import current_app as app
import requests
import re
@@ -122,12 +121,14 @@ def file_age(path):
os.stat(path).st_mtime
)
diff = now - then
rdiff = relativedelta(now, then)
return diff, "%dM %02dD %02d:%02dH" % (
rdiff.years * 12 + rdiff.months,
rdiff.days,
rdiff.hours,
rdiff.minutes
return (
diff,
"%03d d %s"%(
diff.days,
datetime.utcfromtimestamp(
diff.seconds
).strftime('%H:%M:%S')
)
)

View File

@@ -13,6 +13,7 @@
"timeout": 3600,
"uid": 1000,
"gid": -1,
"timezone": "Etc/UTC",
"max_zip_size": 1000,
"app_secret_key": "Cz2dw5NiRt3PSMFBSLTAJJi7kKrc4QU2CdQqEeOaU6",
"notifier": "",