2.2.3. curl을 사용하여 ISO 이미지 다운로드
curl 도구를 사용하면 명령줄을 사용하여 웹에서 필요한 파일을 가져와서 로컬로 저장하거나 필요에 따라 다른 프로그램으로 파이프할 수 있습니다. 이 섹션에서는 curl 명령을 사용하여 설치 이미지를 다운로드하는 방법을 설명합니다.
사전 요구 사항
-
curl및jq패키지가 설치됩니다. -
Linux 배포판에서
dnf또는apt를 사용하지 않거나 Linux를 사용하지 않는 경우 curl 웹 사이트에서가장 적합한 소프트웨어 패키지를 다운로드합니다. - Red Hat API 토큰에서 오프라인으로 생성된 토큰
- 제품 다운로드에서 다운로드하려는 파일의 체크섬
절차
다음 콘텐츠를 사용하여 bash 파일을 생성합니다.
#!/bin/bash # set the offline token and checksum parameters offline_token="<offline_token>" checksum=<checksum> # get an access token access_token=$(curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=$offline_token | jq -r '.access_token') # get the filename and download url image=$(curl -H "Authorization: Bearer $access_token" "https://api.access.redhat.com/management/v1/images/$checksum/download") filename=$(echo $image | jq -r .body.filename) url=$(echo $image | jq -r .body.href) # download the file curl $url -o $filename위의 텍스트에서 < offline_token >을 Red Hat API 포털에서 수집한 토큰으로 바꾸고 < checksum >을 Product Downloads 페이지에서 가져온 체크섬 값으로 바꿉니다.
이 파일을 실행 가능하게 만듭니다.
$ chmod u+x FILEPATH/FILENAME.sh터미널 창을 열고 bash 파일을 실행합니다.
$ ./FILEPATH/FILENAME.sh
주의
네트워킹 모범 사례와 일치하는 암호 관리를 사용하십시오.
- 일반 텍스트에 암호 또는 인증 정보를 저장해 두지 마십시오.
- 무단 사용으로부터 토큰을 안전하게 보관합니다.