Skip to content

Commit 3e0e629

Browse files
authored
Merge pull request #1377 from utmstack/backlog/add-utmstack-integration
Backlog/add utmstack integration
2 parents 82e8dbd + 27b7cb4 commit 3e0e629

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

frontend/src/app/app-module/guides/guide-utmstack/guide-utmstack.component.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class GuideUtmstackComponent implements OnInit {
3636
ngOnInit(): void {
3737
this.ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host;
3838
this.getToken();
39+
this.loadArchitectures();
3940
}
4041

4142
getToken() {
@@ -59,4 +60,50 @@ export class GuideUtmstackComponent implements OnInit {
5960
onDisable() {
6061
this.disablePreAction = true;
6162
}
63+
64+
private loadArchitectures() {
65+
this.architectures = [
66+
{
67+
id: 1, name: 'Ubuntu 16/18/20+',
68+
install: this.getCommandUbuntu('utmstack_agent_service'),
69+
uninstall: this.getUninstallCommand('utmstack_agent_service'),
70+
shell: ''
71+
},
72+
{
73+
id: 2, name: 'Centos 7/Red Hat Enterprise Linux',
74+
install: this.getCommandCentos7RedHat('utmstack_agent_service'),
75+
uninstall: this.getUninstallCommand('utmstack_agent_service'),
76+
shell: ''
77+
},
78+
];
79+
}
80+
81+
getCommandUbuntu(installerName: string): string {
82+
const ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host;
83+
84+
return `sudo bash -c "apt update -y && apt install wget -y && mkdir -p /opt/utmstack-collector && \
85+
wget --no-check-certificate -P /opt/utmstack-collector \
86+
https://${ip}:9001/private/dependencies/collector/${installerName} && \
87+
chmod -R 777 /opt/utmstack-collector/${installerName} && \
88+
/opt/utmstack-collector/${installerName} install ${ip} <secret>${this.token}</secret> yes"`;
89+
}
90+
91+
getCommandCentos7RedHat(installerName: string): string {
92+
const ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host;
93+
94+
return `sudo bash -c "yum install wget -y && mkdir -p /opt/utmstack-collector && \
95+
wget --no-check-certificate -P /opt/utmstack-collector \
96+
https://${ip}:9001/private/dependencies/collector/${installerName} && \
97+
chmod -R 777 /opt/utmstack-collector/${installerName} && \
98+
/opt/utmstack-collector/${installerName} install ${ip} <secret>${this.token}</secret> yes"`;
99+
}
100+
101+
getUninstallCommand(installerName: string): string {
102+
return `sudo bash -c "/opt/utmstack-collector/${installerName} uninstall || true; \
103+
systemctl stop UTMStackCollector 2>/dev/null || true; systemctl disable UTMStackCollector 2>/dev/null || true; \
104+
rm -f /etc/systemd/system/UTMStackCollector.service 2>/dev/null || true; \
105+
systemctl daemon-reload 2>/dev/null || true; \
106+
echo 'Removing UTMStack Collector dependencies...' && sleep 10 && rm -rf /opt/utmstack-collector 2>/dev/null || true; \
107+
echo 'UTMStack Collector dependencies removed successfully.'"`;
108+
}
62109
}

0 commit comments

Comments
 (0)