simplified docker usage
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
FROM python:3.7.3-stretch
|
||||
|
||||
COPY requirements.txt /tmp/
|
||||
COPY entrypoint.sh /
|
||||
|
||||
RUN pip install -r /tmp/requirements.txt
|
||||
COPY . /tmp/infomentor
|
||||
@@ -10,5 +11,4 @@ RUN useradd --create-home appuser
|
||||
WORKDIR /home/appuser
|
||||
USER appuser
|
||||
VOLUME ["/home/appuser"]
|
||||
|
||||
CMD [ "python", "-m", "infomentor" ]
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
41
README.md
41
README.md
@@ -1,9 +1,12 @@
|
||||
# Infomentor Tool
|
||||
|
||||
This tool is designed to check the infomentor portal and send notifications using mail or pushover api.
|
||||
It is also capable of sending Calendar invitations/entries.
|
||||
|
||||
## Usage
|
||||
|
||||
You could install it locally but using the docker image is preferred.
|
||||
|
||||
```
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
@@ -13,53 +16,29 @@ infomentor
|
||||
|
||||
After the first run a `infomentor.ini` file is available which has a few values to be entered.
|
||||
|
||||
|
||||
## Docker
|
||||
|
||||
This could be run within docker. You it has a volume `/home/appuser` where all the data is stored. In favour of accessing it from a webserver you should bindmount it.
|
||||
There also the infomentor.ini should be placed.
|
||||
There also the infomentor.ini would be placed.
|
||||
|
||||
Build the container by `docker build -t infomentor:latest .` and run it like this:
|
||||
|
||||
### Notify Users / First Run
|
||||
|
||||
```
|
||||
docker run -v '/var/docker/infomentor/:/home/appuser' infomentor:latest
|
||||
```
|
||||
|
||||
for adding an user or all the commands run it adding -it to it, like:
|
||||
### Adding a user
|
||||
|
||||
```
|
||||
docker run -it -v '/var/docker/infomentor/:/home/appuser' infomentor:latest adduser
|
||||
docker run -v '/var/docker/infomentor/:/home/appuser' infomentor:latest --username <uname> --password <pwd> --pushover <pushoverid> --invitationmail <mymail>
|
||||
```
|
||||
|
||||
## Manage Users
|
||||
|
||||
|
||||
### Step 1 create a user
|
||||
|
||||
Provide the username and password for infomentor.
|
||||
```
|
||||
docker run -it -v '/var/docker/infomentor/:/home/appuser' infomentor:latest adduser --username <username>
|
||||
```
|
||||
### Step 2 add notification mechanism
|
||||
```
|
||||
docker run -it -v '/var/docker/infomentor/:/home/appuser' infomentor:latest addmail --username <username>
|
||||
```
|
||||
|
||||
or
|
||||
### See all options
|
||||
|
||||
```
|
||||
docker run -it -v '/var/docker/infomentor/:/home/appuser' infomentor:latest pushover --username <username>
|
||||
```
|
||||
|
||||
### Step 3 (optional) Add iCloud calendar
|
||||
|
||||
*NB:* This is currently not working. You could add it, but it won't work.
|
||||
|
||||
It is capable of syncing all the infomentor calendar elements to icloud calendar
|
||||
|
||||
```
|
||||
source venv/bin/activate
|
||||
addcalendar --username <username>
|
||||
docker run -v '/var/docker/infomentor/:/home/appuser' infomentor:latest --help
|
||||
```
|
||||
|
||||
## NB
|
||||
|
||||
3
entrypoint.sh
Normal file
3
entrypoint.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
infomentor $*
|
||||
@@ -34,6 +34,7 @@ def parse_args(arglist):
|
||||
parser.add_argument("--username", type=str, nargs="?", help="infomentor username")
|
||||
parser.add_argument("--password", type=str, nargs="?", help="infomentor password")
|
||||
parser.add_argument("--fake", action="store_true", help="add fake")
|
||||
parser.add_argument("--notifyerrors", action="store_true", help="add fake")
|
||||
parser.add_argument("--pushover", type=str, nargs="?", help="pushover user id")
|
||||
parser.add_argument("--mail", type=str, nargs="?", help="e-mail for notification")
|
||||
parser.add_argument(
|
||||
@@ -59,13 +60,13 @@ def perform_user_update(args):
|
||||
session.query(model.User).filter(model.User.name == username).one_or_none()
|
||||
)
|
||||
if existing_user is not None:
|
||||
print("user exists, changing pw")
|
||||
logger.info("Updating user {}", username)
|
||||
else:
|
||||
print(f"Adding user: {username}")
|
||||
logger.info("Creating User user {}", username)
|
||||
|
||||
if args.password is None:
|
||||
logger.info("No password provided, asking for it")
|
||||
import getpass
|
||||
|
||||
password = getpass.getpass(prompt="Password: ")
|
||||
else:
|
||||
password = args.password
|
||||
@@ -76,15 +77,23 @@ def perform_user_update(args):
|
||||
user = model.User(name=username, password=password)
|
||||
session.add(user)
|
||||
|
||||
if args.notifyerrors:
|
||||
user.wantstatus = True
|
||||
else:
|
||||
user.wantstatus = False
|
||||
|
||||
if args.pushover is not None:
|
||||
logger.info("Adding pushover notification")
|
||||
user.notification = model.Notification(
|
||||
ntype=model.Notification.Types.PUSHOVER, info=args.pushover
|
||||
)
|
||||
elif args.mail:
|
||||
logger.info("Adding email notification")
|
||||
user.notification = model.Notification(
|
||||
ntype=model.Notification.Types.EMAIL, info=args.mail
|
||||
)
|
||||
elif args.fake:
|
||||
logger.info("Adding fake notification")
|
||||
user.notification = model.Notification(
|
||||
ntype=model.Notification.Types.FAKE, info=""
|
||||
)
|
||||
@@ -94,6 +103,7 @@ def perform_user_update(args):
|
||||
and args.icloudpwd is not None
|
||||
and args.icloudcalendar is not None
|
||||
):
|
||||
logger.info("Adding icloud calendar")
|
||||
user.icalendar = model.ICloudCalendar(
|
||||
icloud_user=args.iclouduser,
|
||||
password=args.icloudpwd,
|
||||
@@ -101,6 +111,7 @@ def perform_user_update(args):
|
||||
)
|
||||
|
||||
if args.invitationmail:
|
||||
logger.info("Activating sending of calendar entries per mail")
|
||||
user.invitation = model.Invitation(email=mail)
|
||||
|
||||
session.commit()
|
||||
@@ -111,6 +122,7 @@ def notify_users():
|
||||
session = db.get_db()
|
||||
cfg = config.load()
|
||||
if cfg["healthchecks"]["url"] != "":
|
||||
logger.info("Triggering Healthcheck Start")
|
||||
requests.get(cfg["healthchecks"]["url"] + "/start")
|
||||
|
||||
for user in session.query(model.User):
|
||||
@@ -161,6 +173,7 @@ def notify_users():
|
||||
session.commit()
|
||||
|
||||
if cfg["healthchecks"]["url"] != "":
|
||||
logger.info("Triggering Healthcheck Stop")
|
||||
requests.get(cfg["healthchecks"]["url"])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user