Skip to content
fabfile.py 1.36 KiB
Newer Older
#!/usr/bin/env python
# coding=utf-8

"""
fabric file for server automation.

Usage:

fab deploy
  //deploy debug build to s01 VM.
BUILDDIR=release fab deploy
  //deploy release build to s01 VM.
HOST=ryzen5root fab deploy
  //deploy debug build to ryzen5
HOST=ryzen5root BUILDDIR=release fab deploy
  //deploy release build to ryzen5

"""
# pylint: disable=line-too-long

import warnings
import os
from fabric.api import env, sudo, run, local, hosts, put, cd

env.use_ssh_config = True
TEST_HOST = os.getenv("HOST", "s01root")
DIR = os.getenv("BUILDDIR", "build")


@hosts(TEST_HOST)
def deploy():
    local("ninja -C %s" % (DIR,))
    run("mkdir -p /usr/share/zero-panel/")
    put("zero-panel/zero-panel.ui", "/usr/share/zero-panel/zero-panel.ui")
    put("zero-panel/zero-panel.css", "/usr/share/zero-panel/zero-panel.css")
    run("pkill zero-panel || true")
    put("%s/zero-panel" % (DIR,), "/home/sylecn/d/zero-panel")
    run("chown sylecn:sylecn /home/sylecn/d/zero-panel")
    run("chmod +x /home/sylecn/d/zero-panel")
    put("zero-panel/com.emacsos.zero.Panel1.service",
        "/usr/share/dbus-1/services/")
    run("mkdir -p /usr/share/dbus-1/interfaces/")
    put("zero-panel/com.emacsos.zero.Panel1.PanelInterface.xml",
        "/usr/share/dbus-1/interfaces/")
    run("systemctl reload dbus")


# module init
warnings.filterwarnings(action='ignore',module='.*paramiko.*')