-function install_docker_ce() {
- # installs and configures Docker CE
- echo "Installing Docker CE ..."
- sudo apt-get -qq update
- sudo apt-get install -y apt-transport-https ca-certificates software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get -qq update
- sudo apt-get install -y docker-ce
- echo "Adding user to group 'docker'"
- sudo groupadd -f docker
- sudo usermod -aG docker $USER
- sleep 2
- sudo service docker restart
- echo "... restarted Docker service"
- if [ -n "${DOCKER_PROXY_URL}" ]; then
- echo "Configuring docker proxy ..."
- if [ -f /etc/docker/daemon.json ]; then
- if grep -q registry-mirrors /etc/docker/daemon.json; then
- sudo sed -i "s|registry-mirrors.*|registry-mirrors\": [\"${DOCKER_PROXY_URL}\"] |" /etc/docker/daemon.json
- else
- sudo sed -i "s|{|{\n \"registry-mirrors\": [\"${DOCKER_PROXY_URL}\"],|" /etc/docker/daemon.json
- fi
- else
- sudo bash -c "cat << EOF > /etc/docker/daemon.json
-{
- \"registry-mirrors\": [\"${DOCKER_PROXY_URL}\"]
-}
-EOF"
- fi
- sudo systemctl daemon-reload
- sudo service docker restart
- echo "... restarted Docker service again"
- fi
- sg docker -c "docker version" || FATAL "Docker installation failed"
- echo "... Docker CE installation done"
- return 0
-}
-
-function install_docker_compose() {
- # installs and configures docker-compose
- echo "Installing Docker Compose ..."
- sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
- sudo chmod +x /usr/local/bin/docker-compose
- echo "... Docker Compose installation done"
-}
-
-function install_juju() {
- echo "Installing juju"
- sudo snap install juju --classic --channel=2.8/stable
- [[ ":$PATH": != *":/snap/bin:"* ]] && PATH="/snap/bin:${PATH}"
- [ -n "$INSTALL_NOCACHELXDIMAGES" ] || update_juju_images
- echo "Finished installation of juju"
- return 0
-}
-
-function juju_createcontroller() {
- if ! juju show-controller $OSM_STACK_NAME &> /dev/null; then
- # Not found created, create the controller
- sudo usermod -a -G lxd ${USER}
- sg lxd -c "juju bootstrap --bootstrap-series=xenial --agent-version=$JUJU_AGENT_VERSION $OSM_VCA_CLOUDNAME $OSM_STACK_NAME"
- fi
- [ $(juju controllers | awk "/^${OSM_STACK_NAME}[\*| ]/{print $1}"|wc -l) -eq 1 ] || FATAL "Juju installation failed"
- juju controller-config features=[k8s-operators]
-}
-
-function juju_addk8s() {
- cat $HOME/.kube/config | juju add-k8s $OSM_VCA_K8S_CLOUDNAME --controller $OSM_STACK_NAME --storage openebs-hostpath
-}
-
-function juju_createcontroller_k8s(){
- cat $HOME/.kube/config | juju add-k8s $OSM_VCA_K8S_CLOUDNAME --client
- juju bootstrap $OSM_VCA_K8S_CLOUDNAME $OSM_STACK_NAME \
- --config controller-service-type=loadbalancer \
- --agent-version=$JUJU_AGENT_VERSION
-}
-
-
-function juju_addlxd_cloud(){
- mkdir -p /tmp/.osm
- OSM_VCA_CLOUDNAME="lxd-cloud"
- LXDENDPOINT=$DEFAULT_IP
- LXD_CLOUD=/tmp/.osm/lxd-cloud.yaml
- LXD_CREDENTIALS=/tmp/.osm/lxd-credentials.yaml
-
- cat << EOF > $LXD_CLOUD
-clouds:
- $OSM_VCA_CLOUDNAME:
- type: lxd
- auth-types: [certificate]
- endpoint: "https://$LXDENDPOINT:8443"
- config:
- ssl-hostname-verification: false
-EOF
- openssl req -nodes -new -x509 -keyout /tmp/.osm/client.key -out /tmp/.osm/client.crt -days 365 -subj "/C=FR/ST=Nice/L=Nice/O=ETSI/OU=OSM/CN=osm.etsi.org"
- local server_cert=`cat /var/snap/lxd/common/lxd/server.crt | sed 's/^/ /'`
- local client_cert=`cat /tmp/.osm/client.crt | sed 's/^/ /'`
- local client_key=`cat /tmp/.osm/client.key | sed 's/^/ /'`
-
- cat << EOF > $LXD_CREDENTIALS
-credentials:
- $OSM_VCA_CLOUDNAME:
- lxd-cloud:
- auth-type: certificate
- server-cert: |
-$server_cert
- client-cert: |
-$client_cert
- client-key: |
-$client_key
-EOF
- lxc config trust add local: /tmp/.osm/client.crt
- juju add-cloud -c $OSM_STACK_NAME $OSM_VCA_CLOUDNAME $LXD_CLOUD --force
- juju add-credential -c $OSM_STACK_NAME $OSM_VCA_CLOUDNAME -f $LXD_CREDENTIALS
- sg lxd -c "lxd waitready"
- juju controller-config features=[k8s-operators]
-}
-
-
-function juju_createproxy() {
- check_install_iptables_persistent
-
- if ! sudo iptables -t nat -C PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST; then
- sudo iptables -t nat -A PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST
- sudo netfilter-persistent save
- fi
-}
-