-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebianrepo
executable file
·48 lines (35 loc) · 1.53 KB
/
debianrepo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python3
import argparse
import json
import os
from debian_repo.logger import log
from debian_repo.repository import DebianRepository
if not os.path.exists("/usr/bin/dpkg-scanpackages"):
raise Exception("Please install dpkg-dev package.")
root_dir = os.path.dirname(os.path.realpath(__file__))
repo_dir = os.path.join(root_dir, "repo")
parser = argparse.ArgumentParser(
prog='debianrepo.py',
description='Debian repository controller')
parser.add_argument('-c', '--config', required=True, help="Configuration file")
parser.add_argument('-k', '--keyring', action='store_true', help="Just generate GPG key without running server")
parser.add_argument('-s', '--service', action='store_true', help="Just create and start a Linux service")
parser.add_argument('-r', '--remove-service', action='store_true', help="Just stop and remove Linux service")
parser.add_argument('--no-watch', default=False, action='store_true', help="Don't watch changes in pool directories")
args = parser.parse_args()
with open(args.config) as config_file:
conf = json.load(config_file)
repository = DebianRepository(config=conf, repo_dir=repo_dir, no_watch=args.no_watch)
if args.service:
if args.remove_service:
log("Don't use --remove-service and --service flags at the same time!")
exit(1)
repository.create_service(args.config)
exit(0)
if args.remove_service:
repository.remove_service()
exit(0)
if args.keyring:
repository.generate_gpg()
exit(0)
repository.start()