#!/bin/bash set -e # ansible.builtin.script: # chdir: /root # just in case one runs the script outside ansible cd /root/ [[ ! -x `which curl` ]] && echo error: curl executable not found && exit 1 [[ ! -x `which dpkg` ]] && echo error: dpkg executable not found && exit 1 [[ ! -x `which gpg1` ]] && echo error: gpg1 executable not found && exit 1 [[ ! -x `which lsb_release` ]] && echo error: lsb_release executable not found && exit 1 export DEBIAN_FRONTEND=noninteractive echo -n checking /usr/share/keyrings/fluentbit.gpg ... if [[ -f /usr/share/keyrings/fluentbit.gpg ]]; then echo already else curl -s https://packages.fluentbit.io/fluentbit.key | gpg1 --dearmor > /usr/share/keyrings/fluentbit.gpg && echo done || echo FAIL changed=1 fi distro=`lsb_release -cs 2>/dev/null` if [[ $distro = bookworm || $distro = bullseye ]]; then base=debian elif [[ $distro = jammy || $distro = focal ]]; then base=ubuntu else echo error: $distro - unknown linux distribution codename - eventually update $0 exit 1 fi echo -n checking /etc/apt/sources.list.d/fluentbit.list ... if [[ -f /etc/apt/sources.list.d/fluentbit.list ]]; then echo already else cat > /etc/apt/sources.list.d/fluentbit.list </dev/null 2>&1; then # ok=1 changed=0 echo already else echo -n update package cache ... apt-get -q -y update >/dev/null 2>&1 && echo done || echo FAIL # eventually failed=1 apt-get -q -y install fluent-bit 2>&1 && echo done || echo FAIL changed=1 systemctl enable fluent-bit --now fi [[ -z $changed ]] && echo nothing changed && exit 0 # ok=1 changed=1 echo changed - all done