2016-10-25 12:09:54 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#Shut down Harbor
|
|
|
|
function down {
|
|
|
|
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
docker-compose -f $base_dir/../harbor/docker-compose*.yml down
|
|
|
|
}
|
|
|
|
|
|
|
|
#Start Harbor
|
|
|
|
function up {
|
|
|
|
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
$base_dir/start_harbor.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
#Configure Harbor
|
|
|
|
function configure {
|
|
|
|
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
$base_dir/config.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
#Garbage collectoin
|
|
|
|
function gc {
|
|
|
|
echo "======================= $(date)====================="
|
|
|
|
|
|
|
|
#the registry image
|
|
|
|
image=$1
|
|
|
|
|
|
|
|
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
docker run --name gc --rm --volume /data/registry:/storage \
|
|
|
|
--volume $base_dir/../harbor/common/config/registry/:/etc/registry/ \
|
|
|
|
$image garbage-collect /etc/registry/config.yml
|
|
|
|
|
|
|
|
echo "===================================================="
|
|
|
|
}
|
|
|
|
|
|
|
|
#Add rules to iptables
|
|
|
|
function addIptableRules {
|
|
|
|
iptables -A INPUT -p tcp --dport 5480 -j ACCEPT
|
2016-11-04 08:36:15 +01:00
|
|
|
#iptables -A INPUT -p tcp --dport 5488 -j ACCEPT
|
|
|
|
#iptables -A INPUT -p tcp --dport 5489 -j ACCEPT
|
2016-10-25 12:09:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#Install docker-compose
|
|
|
|
function installDockerCompose {
|
|
|
|
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
$base_dir/../deps/docker-compose-1.7.1/install.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
#Load images
|
|
|
|
function load {
|
|
|
|
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
docker load -i $basedir/../harbor/harbor*.tgz
|
2016-11-04 08:36:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#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
|
2016-10-25 12:09:54 +02:00
|
|
|
}
|