1.Add script to collect logs and configurations 2.Add OVA option to enable/disable root login

This commit is contained in:
Wenkai Yin 2016-11-04 15:36:15 +08:00
parent 592e596ae4
commit 80da0ffea8
4 changed files with 53 additions and 4 deletions

21
tools/ova/script/collect.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
dir=harbor_logs
mkdir -p $dir
echo "Version" >> $dir/docker
docker version >> $dir/docker
printf "\n\nInfo\n" >> $dir/docker
docker info >> $dir/docker
printf "\n\nImages\n" >> $dir/docker
docker images >> $dir/docker
printf "\n\nRunning containers\n" >> $dir/docker
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 $base_dir/../harbor/harbor.cfg $dir/
cp -r /var/log/harbor $dir/
tar --remove-files -zcf $dir.tar.gz $dir

View File

@ -37,8 +37,8 @@ function gc {
#Add rules to iptables #Add rules to iptables
function addIptableRules { function addIptableRules {
iptables -A INPUT -p tcp --dport 5480 -j ACCEPT iptables -A INPUT -p tcp --dport 5480 -j ACCEPT
iptables -A INPUT -p tcp --dport 5488 -j ACCEPT #iptables -A INPUT -p tcp --dport 5488 -j ACCEPT
iptables -A INPUT -p tcp --dport 5489 -j ACCEPT #iptables -A INPUT -p tcp --dport 5489 -j ACCEPT
} }
#Install docker-compose #Install docker-compose
@ -51,4 +51,26 @@ function installDockerCompose {
function load { function load {
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
docker load -i $basedir/../harbor/harbor*.tgz docker load -i $basedir/../harbor/harbor*.tgz
}
#Configure SSH
function configSSH {
value=$(ovfenv -k permit_root_login)
if [ "$value" = "true" ]
then
v=yes
else
v=no
fi
echo "ssh: permit root login - $v"
sed -i -r s%"^PermitRootLogin .*"%"PermitRootLogin $v"% /etc/ssh/sshd_config
if [ ! -f /etc/ssh/ssh_host_rsa_key ] \
|| [ ! -f /etc/ssh/ssh_host_ecdsa_key ] \
|| [ ! -f /etc/ssh/ssh_host_ed25519_key ]
then
ssh-keygen -A
fi
systemctl restart sshd
} }

View File

@ -16,8 +16,11 @@ then
printf "$value\n$value\n" | passwd root printf "$value\n$value\n" | passwd root
fi fi
#configure SSH
configSSH
#echo "Adding rules to iptables..." #echo "Adding rules to iptables..."
#addIptableRules addIptableRules
echo "Installing docker compose..." echo "Installing docker compose..."
installDockerCompose installDockerCompose

View File

@ -7,8 +7,11 @@ export PATH=$PATH:/usr/local/bin
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $base_dir/common.sh source $base_dir/common.sh
#configure SSH
configSSH
#echo "Adding rules to iptables..." #echo "Adding rules to iptables..."
#addIptableRules addIptableRules
#Stop Harbor #Stop Harbor
echo "Shutting down Harbor..." echo "Shutting down Harbor..."