11#! /bin/bash
22
3- # Utility to manage rpm/deb repositories for packages.treasuredata.com
3+ # Utility to manage rpm/deb repositories for fluentd.cdn.cncf.io
44#
55# Usage:
66# $ manage-fluent-repositories.sh COMMAND FLUENT_RELEASE_DIR
77#
8- # NOTE: setup AccessKeyId, SecretAccessKey, SessionToken and AWS release-td-agent profile in beforehand
9- # $ aws sts get-session-token --serial-number arn:aws:iam::523683666290:mfa/clearcode-xxx --profile USER_PROFILE --duration-seconds 129600 --token-code XXXXX
8+ # NOTE: setup fluentd-r2 profile in beforehand. See secrets in fluent-apt-source/
9+ #
10+ # 1. configure fluentd-r2 profile in ~/.aws/credentials
11+ # 2. export AWS_ENDPOINT_URL_S3=...
1012#
1113
1214set -e
@@ -17,13 +19,13 @@ Usage:
1719 $0 COMMAND [FLUENT_RELEASE_PROFILE] [FLUENT_RELEASE_DIR] [FLUENT_PACKAGE_VERSION]
1820
1921Example:
20- $ $0 ls release-td-agent
21- $ $0 dry-download release-td-agent /tmp/td-agent -release
22- $ $0 download release-td-agent /tmp/td-agent -release
23- $ $0 dry-upload release-td-agent /tmp/td-agent -release
24- $ $0 upload release-td-agent /tmp/td-agent -release
25- $ $0 deb /tmp/td-agent -release 4.2 .0
26- $ $0 rpm /tmp/td-agent -release 4.2 .0
22+ $ $0 ls fluentd-r2
23+ $ $0 dry-download fluentd-r2 /tmp/fluent-package -release
24+ $ $0 download fluentd-r2 /tmp/fluent-package -release
25+ $ $0 dry-upload fluentd-r2 /tmp/fluent-package -release
26+ $ $0 upload fluentd-r2 /tmp/fluent-package -release
27+ $ $0 deb /tmp/fluent-package -release 6.0 .0
28+ $ $0 rpm /tmp/fluent-package -release 6.0 .0
2729 $ $0 download-artifacts pull/587
2830EOF
2931}
@@ -42,7 +44,7 @@ case $COMMAND in
4244 FLUENT_RELEASE_DIR=$2
4345 FLUENT_PACKAGE_VERSION=$3
4446 if [ -z " $FLUENT_PACKAGE_VERSION " ]; then
45- echo " ERROR: No package version for releasing fluentd packages, (e.g export FLUENT_PACKAGE_VERSION=4.2.0)"
47+ echo -e " \e[37;41mERROR:\e[0m No package version for releasing fluentd packages, (e.g export FLUENT_PACKAGE_VERSION=4.2.0)"
4648 exit 1
4749 fi
4850 ;;
@@ -61,7 +63,12 @@ case $COMMAND in
6163 FLUENT_RELEASE_DIR=$3
6264 FLUENT_PACKAGE_VERSION=$4
6365 if [ -z " $FLUENT_RELEASE_PROFILE " ]; then
64- echo " ERROR: No s3 profile for releasing fluentd packages"
66+ echo -e " \e[37;41mERROR:\e[0m No s3 profile for releasing fluentd packages"
67+ usage
68+ exit 1
69+ fi
70+ if [ -z " $AWS_ENDPOINT_URL_S3 " ]; then
71+ echo -e " \e[37;41mERROR:\e[0m No AWS_ENDPOINT_URL_S3 environment variable"
6572 usage
6673 exit 1
6774 fi
7178case $COMMAND in
7279 ls)
7380 # check whether profile and permission is valid
74- command=" aws s3 ls s3://packages.treasuredata.com --profile $FLUENT_RELEASE_PROFILE "
81+ command=" aws s3 ls s3://fluentd --profile $FLUENT_RELEASE_PROFILE "
7582 echo $command
7683 $command
7784 ;;
@@ -84,41 +91,41 @@ case $COMMAND in
8491 for target in $TARGETS ; do
8592 case $FLUENT_RELEASE_DIR in
8693 * test/experimental/lts)
87- command=" aws s3 sync $DRYRUN_OPTION --delete $FLUENT_RELEASE_DIR /6/$target s3://packages.treasuredata.com /test/experimental/lts/6/$target --profile $FLUENT_RELEASE_PROFILE "
94+ command=" aws s3 sync $DRYRUN_OPTION --delete $FLUENT_RELEASE_DIR /6/$target s3://fluentd /test/experimental/lts/6/$target --profile $FLUENT_RELEASE_PROFILE "
8895 ;;
8996 * test/experimental)
90- command=" aws s3 sync $DRYRUN_OPTION --delete $FLUENT_RELEASE_DIR /6/$target s3://packages.treasuredata.com /test/experimental/6/$target --profile $FLUENT_RELEASE_PROFILE "
97+ command=" aws s3 sync $DRYRUN_OPTION --delete $FLUENT_RELEASE_DIR /6/$target s3://fluentd /test/experimental/6/$target --profile $FLUENT_RELEASE_PROFILE "
9198 ;;
9299 * lts)
93- command=" aws s3 sync $DRYRUN_OPTION --delete $FLUENT_RELEASE_DIR /6/$target s3://packages.treasuredata.com /lts/6/$target --profile $FLUENT_RELEASE_PROFILE "
100+ command=" aws s3 sync $DRYRUN_OPTION --delete $FLUENT_RELEASE_DIR /6/$target s3://fluentd /lts/6/$target --profile $FLUENT_RELEASE_PROFILE "
94101 ;;
95102 * )
96- command=" aws s3 sync $DRYRUN_OPTION --delete $FLUENT_RELEASE_DIR /6/$target s3://packages.treasuredata.com /6/$target --profile $FLUENT_RELEASE_PROFILE "
103+ command=" aws s3 sync $DRYRUN_OPTION --delete $FLUENT_RELEASE_DIR /6/$target s3://fluentd /6/$target --profile $FLUENT_RELEASE_PROFILE "
97104 ;;
98105 esac
99106 echo $command
100107 $command
101108 done
102109 ;;
103110 dry-download|download)
104- VERSIONS=" 5 "
111+ VERSIONS=" 6 "
105112 DRYRUN_OPTION=" --dryrun"
106113 if [ $COMMAND = " download" ]; then
107114 DRYRUN_OPTION=" "
108115 fi
109116 for target in $VERSIONS ; do
110117 case $FLUENT_RELEASE_DIR in
111118 * test/experimental/lts)
112- command=" aws s3 sync $DRYRUN_OPTION --delete s3://packages.treasuredata.com /test/experimental/lts/$target $FLUENT_RELEASE_DIR /$target --profile $FLUENT_RELEASE_PROFILE "
119+ command=" aws s3 sync $DRYRUN_OPTION --delete s3://fluentd /test/experimental/lts/$target $FLUENT_RELEASE_DIR /$target --profile $FLUENT_RELEASE_PROFILE "
113120 ;;
114121 * test/experimental)
115- command=" aws s3 sync $DRYRUN_OPTION --delete s3://packages.treasuredata.com /test/experimental/$target $FLUENT_RELEASE_DIR /$target --profile $FLUENT_RELEASE_PROFILE "
122+ command=" aws s3 sync $DRYRUN_OPTION --delete s3://fluentd /test/experimental/$target $FLUENT_RELEASE_DIR /$target --profile $FLUENT_RELEASE_PROFILE "
116123 ;;
117124 * lts)
118- command=" aws s3 sync $DRYRUN_OPTION --delete s3://packages.treasuredata.com /lts/$target $FLUENT_RELEASE_DIR /$target --profile $FLUENT_RELEASE_PROFILE "
125+ command=" aws s3 sync $DRYRUN_OPTION --delete s3://fluentd /lts/$target $FLUENT_RELEASE_DIR /$target --profile $FLUENT_RELEASE_PROFILE "
119126 ;;
120127 * )
121- command=" aws s3 sync $DRYRUN_OPTION --delete s3://packages.treasuredata.com /$target $FLUENT_RELEASE_DIR /$target --profile $FLUENT_RELEASE_PROFILE "
128+ command=" aws s3 sync $DRYRUN_OPTION --delete s3://fluentd /$target $FLUENT_RELEASE_DIR /$target --profile $FLUENT_RELEASE_PROFILE "
122129 ;;
123130 esac
124131 echo $command
176183 find $FLUENT_RELEASE_DIR /6 -name " *$FLUENT_PACKAGE_VERSION *.rpm" | xargs rpm --resign --define " _gpg_name $SIGNING_KEY "
177184 # check whether packages are signed correctly.
178185 find $FLUENT_RELEASE_DIR /6 -name " *$FLUENT_PACKAGE_VERSION *.rpm" | xargs rpm -K || \
179- (echo " Import public key to verify: rpm --import https://s3.amazonaws.com/packages.treasuredata.com /GPG-KEY-fluent-package" && exit 1)
186+ (echo -e " \e[37;41mERROR:\e[0m Import public key to verify: rpm --import https://fluentd /GPG-KEY-fluent-package" && exit 1)
180187
181188 # update & sign rpm repository
182189 repodirs=` find " ${FLUENT_RELEASE_DIR} " -regex " ^${FLUENT_RELEASE_DIR} /6/\(redhat\|amazon\)/\([2789]\|10\|2023\)/\(x86_64\|aarch64\)$" `
0 commit comments