Last active
June 20, 2018 11:14
-
-
Save norbertparti/9024d2541af2d690cd386569c885e1b3 to your computer and use it in GitHub Desktop.
Dev environment provision script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import shutil | |
packages = [ | |
'chromium', | |
'git', | |
'mc', | |
'ntp', | |
'pacaur', | |
'snapd', | |
'vim', | |
'zsh' | |
] | |
def run(command): | |
subprocess.run(command, check=True, shell=True) | |
def pacman(*args): | |
def install(function): | |
install_packages = ''.join(args) | |
if install_packages: | |
run(f'sudo pacman -Sy {install_packages}') | |
def wrapper(*args, **kwargs): | |
function(*args, **kwargs) | |
return wrapper | |
return install | |
def pacaur(*args): | |
def install(function): | |
install_packages = ''.join(args) | |
if install_packages: | |
run(f'sudo pacaur -Sy {install_packages}') | |
def wrapper(*args, **kwargs): | |
function(*args, **kwargs) | |
return wrapper | |
return install | |
def copy_rsa(rsa_path='./id_rsa.pub'): | |
# relative path | |
shutil.copy2(rsa_path, '.ssh') | |
def copy_gitconfig(git_config_path='./gitconfig'): | |
# relative path | |
shutil.copy2(git_config_path, '~') | |
def install_virtealenv(): | |
run('sudo pip install virtualenv tox') | |
@pacaur('atom-editor') | |
def setup_atom_python(): | |
run('sudo pip install python-language-server[all]') | |
run('apm install atom-ide-ui') | |
run('apm install ide-python') | |
@pacman('docker') | |
def setup_docker(): | |
docker_setup_commands = [ | |
'sudo systemctl start docker', | |
'sudo systemctl enable docker', | |
'sudo groupadd docker', | |
'sudo usermod -aG docker $USER' | |
] | |
for command in docker_setup_commands: | |
run(command) | |
def setup_oh_my_zsh(): | |
run('sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"') | |
def setup_snapd(): | |
run('sudo systemctl enable --now snapd.socket') | |
def setup_ntp(timezone='Europe/Budapest'): | |
run(f'sudo timedatectl set-timezone {timezone}') | |
run('sudo timedatectl set-ntp true') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment