mirror of
https://github.com/Derisis13/barusu.git
synced 2025-12-06 19:42:48 +01:00
Script checks for root if run in restore mode. This might help with using it correctly
This commit is contained in:
35
main.py
35
main.py
@@ -32,23 +32,26 @@ def save_settings():
|
|||||||
|
|
||||||
def restore():
|
def restore():
|
||||||
global packagelist, config
|
global packagelist, config
|
||||||
try:
|
if os.getuid() == 0:
|
||||||
os.chdir(backupdir)
|
try:
|
||||||
except FileNotFoundError:
|
os.chdir(backupdir)
|
||||||
print("Backup directory not found! Does it really exist? Please check for correct order of arguments: "
|
except FileNotFoundError:
|
||||||
"-d/--backup-dir -r/--restore!")
|
print("Backup directory not found! Does it really exist? Please check for correct order of arguments: "
|
||||||
exit(2)
|
"-d/--backup-dir -r/--restore!")
|
||||||
try:
|
exit(2)
|
||||||
packagelist = open("packages.txt", "r")
|
try:
|
||||||
except FileNotFoundError:
|
packagelist = open("packages.txt", "r")
|
||||||
print("No packages.txt in your backup directory! Did you specify the right directory? Please check for "
|
except FileNotFoundError:
|
||||||
"correct order of arguments: first -d/--backup-dir then -r/--restore!")
|
print("No packages.txt in your backup directory! Did you specify the right directory? Please check for "
|
||||||
packagelist.close()
|
"correct order of arguments: first -d/--backup-dir then -r/--restore!")
|
||||||
exit(2)
|
packagelist.close()
|
||||||
|
exit(2)
|
||||||
|
else:
|
||||||
|
subprocess.call(["dpkg", "--set-selections"], stdin=packagelist)
|
||||||
|
subprocess.call(["apt-get", "dselect-upgrade"])
|
||||||
|
packagelist.close()
|
||||||
else:
|
else:
|
||||||
subprocess.call(["dpkg", "--set-selections"], stdin=packagelist)
|
print("You're not root! You can't restore packages unless you are root!")
|
||||||
subprocess.call(["apt-get", "dselect-upgrade"])
|
|
||||||
packagelist.close()
|
|
||||||
try:
|
try:
|
||||||
config = open("dconf_out.txt", "r")
|
config = open("dconf_out.txt", "r")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
|||||||
Reference in New Issue
Block a user