forked from bestwpw/pmbootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmbootstrap.py
executable file
·69 lines (54 loc) · 2.02 KB
/
pmbootstrap.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
"""
Copyright 2017 Oliver Smith
This file is part of pmbootstrap.
pmbootstrap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
pmbootstrap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
import logging
import os
import traceback
import pmb.config
import pmb.helpers.frontend
import pmb.helpers.logging
import pmb.helpers.other
import pmb.parse
def main():
# Parse arguments, set up logging
args = pmb.parse.arguments()
pmb.helpers.logging.init(args)
# Wrap everything to display nice error messages
try:
# Sanity check
pmb.helpers.other.check_grsec(args)
# Initialize or require config
if args.action == "init":
return pmb.config.init(args)
elif not os.path.exists(args.config):
logging.critical("Please specify a config file, or run"
" 'pmbootstrap init' to generate one.")
return 1
# Run the function with the action's name (in pmb/helpers/frontend.py)
if args.action:
getattr(pmb.helpers.frontend, args.action)(args)
else:
logging.info("Run pmbootstrap -h for usage information.")
# Print finish timestamp
logging.info("Done")
except Exception as e:
logging.info("ERROR: " + str(e))
logging.info("Run 'pmbootstrap log' for details.")
logging.info("See also: <https://postmarketos.org/troubleshooting>")
logging.debug(traceback.format_exc())
return 1
if __name__ == "__main__":
sys.exit(main())