Skip to content

Commit 9a058a4

Browse files
committed
Refactoring
1) remove useless yum installations 2) use the zip package from git-hub and fix teh unzip command accordingly
1 parent a319494 commit 9a058a4

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

grafana-post-install.sh

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#source the AWS ParallelCluster profile
1010
. /etc/parallelcluster/cfnconfig
1111

12-
yum -y install docker glibc-static
12+
yum -y install docker
1313
service docker start
1414
chkconfig docker on
1515
usermod -a -G docker $cfn_cluster_user
@@ -22,11 +22,6 @@ chmod +x /usr/local/bin/docker-compose
2222
case "${cfn_node_type}" in
2323
MasterServer)
2424

25-
# Install docker to simplify Prometheus & Grafana deployment
26-
yum -y install git golang-bin make
27-
28-
wget "${2}"
29-
3025
#Unsupported
3126
#cfn_efs=$(cat /etc/chef/dna.json | grep \"cfn_efs\" | awk '{print $2}' | sed "s/\",//g;s/\"//g")
3227
#cfn_cluster_cw_logging_enabled=$(cat /etc/chef/dna.json | grep \"cfn_cluster_cw_logging_enabled\" | awk '{print $2}' | sed "s/\",//g;s/\"//g")
@@ -37,20 +32,22 @@ master_instance_id=$(ec2-metadata -i | awk '{print $2}')
3732
cfn_max_queue_size=$(aws cloudformation describe-stacks --stack-name $stack_name --region $cfn_region | jq -r '.Stacks[0].Parameters | map(select(.ParameterKey == "MaxSize"))[0].ParameterValue')
3833
s3_bucket=$(echo $cfn_postinstall | sed "s/s3:\/\///g;s/\/.*//")
3934

40-
yum -y install git golang-bin make
35+
yum -y install golang-bin
36+
37+
filename=$(wget -nv "${2}" 2>&1 |cut -d\" -f2)
38+
packagename=$(basename "${filename}" ".zip")
4139

42-
wget "${2}"
43-
unzip main.zip ../Grafana/grafana/*
44-
unzip main.zip ../Grafana/nginx/*
45-
unzip main.zip ../Grafana/www/*
46-
unzip main.zip ../Grafana/docker-compose/*
47-
unzip main.zip ../Grafana/prometheus/*
48-
mv Grafana/* /home/$cfn_cluster_user/
40+
unzip "${filename}" "${packagename}/grafana/*"
41+
unzip "${filename}" "${packagename}/nginx/*"
42+
unzip "${filename}" "${packagename}/www/*"
43+
unzip "${filename}" "${packagename}/docker-compose/*"
44+
unzip "${filename}" "${packagename}/prometheus/*"
45+
mv -f ${packagename}/* "/home/${cfn_cluster_user}/"
4946

50-
unzip -j main.zip ../Grafana/custom-metrics/1h-cost-metrics.sh -d /usr/local/bin/
51-
unzip -j main.zip ../Grafana/custom-metrics/1m-cost-metrics.sh -d /usr/local/bin/
52-
unzip -j main.zip ../Grafana/custom-metrics/aws-region.py -d /usr/local/bin/
53-
unzip -j main.zip ../Grafana/prometheus-slurm-exporter/slurm_exporter.service -d /etc/systemd/system/
47+
unzip -j "${filename}" "${packagename}/custom-metrics/1h-cost-metrics.sh" -d /usr/local/bin/
48+
unzip -j "${filename}" "${packagename}/custom-metrics/1m-cost-metrics.sh" -d /usr/local/bin/
49+
unzip -j "${filename}" "${packagename}/custom-metrics/aws-region.py" -d /usr/local/bin/
50+
unzip -j "${filename}" "${packagename}/prometheus-slurm-exporter/slurm_exporter.service" -d /etc/systemd/system/
5451

5552
chmod +x /usr/local/bin/1h-cost-metrics.sh
5653
chmod +x /usr/local/bin/1m-cost-metrics.sh
@@ -107,7 +104,7 @@ systemctl start slurm_exporter
107104
;;
108105
ComputeFleet)
109106

110-
docker-compose --env-file /etc/parallelcluster/cfnconfig -f /home/$cfn_cluster_user/docker-compose/docker-compose.compute.yml -p grafana-compute up -d
107+
docker-compose -f /home/$cfn_cluster_user/docker-compose/docker-compose.compute.yml -p grafana-compute up -d
111108

112109
;;
113-
esac
110+
esac

0 commit comments

Comments
 (0)