mirror of
https://github.com/isjerryxiao/pacroller.git
synced 2024-11-23 00:00:44 +08:00
add root check
This commit is contained in:
parent
57e96c2650
commit
7083d4b41b
1 changed files with 5 additions and 1 deletions
|
@ -5,7 +5,7 @@ import subprocess
|
||||||
import logging
|
import logging
|
||||||
from re import match
|
from re import match
|
||||||
import json
|
import json
|
||||||
from os import environ
|
from os import environ, getuid
|
||||||
import traceback
|
import traceback
|
||||||
import pyalpm
|
import pyalpm
|
||||||
import pycman
|
import pycman
|
||||||
|
@ -169,6 +169,8 @@ def main() -> None:
|
||||||
logging.basicConfig(level=logging.INFO, format='%(levelname)s - %(message)s')
|
logging.basicConfig(level=logging.INFO, format='%(levelname)s - %(message)s')
|
||||||
|
|
||||||
if args.action == 'run':
|
if args.action == 'run':
|
||||||
|
if getuid() != 0:
|
||||||
|
parser.error('you need to be root')
|
||||||
if prev_err := has_previous_error():
|
if prev_err := has_previous_error():
|
||||||
logger.error(f'Cannot continue, a previous error {prev_err} is still present. Please resolve this issue and run fail-reset.')
|
logger.error(f'Cannot continue, a previous error {prev_err} is still present. Please resolve this issue and run fail-reset.')
|
||||||
else:
|
else:
|
||||||
|
@ -199,6 +201,8 @@ def main() -> None:
|
||||||
break
|
break
|
||||||
print()
|
print()
|
||||||
elif args.action == 'fail-reset':
|
elif args.action == 'fail-reset':
|
||||||
|
if getuid() != 0:
|
||||||
|
parser.error('you need to be root')
|
||||||
if prev_err := has_previous_error():
|
if prev_err := has_previous_error():
|
||||||
write_db(None)
|
write_db(None)
|
||||||
logger.info(f'reset previous error {prev_err}')
|
logger.info(f'reset previous error {prev_err}')
|
||||||
|
|
Loading…
Reference in a new issue