Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jacotsu
uus
Commits
97c8491b
Commit
97c8491b
authored
Feb 25, 2019
by
JackV
Browse files
Revert uus management split
This reverts commit
805d4729
.
parent
d2ab8626
Changes
3
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
97c8491b
...
...
@@ -9,7 +9,8 @@ RUN apk add -U python3 py3-gunicorn && \
ENV
FLASK_APP=uus
COPY
uus_mng /
COPY
uus.py /uus
COPY
admin /uus/admin
EXPOSE
8000
...
...
README.md
View file @
97c8491b
...
...
@@ -8,9 +8,9 @@ Also, `FLASK_APP=uus` must be set when not running in Docker (the Dockerfile alr
Run
`flask`
to get the list of commands.
In the docker container you can run
`uus
_mng
`
directly to get to the CLI, for example
In the docker container you can run
`uus`
directly to get to the CLI, for example
```
$ docker exec -it uus_uus_1
/
uus
_mng
adduser admin
$ docker exec -it uus_uus_1 uus adduser admin
Password:
```
```
\ No newline at end of file
uus
_mng
→
uus
/management_cli.py
100755 → 100644
View file @
97c8491b
#!/usr/bin/env python3
import
crypt
import
click
import
redis
import
os
redis_store
=
None
default_redis_url
=
os
.
environ
.
get
(
'REDIS_URL'
,
'redis://127.0.0.1:6379/0'
)
import
click
@
click
.
group
()
@
click
.
option
(
"--redisurl"
,
"-u"
,
help
=
"Redis DB url"
,
default
=
default_redis_url
)
def
cli
(
redisurl
):
global
redis_store
redis_store
=
redis
.
from_url
(
redisurl
)
from
.
import
app
,
redis_store
,
redis_key_for_user
@
cli
.
command
()
@
app
.
cli
.
command
()
@
click
.
argument
(
"username"
)
@
click
.
option
(
"--passwd"
,
"-p"
,
prompt
=
"Password"
,
help
=
"Password"
,
hide_input
=
True
)
def
adduser
(
username
,
passwd
):
"""Add UUS admin user"""
cryptpwd
=
crypt
.
crypt
(
passwd
)
redis_store
.
set
(
'usr.'
+
username
,
cryptpwd
)
redis_store
.
set
(
redis_key_for_user
(
username
)
,
cryptpwd
)
@
cli
.
command
()
@
app
.
cli
.
command
()
@
click
.
argument
(
"username"
)
@
click
.
option
(
"--passwd"
,
"-p"
,
prompt
=
"Password"
,
help
=
"Password"
,
hide_input
=
True
)
def
passwd
(
username
,
passwd
):
...
...
@@ -32,12 +22,8 @@ def passwd(username, passwd):
adduser
(
username
,
passwd
)
@
cli
.
command
()
@
app
.
cli
.
command
()
@
click
.
argument
(
"username"
)
def
deluser
(
username
):
"""Delete UUS admin user"""
redis_store
.
delete
(
'usr.'
+
username
)
if
__name__
==
'__main__'
:
cli
()
redis_store
.
delete
(
redis_key_for_user
(
username
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment