Skip to content

Instantly share code, notes, and snippets.

@peakwinter
Last active April 4, 2016 21:47
Show Gist options
  • Save peakwinter/bc342cdeb85ee640afd5 to your computer and use it in GitHub Desktop.
Save peakwinter/bc342cdeb85ee640afd5 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("https://pkg.arkos.io/resources/arkos-mirrorlist-latest.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", "a") as f:
f.write("\n[arkos]\nInclude = /etc/pacman.d/arkos-mirrorlist")
subprocess.call(["pacman", "-Sy"])
# Install new requirements
required = ["avahi", "redis", "openldap", "nodejs", "npm", "ntp", "arkos-openldap",
"git", "arkos-keyring", "arkos-cli", "nginx", "cronie", "python2-aniso8601",
"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"])
# Configure nginx
if not os.path.exists("/srv/http/webapps"):
os.makedirs("/srv/http/webapps")
if not os.path.exists("/etc/nginx/sites-available"):
os.makedirs("/etc/nginx/sites-available")
if not os.path.exists("/etc/nginx/sites-enabled"):
os.makedirs("/etc/nginx/sites-enabled")
ngxdata = urllib2.urlopen("https://gist.githubusercontent.com/peakwinter/8e9a3a1cf55745ad5b93c5282f3a92ff/raw/35a476562f703f059d41dfc81d1016d348a6da2b/nginx.conf")
with open("/etc/nginx/nginx.conf", "w") as f:
f.write(ngxdata.read())
if __name__ == '__main__':
subprocess.call(["systemctl", "stop", "mysqld", "genesis"])
install()
subprocess.call(["systemctl", "enable", "avahi-daemon", "ntpd", "cronie", "arkos-redis", "krakend", "slapd", "nginx"])
print "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment