File tree Expand file tree Collapse file tree 4 files changed +30
-16
lines changed
Expand file tree Collapse file tree 4 files changed +30
-16
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ install:
6363 -mkdir -p /etc/containers/systemd/piccolo/etcd-data/
6464 -cp -r ./src/settings.yaml /etc/containers/systemd/piccolo/
6565 -cp -r ./containers/piccolo-* .* /etc/containers/systemd/piccolo/
66+ -cp -r ./scripts/update_server_ip.sh /etc/containers/systemd/piccolo/
67+
6668 systemctl daemon-reload
6769 systemctl start piccolo-server
6870 systemctl start piccolo-player
Original file line number Diff line number Diff line change @@ -8,9 +8,8 @@ WantedBy=multi-user.target default.target
88
99[Kube]
1010Yaml=/etc/containers/systemd/piccolo/piccolo-server.yaml
11- # settings.yaml에서 호스트 IP를 추출하여 환경 변수로 설정
12- PodmanArgs=--env HOST_IP=$(grep -A 3 "host:" /etc/containers/systemd/piccolo/settings.yaml | grep "ip:" | awk '{print $2}')
1311
1412[Service]
1513Restart=always
16- ExecStartPre=/bin/bash -c 'if ! ip=$(grep -A 3 "host:" /etc/containers/systemd/piccolo/settings.yaml | grep "ip:" | awk "{print \\$2}"); then echo "Failed to extract host IP from settings.yaml"; exit 1; fi'
14+ # settings.yaml에서 IP를 읽어서 yaml 파일을 동적으로 수정하는 스크립트 실행
15+ ExecStartPre=/etc/containers/systemd/piccolo/update_server_ip.sh
Original file line number Diff line number Diff line change @@ -14,20 +14,11 @@ spec:
1414 containers :
1515 - name : etcd
1616 image : gcr.io/etcd-development/etcd:v3.5.11
17- command : ["/bin/sh "]
17+ command : ["/usr/local/ bin/etcd "]
1818 args :
19- - " -c"
20- - |
21- # HOST_IP 환경변수가 있으면 사용, 없으면 기본값 사용
22- if [ -z "$HOST_IP" ]; then
23- echo "Warning: HOST_IP environment variable not set. Using 127.0.0.1 as default."
24- HOST_IP="127.0.0.1"
25- else
26- echo "Using host IP from environment variable: $HOST_IP"
27- fi
28-
29- # etcd 실행
30- exec /usr/local/bin/etcd --data-dir=/etcd-data --listen-client-urls=http://${HOST_IP}:2379,http://127.0.0.1:2379 --advertise-client-urls=http://${HOST_IP}:2379
19+ - " --data-dir=/etcd-data"
20+ - " --listen-client-urls=http://127.0.0.1:2379,http://$(HOST_IP):2379"
21+ - " --advertise-client-urls=http://$(HOST_IP):2379"
3122 volumeMounts :
3223 - name : etcd-data
3324 mountPath : /etcd-data
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # settings.yaml 파일에서 IP를 추출하여 YAML 파일의 $(HOST_IP) 패턴을 대체하는 스크립트
3+
4+ # 입력 및 출력 파일 경로
5+ SETTINGS_YAML=" /etc/containers/systemd/piccolo/settings.yaml"
6+ SERVER_YAML=" /etc/containers/systemd/piccolo/piccolo-server.yaml"
7+
8+ # settings.yaml에서 IP 주소 추출
9+ HOST_IP=$( grep -A 3 " host:" $SETTINGS_YAML | grep " ip:" | sed -e " s/^[ ]*ip:[ ]*//" -e " s/[ ]*$//" )
10+ echo " Extracted HOST_IP: $HOST_IP "
11+
12+ # IP 주소가 비어있는지 확인
13+ if [ -z " $HOST_IP " ]; then
14+ echo " Failed to extract host IP from settings.yaml"
15+ exit 1
16+ fi
17+
18+ # 문자 그대로의 $(HOST_IP)를 실제 IP 주소로 대체
19+ sed -i " s/\\\$ (HOST_IP)/${HOST_IP} /g" $SERVER_YAML
20+
21+ echo " Successfully replaced \$ (HOST_IP) with $HOST_IP in $SERVER_YAML "
22+ exit 0
You can’t perform that action at this time.
0 commit comments