@@ -13,33 +13,34 @@ namespace AzureWebFarm.OctopusDeploy.Infrastructure
1313{
1414 internal class OctopusDeploy
1515 {
16+ private const string InstanceArg = "--instance \" Tentacle\" " ;
1617 private readonly string _machineName ;
1718 private readonly ConfigSettings _config ;
1819 private readonly IProcessRunner _processRunner ;
1920 private readonly IOctopusRepository _repository ;
21+ private readonly string _tentaclePath ;
22+ private readonly string _tentacleInstallPath ;
2023
2124 public OctopusDeploy ( string machineName , ConfigSettings config , IOctopusRepository repository , IProcessRunner processRunner )
2225 {
2326 _machineName = machineName ;
2427 _config = config ;
2528 _processRunner = processRunner ;
2629 _repository = repository ;
30+ _tentacleInstallPath = _config . TentacleInstallPath ;
31+ _tentaclePath = Path . Combine ( _tentacleInstallPath , "Tentacle" , "Tentacle.exe" ) ;
2732 }
2833
2934 public void ConfigureTentacle ( )
3035 {
31- const string instanceArg = "--instance \" Tentacle\" " ;
3236 var tentacleDeploymentsPath = _config . TentacleDeploymentsPath ;
33- var tentacleInstallPath = _config . TentacleInstallPath ;
34- var tentacleDir = Path . Combine ( tentacleInstallPath , "Tentacle" ) ;
35- var tentaclePath = Path . Combine ( tentacleDir , "Tentacle.exe" ) ;
3637
37- _processRunner . Run ( tentaclePath , string . Format ( "create-instance {0} --config \" {1}\" --console" , instanceArg , Path . Combine ( tentacleInstallPath , "Tentacle.config" ) ) ) ;
38- _processRunner . Run ( tentaclePath , string . Format ( "new-certificate {0} --console" , instanceArg ) ) ;
39- _processRunner . Run ( tentaclePath , string . Format ( "configure {0} --home \" {1}\" --console" , instanceArg , tentacleDeploymentsPath . Substring ( 0 , tentacleDeploymentsPath . Length - 1 ) ) ) ;
40- _processRunner . Run ( tentaclePath , string . Format ( "configure {0} --app \" {1}\" --console" , instanceArg , Path . Combine ( tentacleDeploymentsPath , "Applications" ) ) ) ;
41- _processRunner . Run ( tentaclePath , string . Format ( "register-with {0} --server \" {1}\" --environment \" {2}\" --role \" {3}\" --apiKey \" {4}\" --name \" {5}\" --comms-style TentacleActive --force --console" , instanceArg , _config . OctopusServer , _config . TentacleEnvironment , _config . TentacleRole , _config . OctopusApiKey , _machineName ) ) ;
42- _processRunner . Run ( tentaclePath , string . Format ( "service {0} --install --start --console" , instanceArg ) ) ;
38+ _processRunner . Run ( _tentaclePath , string . Format ( "create-instance {0} --config \" {1}\" --console" , InstanceArg , Path . Combine ( _tentacleInstallPath , "Tentacle.config" ) ) ) ;
39+ _processRunner . Run ( _tentaclePath , string . Format ( "new-certificate {0} --console" , InstanceArg ) ) ;
40+ _processRunner . Run ( _tentaclePath , string . Format ( "configure {0} --home \" {1}\" --console" , InstanceArg , tentacleDeploymentsPath . Substring ( 0 , tentacleDeploymentsPath . Length - 1 ) ) ) ;
41+ _processRunner . Run ( _tentaclePath , string . Format ( "configure {0} --app \" {1}\" --console" , InstanceArg , Path . Combine ( tentacleDeploymentsPath , "Applications" ) ) ) ;
42+ _processRunner . Run ( _tentaclePath , string . Format ( "register-with {0} --server \" {1}\" --environment \" {2}\" --role \" {3}\" --apiKey \" {4}\" --name \" {5}\" --comms-style TentacleActive --force --console" , InstanceArg , _config . OctopusServer , _config . TentacleEnvironment , _config . TentacleRole , _config . OctopusApiKey , _machineName ) ) ;
43+ _processRunner . Run ( _tentaclePath , string . Format ( "service {0} --install --start --console" , InstanceArg ) ) ;
4344 }
4445
4546 public void DeleteMachine ( )
@@ -99,5 +100,12 @@ public static IOctopusRepository GetRepository(ConfigSettings config)
99100 {
100101 return new OctopusRepository ( new OctopusServerEndpoint ( config . OctopusServer , config . OctopusApiKey ) ) ;
101102 }
103+
104+ public void UninstallTentacle ( )
105+ {
106+ _processRunner . Run ( _tentaclePath , string . Format ( "service {0} --stop --uninstall --console" , InstanceArg ) ) ;
107+ _processRunner . Run ( _tentaclePath , string . Format ( "delete-instance {0} --console" , InstanceArg ) ) ;
108+ _processRunner . Run ( "msiexec" , string . Format ( "/uninstall \" {0}{1}\" /quiet" , _tentacleInstallPath , "Octopus.Tentacle.msi" ) ) ;
109+ }
102110 }
103111}
0 commit comments