@@ -879,26 +879,36 @@ if [[ "${PROXY_TYPE}" != "${PROXY_TYPE_GOOGLE}" ]]; then
879879set -o errexit
880880set -o nounset
881881
882- # Insert a workspace link into the banner title
883- sed -i 's#<banner-title>#<banner-title>\n${WORKSPACE_LINK_EL} \> #' "${PROXY_AGENT_BANNER} "
884-
882+ # Banner modifications is idempotent to allow multiple re-runs (reboot/service restart on failure)
885883# Add target blank property to all banner links so they open in a new tab
886- sed -i 's#class="forum"#class="forum" target="_blank"#g' "${PROXY_AGENT_BANNER} "
887- sed -i 's#id="signout"#id="signout" target="_blank"#g' "${PROXY_AGENT_BANNER} "
884+ if ! grep -q 'class="forum" target="_blank"' "${PROXY_AGENT_BANNER} "; then
885+ sed -i 's#class="forum"#class="forum" target="_blank"#g' "${PROXY_AGENT_BANNER} "
886+ fi
887+ if ! grep -q 'id="signout" target="_blank"' "${PROXY_AGENT_BANNER} "; then
888+ sed -i 's#id="signout"#id="signout" target="_blank"#g' "${PROXY_AGENT_BANNER} "
889+ fi
890+
891+ # Insert a workspace link into the banner title
892+ if ! grep -q 'id="workspace"' "${PROXY_AGENT_BANNER} "; then
893+ sed -i 's#<banner-title>#<banner-title>\n${WORKSPACE_LINK_EL} \> #' "${PROXY_AGENT_BANNER} "
894+ fi
888895
889896# Remove flex styling from the banner-account css class to prevent banner content from wrapping
890897sed -i '/banner-account {/,/}/{/flex:/d;/-ms-flex:/d;/-webkit-flex:/d;}' "${PROXY_AGENT_BANNER} "
891898
892899# Add css class for a#workspace before a#project
893- sed -i '/a#project {/i\
900+ if ! grep -q 'a#workspace {' "${PROXY_AGENT_BANNER} "; then
901+ sed -i '/a#project {/i\
894902a#workspace {\
895903 color:white;\
896904 text-decoration:none;\
897905 padding:4px;\
898906}' "${PROXY_AGENT_BANNER} "
907+ fi
899908
900909# Start Docker proxy agent
901- /usr/bin/docker run \
910+ docker start "proxy-agent" 2>/dev/null \
911+ || docker run \
902912 --detach \
903913 --name "proxy-agent" \
904914 --restart=unless-stopped \
0 commit comments