This commit is contained in:
Yue Zhang 2015-06-30 17:08:43 +08:00
Родитель d8240b5457
Коммит 587da2e908
3 изменённых файлов: 16 добавлений и 7 удалений

Просмотреть файл

@ -26,7 +26,7 @@ import traceback
import threading
import subprocess
import azurelinuxagent.logger as logger
from azurelinuxagent.metadata import GuestAgentLongVersion, \
from azurelinuxagent.metadata import GuestAgentName, GuestAgentLongVersion, \
DistroName, DistroVersion, DistroFullName
from azurelinuxagent.utils.osutil import OSUtil
from azurelinuxagent.handler import Handlers
@ -56,6 +56,8 @@ def ParseArgs(sysArgv):
cmd = "daemon"
elif re.match("^([-/]*)start", a):
cmd = "start"
elif re.match("^([-/]*)register-service", a):
cmd = "register-service"
elif re.match("^([-/]*)version", a):
cmd = "version"
elif re.match("^([-/]*)verbose", a):
@ -74,8 +76,8 @@ def Version():
DistroVersion))
def Usage():
print("")
print(("usage: {0} [-verbose] [-force] "
"[-help|-deprovision[+user]|-version|-daemon|-start]"
print(("usage: {0} [-verbose] [-force] [-help]"
"-deprovision[+user]|-register-service|-version|-daemon|-start]"
"").format(sys.argv[0]))
print("")
@ -83,6 +85,12 @@ def Start():
devnull = open(os.devnull, 'w')
subprocess.Popen([sys.argv[0], '-daemon'], stdout=devnull, stderr=devnull)
def RegisterService():
print "Register {0} service".format(GuestAgentName)
OSUtil.RegisterAgentService()
print "Start {0} service".format(GuestAgentName)
OSUtil.StartAgentService()
def Main():
command, force, verbose = ParseArgs(sys.argv[1:])
if command == "version":
@ -97,5 +105,7 @@ def Main():
Deprovision(force, deluser=False)
elif command == "start":
Start()
elif command == "register-service":
RegisterService()
elif command == "daemon":
Run()

1
bin/register-service Normal file
Просмотреть файл

@ -0,0 +1 @@
waagent register-service

Просмотреть файл

@ -23,6 +23,7 @@ from azurelinuxagent.metadata import GuestAgentName, GuestAgentVersion, \
DistroName, DistroVersion, DistroFullName
from azurelinuxagent.utils.osutil import OSUtil
import azurelinuxagent.agent as agent
import setuptools
from setuptools import find_packages
from setuptools.command.install import install as _install
@ -117,10 +118,7 @@ class install(_install):
def run(self):
_install.run(self)
if self.register_service:
print "Register agent service"
OSUtil.RegisterAgentService()
print "Start agent service"
OSUtil.StartAgentService()
agent.RegisterService()
setuptools.setup(name=GuestAgentName,
version=GuestAgentVersion,