Merge pull request #1030 from ywk253100/161104_ova

OVA
This commit is contained in:
Daniel Jiang 2016-11-08 16:52:59 +08:00 committed by GitHub
commit 8e0d1748a2
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
function addIptableRules {
iptables -A INPUT -p tcp --dport 5480 -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 5488 -j ACCEPT
#iptables -A INPUT -p tcp --dport 5489 -j ACCEPT
}
#Install docker-compose
@ -51,4 +51,26 @@ function installDockerCompose {
function load {
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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
fi
#configure SSH
configSSH
#echo "Adding rules to iptables..."
#addIptableRules
addIptableRules
echo "Installing docker compose..."
installDockerCompose

View File

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