From 53037fb233f619c4f6fee5928f09f121afd95473 Mon Sep 17 00:00:00 2001 From: simono41 Date: Mon, 5 Aug 2019 13:43:33 +0200 Subject: [PATCH] server_optimize --- server_optimize.sh | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/server_optimize.sh b/server_optimize.sh index 379f376..98d32ad 100755 --- a/server_optimize.sh +++ b/server_optimize.sh @@ -5,6 +5,14 @@ set -ex version="${1}" [[ -z "${version}" ]] && version="${hostname#*-}" +# while-schleife +while (( "$#" )) +do + echo ${1} + export ${1}="y" + shift +done + if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 sudo "$0" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" @@ -14,6 +22,8 @@ else fi echo "Als root Angemeldet" +sleep 5 + function makesshsecure() { #sshd -T |grep permitrootlogin @@ -53,7 +63,12 @@ function makefail2ban() { } function makeuser() { + if ! cat /etc/group | grep wheel; then + groupadd wheel + fi + echo "root ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers echo "%wheel ALL=(ALL)" >> /etc/sudoers + adduser user1 adduser user1 wheel } @@ -88,14 +103,21 @@ function dailyupdates() { } -makesshsecure -sleep 1 -makeiptables -sleep 1 -makefail2ban -sleep 1 -makeuser -sleep 1 -userloginalert -sleep 1 -dailyupdates +if [ "${makesshsecure}" == "y" ] || [ "${all}" == "y" ]; then + makesshsecure +fi +if [ "${makeiptables}" == "y" ] || [ "${all}" == "y" ]; then + makeiptables +fi +if [ "${makefail2ban}" == "y" ] || [ "${all}" == "y" ]; then + makefail2ban +fi +if [ "${makeuser}" == "y" ] || [ "${all}" == "y" ]; then + makeuser +fi +if [ "${userloginalert}" == "y" ] || [ "${all}" == "y" ]; then + userloginalert +fi +if [ "${dailyupdates}" == "y" ] || [ "${all}" == "y" ]; then + dailyupdates +fi