#!/bin/bash readonly UNWANTED_PACKAGES_STRING="nginx node python haxe" readonly MANDATORY_PACKAGES_STRING="wget apache2 make git imagemagick gettext libapache2-mod-neko mariadb-client sendemail libio-socket-ssl-perl libnet-ssleay-perl" ### CHECK function check() { PREFIX="recipe:cagettepei:check" check_unwanted_packages || return 21 check_mandatory_packages || return 22 check_apache_modules || return 23 check_node8 || return 24 check_python2 || return 25 check_haxe3 || return 26 check_cagettepei_batch || return 35 check_cagettepei_timers || return 36 } function check_apache_modules() { lxc exec "$CONTAINER" -- bash <&1 | grep -q 'Python 2.7.18' EOF } function check_haxe3() { lxc exec "$CONTAINER" -- bash <&1 | grep -q '3.4.7' EOF } function check_unwanted_packages() { lxc exec "$CONTAINER" -- bash </dev/null | grep -q ^ii) done true # useful because for might return last inexistant package EOF } function check_mandatory_packages() { lxc exec "$CONTAINER" -- bash </dev/null | grep -q ^ii done EOF } ### INSTALL function install() { PREFIX="recipe:cagettepei:install" : $PREFIX launch_container "$CONTAINER" echo "initializing CagettePĂ©i ... " echo -n "check unwanted packages..." check_unwanted_packages PREFIX="" echo "OK" lxc exec "$CONTAINER" -- bash </,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf sed -i 's/^Listen 80$//' /etc/apache2/ports.conf echo "prepare folder for cagettepei instances" mkdir -p /var/www/cagettepei echo "enable neko and rewrite apache2 modules" a2enmod neko a2enmod rewrite EOF echo -n "copy cagettepei-batch..." lxc file push --uid 0 --gid 0 "$MIAOU_BASEDIR/templates/apps/cagettepei/cagettepei-batch" "$CONTAINER/var/www/cagettepei/cagettepei-batch" lxc exec "$CONTAINER" -- chmod +x /var/www/cagettepei/cagettepei-batch PREFIX="" echo "OK" echo -n "copy cagettepei timers in systemd..." lxc file push --uid 0 --gid 0 "$MIAOU_BASEDIR/templates/apps/cagettepei/systemd/cagettepei-batch-minute.service" "$CONTAINER/etc/systemd/system/cagettepei-batch-minute.service" lxc file push --uid 0 --gid 0 "$MIAOU_BASEDIR/templates/apps/cagettepei/systemd/cagettepei-batch-minute.timer" "$CONTAINER/etc/systemd/system/cagettepei-batch-minute.timer" lxc file push --uid 0 --gid 0 "$MIAOU_BASEDIR/templates/apps/cagettepei/systemd/cagettepei-batch-day.service" "$CONTAINER/etc/systemd/system/cagettepei-batch-day.service" lxc file push --uid 0 --gid 0 "$MIAOU_BASEDIR/templates/apps/cagettepei/systemd/cagettepei-batch-day.timer" "$CONTAINER/etc/systemd/system/cagettepei-batch-day.timer" PREFIX="" echo "OK" echo -n "override apache2 service to launch cagettepei timers..." lxc exec "$CONTAINER" -- bash -c "SYSTEMD_EDITOR=tee systemctl edit apache2 <