You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.1 KiB

#!/usr/bin/env bash
# CONSTANTS
BASEDIR=$(dirname "$0")
CONTAINER=''
IMPORT_FILE=''
# FUNCTIONS
function usage {
echo "$(basename "$0") <CONTAINER_NAME> <BACKUP_SYMPA_FILE>"
}
function parse_options {
while [[ $# -gt 0 ]]; do
case "$1" in
--help | -h)
usage && exit 0
;;
*)
if [[ -z $CONTAINER ]]; then
CONTAINER=$1
elif [[ -z $IMPORT_FILE ]]; then
IMPORT_FILE=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
esac
shift 1 # Move to the next argument
done
[[ -n $CONTAINER ]] || [[ -n $IMPORT_FILE ]] (usage && exit 1)
}
function assert_fake_sympa {
[[ $(fqdn) == 'topcode' ]] && [[ -d /opt/miaou-incus ]]
}
function install_fake_additional {
assert_fake_sympa || return
echo 'install fake additional...'
miaou-push $CONTAINER $HOME/.ssh/id_ed25519 /root/.ssh/
miaou-push $CONTAINER $HOME/.ssh/id_ed25519.pub /root/.ssh/
miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_ldap_auth_remote.recipe
echo 'install fake additional...OK'
}
# MAIN
set -Eue
parse_options $*
"$BASEDIR"/miaou-install-sympa "$CONTAINER"
# TODO: import from file...
install_fake_additional