mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Check if current user is root. Fixes #20
This commit is contained in:
parent
851389da09
commit
210d3261c0
1 changed files with 6 additions and 2 deletions
|
@ -3,8 +3,12 @@ log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
import log
|
import os
|
||||||
args = get_args()
|
args = get_args()
|
||||||
|
# Require root privileges, except when doing a dry-run where they aren't needed
|
||||||
|
if os.geteuid() != 0 and not args.dry_run:
|
||||||
|
raise Exception('This program requires root privileges.')
|
||||||
|
import log
|
||||||
logfile = log.get_logfile_path(args.manifest)
|
logfile = log.get_logfile_path(args.manifest)
|
||||||
log.setup_logger(logfile=logfile, debug=args.debug)
|
log.setup_logger(logfile=logfile, debug=args.debug)
|
||||||
run(args)
|
run(args)
|
||||||
|
@ -40,7 +44,7 @@ def run(args):
|
||||||
except (Exception, KeyboardInterrupt) as e:
|
except (Exception, KeyboardInterrupt) as e:
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
if args.pause_on_error:
|
if args.pause_on_error:
|
||||||
raw_input("Press Enter to commence rollback")
|
raw_input('Press Enter to commence rollback')
|
||||||
log.error('Rolling back')
|
log.error('Rolling back')
|
||||||
|
|
||||||
rollback_tasklist = TaskList()
|
rollback_tasklist = TaskList()
|
||||||
|
|
Loading…
Add table
Reference in a new issue