From 9d5f12c6c5e71653ec1aca8c21b69c6ce3bf5d18 Mon Sep 17 00:00:00 2001 From: olli Date: Wed, 23 Aug 2023 14:15:21 +0200 Subject: [PATCH] =?UTF-8?q?install.sh=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..acfe135 --- /dev/null +++ b/install.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -e + +# on fresh install remove cdrom-repo and install sudo if not available +[ -s /usr/bin/sudo ] || su -c "sed -i '/cdrom/d' /etc/apt/sources.list ; apt update ; apt -y install sudo" +# add user to sudo group it not +if ! id | grep -q '(sudo)' +then + su -c "/usr/sbin/usermod -a -G sudo ${USER}" + # use sudo group and restart this script + exec sg sudo -c "bash $0" + exit $? +fi + +which ansible >/dev/null 2>&1 || sudo apt-get -y install ansible git +sudo ansible-galaxy collection list | grep -q community.general || sudo ansible-galaxy collection install community.general + +cd +rm -rf $(hostname -s)-git +mkdir $(hostname -s)-git +cd $(hostname -s)-git + + +for playbook in $PLAYBOOKS +do + git clone https://gitea.ds9.dedyn.io/olli/${playbook}.git + [ -s /etc/dohardening ] || rm -f ${playbook}/hardening.yml + sudo ansible-playbook --connection=local --inventory $(hostname), --limit $(hostname) ${playbook}/*.yml +done \ No newline at end of file