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.

69 lines
1.5 KiB

#!/usr/bin/env bash
# CONSTANTS
BASEDIR=$(dirname "$0")
CONTAINER=''
# FUNCTIONS
function usage {
echo "$(basename "$0") <CONTAINER_NAME>"
}
function parse_options {
while [[ $# -gt 0 ]]; do
case "$1" in
--help | -h)
usage && exit 0
;;
*)
if [[ -z $CONTAINER ]]; then
CONTAINER=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
esac
shift 1 # Move to the next argument
done
[[ -n $CONTAINER ]] || (usage && exit 1)
}
function assert_miaou_server {
[[ -d /opt/miaou-incus ]] ||
[[ -d /opt/miaou-proxmox ]] ||
(>&2 echo 'ERROR: either miaou-{incus,proxmox} must be installed on this host prior running this command!' && exit 10)
}
function assert_fake_sympa {
[[ $(fqdn) == 'topcode' ]] && [[ -d /opt/miaou-incus ]]
}
function install_sympa_tools {
for file in "$BASEDIR"/../resources/tools/*; do
miaou-push $CONTAINER $file /opt/miaou-sympa/tools/
done
miaou-exec $CONTAINER -- ln -sf /usr/lib/sympa/bin/sympa.pl /opt/miaou-sympa/tools/
}
function install_fake_additional {
assert_fake_sympa || return
echo 'install fake additional TODO: not yet functional...'
# 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
}
# MAIN
set -Eue
parse_options $*
assert_miaou_server
miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa.recipe
miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_custom_style.recipe
install_sympa_tools
install_fake_additional