dotfiles/scripts/install_dotfiles.py

68 lines
1.5 KiB
Python
Raw Normal View History

2016-02-05 18:02:02 +00:00
#!/usr/bin/env python3
2016-02-07 16:39:18 +00:00
import json, os, shutil
2016-02-07 16:19:03 +00:00
2016-02-09 21:54:21 +00:00
2016-02-07 16:19:03 +00:00
DIR = os.getcwd()
2016-02-08 11:07:00 +00:00
2016-02-07 21:53:49 +00:00
def _get_json(path):
2016-02-07 19:09:53 +00:00
return json.load(open(DIR + path))
2016-02-09 21:54:21 +00:00
2016-02-08 22:27:58 +00:00
def update():
2016-02-07 16:39:18 +00:00
os.system('apt-get update -y')
2016-02-08 22:27:58 +00:00
def apt_upgrade():
2016-02-07 16:39:18 +00:00
os.system('apt-get upgrade -y')
os.system('apt-get dist-upgrade -y')
2016-02-07 22:08:48 +00:00
def apt_install_core():
2016-02-09 22:22:34 +00:00
packages = " ".join(_get_json('/apt/apt-installs-core.json'))
2016-02-09 22:20:35 +00:00
os.system("apt-get install {} -y".format(packages))
2016-02-07 16:19:03 +00:00
2016-02-07 22:08:48 +00:00
def add_apt_keys():
2016-02-07 21:53:49 +00:00
for key in _get_json('/apt/apt-keys.json'):
2016-02-07 16:39:18 +00:00
os.system("wget -O - {} | apt-key add -".format(key))
2016-02-07 16:19:03 +00:00
2016-02-07 22:08:48 +00:00
def add_apt_sources():
2016-02-07 16:19:03 +00:00
os.system('apt/add-apt-sources.sh')
2016-02-07 22:08:48 +00:00
def add_apt_repos():
2016-02-07 21:53:49 +00:00
for repo in _get_json('/apt/apt-repos.json'):
2016-02-07 16:39:18 +00:00
os.system("add-apt-repository {} -y".format(repo))
2016-02-07 16:19:03 +00:00
2016-02-07 22:08:48 +00:00
def apt_install_extras():
2016-02-09 22:22:34 +00:00
packages = " ".join(_get_json('/apt/apt-installs-extra.json'))
2016-02-09 22:20:35 +00:00
os.system("apt-get install {} -y".format(packages))
2016-02-07 16:19:03 +00:00
2016-02-07 17:13:23 +00:00
2016-02-07 22:08:48 +00:00
def run_custom_installs():
2016-02-07 17:13:23 +00:00
os.system('apt/custom-installs.sh')
2016-02-07 16:32:59 +00:00
2016-02-07 22:08:48 +00:00
def install_atom_packages():
2016-02-07 21:53:49 +00:00
packages = " ".join(_get_json('/atom/packages.json'))
2016-02-07 16:32:59 +00:00
os.system("apm install {}".format(packages))
2016-02-05 18:02:02 +00:00
2016-02-08 11:07:00 +00:00
def export_atom_config():
2016-02-09 22:20:35 +00:00
os.mkdir("~/.atom/")
2016-02-08 11:07:00 +00:00
os.system("cp -R atom/* ~/.atom/")
2016-02-07 22:08:48 +00:00
def install_configs():
2016-02-09 22:20:35 +00:00
os.mkdir("~/.config/terminator/")
2016-02-07 16:39:18 +00:00
shutil.copyfile(DIR + "/config/terminator.conf", "~/.config/terminator/config")
2016-02-08 22:33:46 +00:00
shutil.copyfile(DIR + "/bash/.bash_aliases", "~/.bashrc")
2016-02-07 16:39:18 +00:00
2016-02-07 17:13:23 +00:00
2016-02-05 18:02:02 +00:00
if __name__ == '__main__':
2016-02-07 21:53:49 +00:00
print("Please run this file using the install script, not directly.")
2016-02-05 18:02:02 +00:00
exit(1)