fix exposure issue when collecting logs

This commit is contained in:
Wenkai Yin 2016-12-06 13:05:57 +08:00
parent 9ab756e2b7
commit bad8835c79

View File

@ -1,6 +1,8 @@
#!/bin/bash
dir=harbor_logs
outputdir=/tmp
outputfolder=harbor_logs
dir=$outputdir/$outputfolder
mkdir -p $dir
echo "Version" >> $dir/docker
@ -15,7 +17,29 @@ docker ps >> $dir/docker
docker-compose version >> $dir/docker-compose
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cp -r $base_dir/../harbor/common $dir/
cp -r $base_dir/../script $dir/
cp $base_dir/../harbor/harbor.cfg $dir/
cp -r /var/log/harbor $dir/
tar --remove-files -zcf $dir.tar.gz $dir
properties=(
email_server
email_server_port
email_username
email_password
email_from
harbor_admin_password
ldap_url
ldap_searchdn
ldap_search_pwd
ldap_basedn
db_password
)
for property in "${properties[@]}"
do
sed -i -r "s%#?$property\s*=\s*.*%$property = %" $dir/harbor.cfg
done
tar --remove-files -zcf $outputfolder.tar.gz -C $outputdir $outputfolder
echo "$outputfolder.tar.gz is generated in current directory."