diff --git a/selfprivacy_api/app.py b/selfprivacy_api/app.py index ffc4788..03e86a1 100644 --- a/selfprivacy_api/app.py +++ b/selfprivacy_api/app.py @@ -68,7 +68,7 @@ def create_app(test_config=None): def spec(): if app.config["ENABLE_SWAGGER"] == "1": swag = swagger(app) - swag["info"]["version"] = "1.2.2" + swag["info"]["version"] = "1.2.3" swag["info"]["title"] = "SelfPrivacy API" swag["info"]["description"] = "SelfPrivacy API" swag["securityDefinitions"] = { diff --git a/selfprivacy_api/migrations/migrate_to_selfprivacy_channel.py b/selfprivacy_api/migrations/migrate_to_selfprivacy_channel.py new file mode 100644 index 0000000..b38e256 --- /dev/null +++ b/selfprivacy_api/migrations/migrate_to_selfprivacy_channel.py @@ -0,0 +1,47 @@ +import os +import subprocess + +from selfprivacy_api.migrations.migration import Migration + + +class MigrateToSelfprivacyChannel(Migration): + def get_migration_name(self): + return "migrate_to_selfprivacy_channel" + + def get_migration_description(self): + return "Migrate to selfprivacy Nix channel." + + def is_migration_needed(self): + try: + output = subprocess.check_output( + ["nix-channel", "--list"], start_new_session=True + ) + output = output.decode("utf-8") + first_line = output.split("\n", maxsplit=1)[0] + return first_line.startswith("nixos") and ( + first_line.endswith("nixos-21.11") or first_line.endswith("nixos-21.05") + ) + except subprocess.CalledProcessError: + return False + return False + + def migrate(self): + # Change the channel and update them. + # Also, go to /etc/nixos directory and make a git pull + current_working_directory = os.getcwd() + try: + os.chdir("/etc/nixos") + subprocess.check_output( + [ + "nix-channel", + "--add", + "https://channel.selfprivacy.org/nixos-selfpricacy", + "nixos", + ] + ) + subprocess.check_output(["nix-channel", "--update"]) + subprocess.check_output(["git", "pull"]) + os.chdir(current_working_directory) + except subprocess.CalledProcessError: + os.chdir(current_working_directory) + print("Error") diff --git a/selfprivacy_api/resources/common.py b/selfprivacy_api/resources/common.py index 1517438..2955165 100644 --- a/selfprivacy_api/resources/common.py +++ b/selfprivacy_api/resources/common.py @@ -23,4 +23,4 @@ class ApiVersion(Resource): 401: description: Unauthorized """ - return {"version": "1.2.2"} + return {"version": "1.2.3"} diff --git a/setup.py b/setup.py index 2501c3b..8f9f806 100755 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="selfprivacy_api", - version="1.2.2", + version="1.2.3", packages=find_packages(), scripts=[ "selfprivacy_api/app.py",