#!/bin/bash function check() { PREFIX="recipe:postgresql:check" container_running "$CONTAINER" || return 10 echo "checking postgresql regarding access to the bridge subnet <$BRIDGE_SUBNET>..." lxc exec "$CONTAINER" -- bash </dev/null ss -tlnp | grep postgres | grep -q 0.0.0.0:5432 PG_VERSION=\$(pg_lsclusters -h | cut -d' ' -f1) grep -Eq "^host.*all.*all.*$BRIDGE_SUBNET.*md5" /etc/postgresql/\$PG_VERSION/main/pg_hba.conf test -f /etc/default/autopostgresqlbackup EOF status="$?" [[ $status -eq 0 ]] && echo "container <$CONTAINER> approved!" return $status } function install() { PREFIX="recipe:postgresql:install" : "$PREFIX" echowarn "initializing postgresql regarding access to the bridge subnet <$BRIDGE_SUBNET>..." launch_container "$CONTAINER" lxc exec "$CONTAINER" -- bash < files over container <$CONTAINER> ... " lxc file push --uid 0 --gid 0 "$MIAOU_BASEDIR/templates/autopostgresqlbackup/script" "$CONTAINER/usr/sbin/autopostgresqlbackup" lxc file push --uid 0 --gid 0 "$MIAOU_BASEDIR/templates/autopostgresqlbackup/cron.daily" "$CONTAINER/etc/cron.daily/autopostgresqlbackup" lxc file push --uid 0 --gid 0 "$MIAOU_BASEDIR/templates/autopostgresqlbackup/default.conf" "$CONTAINER/etc/default/autopostgresqlbackup" PREFIX="" echo OK } # MAIN . "$MIAOU_BASEDIR/lib/init.sh" arg1_required "$@" CONTAINER="$1" BRIDGE_SUBNET=$(lxc network get lxdbr0 ipv4.address) readonly CONTAINER BRIDGE_SUBNET check || ( install check )