mirror of
https://github.com/jung-geun/policy-routing.git
synced 2025-12-20 02:34:39 +09:00
46 lines
1.5 KiB
YAML
46 lines
1.5 KiB
YAML
#cloud-config
|
|
|
|
write_files:
|
|
- path: /tmp/pbr-script-cloud-init.sh
|
|
permissions: "0755"
|
|
owner: root:root
|
|
content: |
|
|
#!/bin/bash
|
|
|
|
# GitLab 스크립트 URL (공개 저장소 또는 접근 가능한 URL)
|
|
# 예시: GitLab Pages, Raw 파일 URL 등
|
|
# private repository인 경우 인증 관련 부분을 추가해야 합니다. (아래 설명)
|
|
SCRIPT_URL="https://git.dmslab.xyz/dmslab/policy-routing/-/raw/v0.3/policy_routing.py"
|
|
DEST_PATH="/opt/PBR/routing.py"
|
|
|
|
# 스크립트 저장될 디렉토리 생성 (필요하다면)
|
|
mkdir -p $(dirname "${DEST_PATH}")
|
|
|
|
echo "Downloading script from ${SCRIPT_URL}..."
|
|
# wget 또는 curl 사용
|
|
# wget이 일반적으로 더 많이 사용됨
|
|
if command -v wget &> /dev/null
|
|
then
|
|
wget -O "${DEST_PATH}" "${SCRIPT_URL}"
|
|
elif command -v curl &> /dev/null
|
|
then
|
|
curl -o "${DEST_PATH}" "${SCRIPT_URL}"
|
|
else
|
|
echo "Error: Neither wget nor curl found. Cannot download script."
|
|
exit 1
|
|
fi
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "Script downloaded successfully to ${DEST_PATH}. Executing..."
|
|
chmod +x "${DEST_PATH}" # 실행 권한 부여
|
|
"${DEST_PATH}" setup --force # 스크립트 실행
|
|
else
|
|
echo "Error: Failed to download script from ${SCRIPT_URL}."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Script execution finished."
|
|
|
|
runcmd:
|
|
- /tmp/pbr-script-cloud-init.sh
|