Przeglądaj źródła

added root check and needrestart check

Bachir Soussi Chiadmi 7 lat temu
rodzic
commit
c1eefcd6fc
8 zmienionych plików z 49 dodań i 6 usunięć
  1. 5 2
      bin/email.sh
  2. 7 0
      bin/fail2ban.sh
  3. 7 1
      bin/firewall.sh
  4. 7 1
      bin/knockd.sh
  5. 3 2
      bin/lemp.sh
  6. 7 0
      bin/misc.sh
  7. 7 0
      bin/upgrade.sh
  8. 6 0
      bin/user.sh

+ 5 - 2
bin/email.sh

@@ -9,10 +9,13 @@ echo '\033[35m
 \033[0m'
 echo "\033[35;1mEnable mail sending for php \033[0m"
 
-# TODO check if root
+if [ "$EUID" -ne 0 ]
+  then echo "Please run as root"
+  exit
+fi
 
 # http://www.sycha.com/lamp-setup-debian-linux-apache-mysql-php#anchor13
-sleep 3
+sleep 2
 apt-get --yes --force-yes install exim4
 echo "\033[35;1mConfiguring EXIM4 \033[0m"
 while [ "$configexim" != "y" ] && [ "$configexim" != "n" ]

+ 7 - 0
bin/fail2ban.sh

@@ -10,6 +10,13 @@ echo '\033[35m
 /_/    \__,_/_/_//____/_.___/\__,_/_/ /_/
 \033[0m'
 echo "\033[35;1mInstalling fall2ban \033[0m"
+
+if [ "$EUID" -ne 0 ]
+  then echo "Please run as root"
+  exit
+fi
+
+sleep 2
 apt-get --yes --force-yes install fail2ban
 cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
 # ToDo ask for email and configure jail.local with it

+ 7 - 1
bin/firewall.sh

@@ -10,7 +10,13 @@ echo '\033[35m
 /_/   /___/_/ |_/_____/  |__/|__/_/  |_/_____/_____/
 \033[0m'
 echo "\033[35;1mInstalling ufw and setup firewall (allowing only ssh and http) \033[0m"
-sleep 3
+
+if [ "$EUID" -ne 0 ]
+  then echo "Please run as root"
+  exit
+fi
+
+sleep 2
 apt-get --yes --force-yes install ufw
 # ufw allow ssh # knockd will open the ssh port
 ufw allow http

+ 7 - 1
bin/knockd.sh

@@ -10,7 +10,13 @@ echo '\033[35m
 /_/|_/_/ /_/\____/\___/_/|_|\__,_/
 \033[0m'
 echo "\033[35;1mInstalling knockd to control ssh port opening\033[0m"
-sleep 3
+
+if [ "$EUID" -ne 0 ]
+  then echo "Please run as root"
+  exit
+fi
+
+sleep 2
 apt-get --yes --force-yes install knockd
 
 mv /etc/knockd.conf /etc/knockd.conf.ori

+ 3 - 2
bin/lemp.sh

@@ -8,14 +8,15 @@ echo '\033[35m
 /_/\___/_/ /_/ /_/ .___/
                 /_/
 \033[0m'
-echo "\033[35;1mLEMP server (Nginx Mysql Php) \033[0m"
-sleep 3
+echo "\033[35;1mLEMP server (Nginx Mysql Php-fpm) \033[0m"
 
 if [ "$EUID" -ne 0 ]
   then echo "Please run as root"
   exit
 fi
 
+sleep 2
+
 echo '\033[35m
     __  ___                 __
    /  |/  /_  ___________ _/ /

+ 7 - 0
bin/misc.sh

@@ -10,8 +10,15 @@ echo '\033[35m
 /_/  /_/_/____/\___/
 
 \033[0m'
+
+if [ "$EUID" -ne 0 ]
+  then echo "Please run as root"
+  exit
+fi
+sleep 2
 apt-get --yes --force-yes install vim curl
 sed -i "s/^# en_GB.UTF-8/en_GB.UTF-8/g" /etc/locale.gen
 locale-gen
 apt-get --yes --force-yes install ntp
 dpkg-reconfigure tzdata
+apt-get --yes --force-yes install needrestart

+ 7 - 0
bin/upgrade.sh

@@ -9,5 +9,12 @@ echo '\033[35m
 / /_/ / ____/ /_/ / _, _/ ___ |/ /_/ / /___
 \____/_/    \____/_/ |_/_/  |_/_____/_____/
 \033[0m'
+
+if [ "$EUID" -ne 0 ]
+  then echo "Please run as root"
+  exit
+fi
+
 apt-get update
 apt-get dist-upgrade
+needrestart -rl

+ 6 - 0
bin/user.sh

@@ -8,6 +8,12 @@ echo '\033[35m
 \____//____/_____/_/ |_|
 \033[0m'
 echo "\033[35;1mCreate new user (you will be asked a user name and a password) \033[0m"
+
+if [ "$EUID" -ne 0 ]
+  then echo "Please run as root"
+  exit
+fi
+
 sleep 3
 
 # TODO check if root