insert to existing conf
This commit is contained in:
18
README.md
Normal file
18
README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# FLEES
|
||||
|
||||
a very small file sharing website
|
||||
|
||||
- configure with data/shares.json
|
||||
- configure with data/config.json
|
||||
- generate shares with utils/create-share.py
|
||||
- proxy with nginx:
|
||||
```
|
||||
location /flees/ {
|
||||
proxy_pass http://localhost:8136/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
proxy_set_header X-Script-Name /flees;
|
||||
client_max_body_size 8G;
|
||||
}
|
||||
```
|
||||
@@ -1,19 +1,17 @@
|
||||
[
|
||||
{
|
||||
{
|
||||
"name": "test",
|
||||
"pass_hash": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
|
||||
"pass_plain": "password",
|
||||
"path": "files",
|
||||
"pass_hash": "86d2db203591135ea63473e49759a1d2e43fdc4d9857aeee642713c4e837be12",
|
||||
"pass_plain": "tissit",
|
||||
"upload": true,
|
||||
"public": false,
|
||||
"expire": "2018-02-28 10:30"
|
||||
},
|
||||
{
|
||||
"name": "foo",
|
||||
"path": "foo",
|
||||
"pass_hash": "86d2db203591135ea63473e49759a1d2e43fdc4d9857aeee642713c4e837be12",
|
||||
"pass_plain": "tissit",
|
||||
"upload": false,
|
||||
"public": true
|
||||
}
|
||||
"upload": true
|
||||
},
|
||||
{
|
||||
"expire": "2018-12-24 18:00",
|
||||
"name": "test2",
|
||||
"path": "files",
|
||||
"public": false,
|
||||
"upload": false
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
import hashlib,argparse,json,sys
|
||||
from datetime import datetime
|
||||
from shutil import copyfile
|
||||
|
||||
parser = argparse.ArgumentParser(description='Flees share template generator')
|
||||
|
||||
parser.add_argument('-n','--name', action="store", dest="name", required = True)
|
||||
@@ -10,6 +12,10 @@ parser.add_argument('-u','--upload', action="store_true", dest="upload", default
|
||||
parser.add_argument('--pass-plain', action="store", dest="plain", default = False)
|
||||
parser.add_argument('--pass-hashed', action="store", dest="hashed", default = False)
|
||||
parser.add_argument('-e','--expire', action="store", dest="expire", default = False, help = "expire date in format 2018-12-24 21:00")
|
||||
parser.add_argument('-s','--shares', action="store", dest="shares", default = False,
|
||||
help = "Your current shares.json file")
|
||||
parser.add_argument('-i','--insert', action="store_true", dest="insert", default = False,
|
||||
help = "If 'shares' defined, insert new share directly in the shares.json file")
|
||||
|
||||
opts = parser.parse_args()
|
||||
|
||||
@@ -37,7 +43,18 @@ if opts.expire:
|
||||
'expire': opts.expire
|
||||
})
|
||||
|
||||
|
||||
print(json.dumps(share, indent = 2))
|
||||
if opts.shares:
|
||||
shares = json.load(open(opts.shares,'rt'))
|
||||
shares.append(share)
|
||||
if opts.insert:
|
||||
print("creating backup %s"%(opts.shares+".bkp",))
|
||||
copyfile(opts.shares,opts.shares+".bkp")
|
||||
with open(opts.shares,'wt') as fp:
|
||||
json.dump(shares, fp, indent = 2, sort_keys = True)
|
||||
print("Wrote file %s"%(opts.shares,))
|
||||
else:
|
||||
print(json.dumps(shares, indent = 2, sort_keys = True))
|
||||
else:
|
||||
print(json.dumps(share, indent = 2, sort_keys = True))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user