Skip to content

Commit

Permalink
update install
Browse files Browse the repository at this point in the history
  • Loading branch information
yomguy committed Jan 22, 2016
1 parent efa9ae7 commit 1fe6f4c
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions install.py
Expand Up @@ -100,7 +100,7 @@
"""


class DockerComposeDaemonInstall(object):
class DockerCompositionInstaller(object):

docker = '/etc/init.d/docker'
docker_compose = '/usr/local/bin/docker-compose'
Expand All @@ -116,8 +116,8 @@ def get_root(self):
path = self.path
while not self.config in os.listdir(path):
path = os.sep.join(path.split(os.sep)[:-1])
if not path:
raise ValueError('The YAML docker composition was not found, please type "install.py -h" for more infos.')
if not path:
raise ValueError('The YAML docker composition was not found, please type "install.py -h" for more infos.')
return path

def install_docker(self):
Expand Down Expand Up @@ -149,7 +149,7 @@ def install_daemon_systemd(self):
os.system('systemctl enable ' + service)
os.system('systemctl daemon-reload')

def run(self):
def install(self):
print 'Installing ' + self.name + ' composition as a daemon...'
self.install_docker()
if self.init_type == 'sysvinit':
Expand All @@ -169,7 +169,7 @@ def uninstall_daemon_systemd(self):
os.system('systemctl daemon-reload')
os.system('rm ' + service)

def un(self):
def uninstall(self):
print 'Uninstalling ' + self.name + ' composition as a daemon...'
if self.init_type == 'sysvinit':
self.uninstall_daemon_sysvinit()
Expand All @@ -179,27 +179,26 @@ def un(self):


def main():
description ="""Install a docker composition as a daemon with boot init (SysVinit by default)."""
description ="""Install this docker composition program as a daemon with boot init (sysvinit by default)."""
parser = argparse.ArgumentParser(description=description)
parser.add_argument('--uninstall', help='uninstall the daemon', action='store_true')
parser.add_argument('--systemd', help='use systemd', action='store_true')
parser.add_argument('config_file', nargs='?', help='the path of the YAML composition to install')
parser.add_argument('composition_file', nargs='?', help='the path of the YAML composition file to use (optional)')

config = 'docker-compose.yml'
init_type = 'sysvinit'
args = vars(parser.parse_args())

if args['systemd']:
init_type = 'systemd'
if args['config_file']:
config = args['config_file']
if args['composition_file']:
config = args['composition_file']

print init_type, config
install = DockerComposeDaemonInstall(config, init_type)
installer = DockerCompositionInstaller(config, init_type)
if args['uninstall']:
install.un()
installer.uninstall()
else:
install.run()
installer.install()

if __name__ == '__main__':
if not 'Linux' in platform.system():
Expand Down

0 comments on commit 1fe6f4c

Please sign in to comment.