Skip to content

Instantly share code, notes, and snippets.

@peakwinter
Last active October 18, 2015 01:19
Show Gist options
  • Save peakwinter/16c68922f5c2a3206e08 to your computer and use it in GitHub Desktop.
Save peakwinter/16c68922f5c2a3206e08 to your computer and use it in GitHub Desktop.
import os
import re
import subprocess
import sys
import urllib2
def install():
print "Installing new packages..."
# Install new mirrorlist
data = urllib2.urlopen("http://us.mirror.archlinuxarm.org/armv7h/core/pacman-mirrorlist-20150915-1-any.pkg.tar.xz")
with open("/tmp/alarm-mirrorlist.pkg.tar.xz", "wb") as f:
f.write(data.read())
with open("/etc/pacman.d/mirrorlist", "w") as f:
f.write("Server = http://us.mirror.archlinuxarm.org/$arch/$repo")
code = subprocess.call(["pacman", "-U", "/tmp/alarm-mirrorlist.pkg.tar.xz", "--noconfirm", "--force"])
if code != 0:
print "Failed to install ALARM mirrorlist. Please retry."
sys.exit(1)
if os.path.exists("/etc/pacman.d/mirrorlist.pacnew"):
os.unlink("/etc/pacman.d/mirrorlist")
os.rename("/etc/pacman.d/mirrorlist.pacnew", "/etc/pacman.d/mirrorlist")
data = urllib2.urlopen("https://nyus.mirror.arkos.io/x86_64/arkos/arkos-mirrorlist-20150413-1-any.pkg.tar.xz")
with open("/tmp/arkos-mirrorlist.pkg.tar.xz", "wb") as f:
f.write(data.read())
code = subprocess.call(["pacman", "-U", "/tmp/arkos-mirrorlist.pkg.tar.xz", "--noconfirm"])
if code != 0:
print "Failed to install arkOS mirrorlist. Please retry."
sys.exit(1)
with open("/etc/pacman.conf", "r") as f:
pdata = f.read()
if re.search("\[arkos\]\nInclude \= \/etc\/pacman\.d\/mirrorlist", pdata):
with open("/etc/pacman.conf", "w") as f:
f.write(pdata.replace("[arkos]\nInclude = /etc/pacman.d/mirrorlist",
"[arkos]\nInclude = /etc/pacman.d/arkos-mirrorlist"))
elif not re.search("\[arkos\]", pdata):
with open("/etc/pacman.conf", "w") as f:
f.write(pdata)
f.write("\n[arkos]\nInclude = /etc/pacman.d/arkos-mirrorlist")
subprocess.call(["pacman", "-Sy"])
# Install new requirements
required = ["avahi", "redis", "openldap", "nodejs", "npm", "arkos-openldap", "arkos-keyring",
"arkos-core", "arkos-kraken", "arkos-genesis", "arkos-redis", "python2-pacman"]
code = subprocess.call(["pacman", "-Su", "--noconfirm"])
if code != 0:
print "Failed to update system packages. Please retry."
sys.exit(1)
subprocess.call(["pacman-db-upgrade"])
code = subprocess.call(["pacman", "-Sy"] + required + ["--noconfirm"])
if code != 0:
print "Failed to install new requirements. Please retry."
sys.exit(1)
subprocess.call(["pacman-key", "--init"])
subprocess.call(["pacman-key", "--populate", "arkos"])
if __name__ == '__main__':
subprocess.call(["systemctl", "stop", "mysqld", "genesis"])
install()
subprocess.call(["systemctl", "enable", "avahi-daemon", "ntpd", "cronie", "arkos-redis", "krakend", "slapd"])
print "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment