Skip to content

Instantly share code, notes, and snippets.

@peakwinter
Last active October 15, 2016 03:41
Show Gist options
  • Save peakwinter/5ecb12bd1a9c8b0b566dd9595128e084 to your computer and use it in GitHub Desktop.
Save peakwinter/5ecb12bd1a9c8b0b566dd9595128e084 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import configparser
import glob
import os
import pacman
import subprocess
import arkos
from arkos import applications
from arkos.system import services
def start():
print("=====================================")
print("arkOS 0.8 Migration Script")
print("=====================================")
print()
print("This script will help you transition to arkOS 0.8 from an existing installation of arkOS 0.7.x.")
print("It makes no warranties as to the state or accuracy of your installation after the migration, as the best way is to run a fresh install.")
print("Please press Enter to begin, or Ctrl+C to quit.")
input()
def sitedata():
print(" >>> STEP 1: Migrating your website metadata...")
for x in glob.glob('/srv/http/webapps/*/.arkos'):
cfg = configparser.RawConfigParser()
cfg.read(x)
if cfg.has_option("website", "type") and cfg.get("website", "type") == "ReverseProxy":
if cfg.has_option("website", "name"):
cfg.remove_option("website", "name")
if not cfg.has_option("website", "app"):
cfg.set("website", "app", cfg.get("website", "id"))
elif cfg.has_option("website", "type"):
if not cfg.has_option("website", "app"):
cfg.set("website", "app", cfg.get("website", "type"))
if cfg.has_option("website", "type"):
cfg.remove_option("website", "type")
with open(x, "w") as f:
cfg.write(f)
def newplugins():
print(" >>> STEP 2: Updating applications...")
for x in glob.glob("/var/lib/arkos/applications/*"):
app = applications.get(os.path.basename(x))
if app:
app.install(force=True)
if __name__ == '__main__':
start()
if not os.path.exists('/etc/arkos/settings.json') and os.path.exists('/etc/arkos/settings.json.pacsave'):
os.rename('/etc/arkos/settings.json.pacsave', '/etc/arkos/settings.json')
arkos.init()
services.get("krakend").stop()
pacman.install(["python-pip"])
sitedata()
newplugins()
code = subprocess.call(["arkosctl", "init", "redis"], env={"LANG": "en_US.UTF-8"})
if code != 0:
print("Failed to configure Redis. Please retry "
"`sudo arkosctl init redis`.")
services.get("krakend").restart()
print("Finished migration!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment