#!/usr/bin/env bash

# Managed by puppet class profile::swh::deploy::worker::loader_opam
# Changes will be overwritten

CMD=/usr/bin/opam
ROOT_DIR=<%= @opam_root %>
INSTANCE=$1
INSTANCE_URL=$2

if [ $INSTANCE = "opam" ]; then
  # Opam instance is considered the main instance so we must initialize the repository
  # if not present, otherwise we update it
  ( $CMD repo --all --root $ROOT_DIR | grep $INSTANCE_URL && $CMD update --root $ROOT_DIR ) \
    || $CMD init --reinit --bare --no-setup --root $ROOT_DIR $INTSANCE $INSTANCE_URL
else
  # Other instances, if present should be updated. If not present, they should be added
  # to the main root_dir as extra instances
  ( $CMD repo --all --root $ROOT_DIR | grep $INSTANCE_URL && $CMD update --root $ROOT_DIR ) \
    || $CMD repository add --root $ROOT_DIR $INSTANCE $INSTANCE_URL
fi

#!/usr/bin/env bash

# Managed by puppet class profile::swh::deploy::worker::loader_opam
# Changes will be overwritten

CMD=/usr/bin/opam
ROOT_DIR=<%= @opam_root %>
DEFAULT_INSTANCE="opam.ocaml.org"
INSTANCE=$1
INSTANCE_URL=$2

if [ $INSTANCE = $DEFAULT_INSTANCE ]; then
  # Opam instance is considered the main instance so we must initialize the repository
  # if not present, otherwise we update it
  ( $CMD repo --all --root $ROOT_DIR | grep $INSTANCE_URL && $CMD update --root $ROOT_DIR ) \
    || $CMD init --reinit --bare --no-setup --root $ROOT_DIR $INTSANCE $INSTANCE_URL
else
  # Other instances, if present should be updated. If not present, they should be added
  # to the main root_dir as extra instances
  ( $CMD repo --all --root $ROOT_DIR | grep $INSTANCE_URL && $CMD update --root $ROOT_DIR ) \
    || $CMD repository add --root $ROOT_DIR $INSTANCE $INSTANCE_URL
fi

Rename properly the instances 2/2
Rename properly the instances 2/2

Related to T3717
