diff --git a/tools/ova/script/collect.sh b/tools/ova/script/collect.sh new file mode 100755 index 000000000..a189a6f8a --- /dev/null +++ b/tools/ova/script/collect.sh @@ -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 \ No newline at end of file diff --git a/tools/ova/script/common.sh b/tools/ova/script/common.sh index 88b268a78..3ce906c10 100755 --- a/tools/ova/script/common.sh +++ b/tools/ova/script/common.sh @@ -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 } \ No newline at end of file diff --git a/tools/ova/script/firstboot.sh b/tools/ova/script/firstboot.sh index dde6da80e..32ac4c473 100755 --- a/tools/ova/script/firstboot.sh +++ b/tools/ova/script/firstboot.sh @@ -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 diff --git a/tools/ova/script/subsequentboot.sh b/tools/ova/script/subsequentboot.sh index ad09d8743..9cf9a8c0f 100755 --- a/tools/ova/script/subsequentboot.sh +++ b/tools/ova/script/subsequentboot.sh @@ -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..."