@@ -41,6 +41,25 @@ function showFinishedMessage {
4141 echo
4242}
4343
44+ function get_proxy_details {
45+ read -p " Enter the proxy Host (eg. http://proxyserver): " proxyurl
46+ proxyarg+=" --proxyHost=\" $proxyurl \" "
47+ read -p " Enter the proxy Port (eg. 8080): " proxyport
48+ if [ -n " $proxyport " ]; then
49+ proxyarg+=" --proxyPort=\" $proxyport \" "
50+ fi
51+ read -p " Enter the proxy Username (leave blank for none): " proxyusername
52+ if [ -n " $proxyusername " ]; then
53+ proxyarg+=" --proxyUsername=\" $proxyusername \" "
54+ read -sp " Enter the proxy Password: " proxypassword
55+ if [ -n " $proxypassword " ]; then
56+ proxyarg+=" --proxyPassword=\" $proxypassword \" "
57+ fi
58+ fi
59+
60+ echo $proxyarg
61+ }
62+
4463function setupListeningTentacle {
4564 instancename=$@
4665 logpath=" /etc/octopus"
@@ -56,6 +75,22 @@ function setupListeningTentacle {
5675 read -p " Enter the port that this Tentacle will listen on ($port ):" inputport
5776 port=$( assignNonEmptyValue " $inputport " $port )
5877
78+ read -p " Should the Tentacle use a proxy to communicate with Octopus? (y/N): " useproxy
79+ case " ${useproxy,,} " in
80+ y | yes)
81+ proxyarg=" $( get_proxy_details) "
82+ # Mask the proxy password in the display string
83+ proxyargdisplay=$( echo -n " $proxyarg " | sed ' s/proxyPassword=.*/proxyPassword=\"**********\"/' )
84+ # Added newline if password is present to improve readability
85+ if [[ $proxyargdisplay == * " proxyPassword=" * ]]; then
86+ echo
87+ fi
88+ ;;
89+ * )
90+ proxyarg=" "
91+ ;;
92+ esac
93+
5994 while [ -z " $thumbprint " ]
6095 do
6196 read -p ' Enter the thumbprint of the Octopus Server: ' thumbprint
@@ -67,6 +102,9 @@ function setupListeningTentacle {
67102 echo " sudo /opt/octopus/tentacle/Tentacle new-certificate --instance \" $instancename \" --if-blank"
68103 echo " sudo /opt/octopus/tentacle/Tentacle configure --instance \" $instancename \" --app \" $applicationpath \" --port $port --noListen False --reset-trust"
69104 echo -e " sudo /opt/octopus/tentacle/Tentacle configure --instance \" $instancename \" --trust $thumbprint "
105+ if [ -n " $proxyarg " ]; then
106+ echo -e " sudo /opt/octopus/tentacle/Tentacle proxy --instance \" $instancename \" --proxyEnable=\" true\" $proxyargdisplay "
107+ fi
70108
71109 echo -e " sudo /opt/octopus/tentacle/Tentacle service --install --start --instance \" $instancename \" ${NC} "
72110
@@ -84,6 +122,11 @@ function setupListeningTentacle {
84122 eval sudo /opt/octopus/tentacle/Tentacle configure --instance \" $instancename \" --trust $thumbprint
85123 exitIfCommandFailed
86124
125+ if [ -n " $proxyarg " ]; then
126+ eval sudo /opt/octopus/tentacle/Tentacle proxy --instance \" $instancename \" --proxyEnable=\" true\" $proxyarg
127+ exitIfCommandFailed
128+ fi
129+
87130 eval sudo /opt/octopus/tentacle/Tentacle service --install --start --instance \" $instancename \"
88131 exitIfCommandFailed
89132
@@ -195,11 +238,31 @@ function setupPollingTentacle {
195238 ;;
196239 esac
197240
241+ read -p " Should the Tentacle use a proxy to communicate with Octopus? (y/N): " useproxy
242+ case " ${useproxy,,} " in
243+ y | yes)
244+ proxyarg=" $( get_proxy_details) "
245+ # Mask the proxy password in the display string
246+ proxyargdisplay=$( echo -n " $proxyarg " | sed ' s/proxyPassword=.*/proxyPassword=\"**********\"/' )
247+ # Added newline if password is present to improve readability
248+ if [[ $proxyargdisplay == * " proxyPassword=" * ]]; then
249+ echo
250+ fi
251+ ;;
252+ * )
253+ proxyarg=" "
254+ ;;
255+ esac
256+
198257 echo -e " ${GREEN} The following configuration commands will be run to configure Tentacle:"
199258 echo -e " ${YELLOW} sudo /opt/octopus/tentacle/Tentacle create-instance --instance \" $instancename \" --config \" $logpath /$instancename /tentacle-$instancename .config\" "
200259 echo -e " sudo /opt/octopus/tentacle/Tentacle new-certificate --instance \" $instancename \" --if-blank"
201260 echo -e " sudo /opt/octopus/tentacle/Tentacle configure --instance \" $instancename \" --app \" $applicationpath \" --noListen \" True\" --reset-trust"
202261
262+ if [ -n " $proxyarg " ]; then
263+ echo -e " sudo /opt/octopus/tentacle/Tentacle polling-proxy --instance \" $instancename \" --proxyEnable=\" true\" $proxyargdisplay "
264+ fi
265+
203266 if [ $machinetype = 2 ] || [ $machinetype = " worker" ]; then
204267 echo -e " sudo /opt/octopus/tentacle/Tentacle register-worker --instance \" $instancename \" --server \" $octopusserverurl \" --name \" $displayname \" --comms-style \" TentacleActive\" $commsAddressOrPortArgs $displayauth --space \" $space \" $workerpoolsstring "
205268 else
@@ -219,12 +282,16 @@ function setupPollingTentacle {
219282 eval sudo /opt/octopus/tentacle/Tentacle configure --instance \" $instancename \" --app \" $applicationpath \" --noListen \" True\" --reset-trust
220283 exitIfCommandFailed
221284
285+ if [ -n " $proxyarg " ]; then
286+ eval sudo /opt/octopus/tentacle/Tentacle polling-proxy --instance \" $instancename \" --proxyEnable=\" true\" $proxyarg
287+ exitIfCommandFailed
288+ fi
289+
222290 if [ $machinetype = 2 ] || [ $machinetype = " worker" ]; then
223291 eval sudo /opt/octopus/tentacle/Tentacle register-worker --instance \" $instancename \" --server \" $octopusserverurl \" --name \" $displayname \" --comms-style \" TentacleActive\" $commsAddressOrPortArgs $auth --space \" $space \" $workerpoolsstring
224292 else
225293 eval sudo /opt/octopus/tentacle/Tentacle register-with --instance \" $instancename \" --server \" $octopusserverurl \" --name \" $displayname \" --comms-style \" TentacleActive\" $commsAddressOrPortArgs $auth --space \" $space \" $envstring $rolesstring
226294 fi
227-
228295 exitIfCommandFailed
229296
230297 eval sudo /opt/octopus/tentacle/Tentacle service --install --start --instance \" $instancename \"
0 commit comments