Skip to content

Commit

Permalink
Clear Salt cache and synchronize Salt before installing/uninstalling
Browse files Browse the repository at this point in the history
Towards #527
  • Loading branch information
eloquence committed Apr 9, 2020
1 parent 15e825f commit 9019bc5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts/securedrop-admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ def validate_config(path):
raise SDAdminException("Error while validating configuration")


def refresh_salt():
"""
Cleans the Salt cache and synchronizes Salt to ensure we are applying states
from the currently installed version
"""
try:
subprocess.check_call(["sudo", "rm", "-rf", "/var/cache/salt"])
except subprocess.CalledProcessError:
raise SDAdminException("Error while clearing Salt cache")

try:
subprocess.check_call(["sudo", "qubesctl", "saltutil.sync_all", "refresh=true"])
except subprocess.CalledProcessError:
raise SDAdminException("Error while synchronizing Salt")


def perform_uninstall():

try:
Expand Down Expand Up @@ -128,6 +144,7 @@ def main():
print("Applying configuration...")
validate_config(SCRIPTS_PATH)
copy_config()
refresh_salt()
provision_all()
elif args.uninstall:
print(
Expand All @@ -139,6 +156,7 @@ def main():
print("Exiting.")
sys.exit(0)
else:
refresh_salt()
perform_uninstall()
else:
sys.exit(0)
Expand Down

0 comments on commit 9019bc5

Please sign in to comment.