install.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #!/bin/sh
  2. # bachir soussi chiadmi
  3. #
  4. # http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
  5. # http://web-74.com/blog/reseaux/gerer-le-deploiement-facilement-avec-git/
  6. #
  7. echo -e '\033[35m
  8. ____ __ _ _____
  9. / __ \___ / /_ (_)___ _____ / ___/___ ______ _____ _____
  10. / / / / _ \/ __ \/ / __ `/ __ \ \__ \/ _ \/ ___/ | / / _ \/ ___/
  11. / /_/ / __/ /_/ / / /_/ / / / / ___/ / __/ / | |/ / __/ /
  12. /_____/\___/_.___/_/\__,_/_/ /_/ /____/\___/_/ |___/\___/_/
  13. \033[0m'
  14. echo -e "\033[35;1mThis script has been tested only on Linux Debian 10 \033[0m"
  15. if [ "$EUID" -ne 0 ]; then
  16. echo "Please run as root"
  17. exit
  18. fi
  19. echo -n "Should we start? [Y|n] "
  20. read yn
  21. yn=${yn:-y}
  22. if [ "$yn" != "y" ]; then
  23. echo "aborting script!"
  24. exit
  25. fi
  26. # get the current position
  27. _cwd="$(pwd)"
  28. . bin/upgrade.sh
  29. . bin/misc.sh
  30. . bin/firewall.sh
  31. . bin/fail2ban.sh
  32. # . bin/knockd.sh
  33. . bin/user.sh
  34. . bin/email.sh
  35. while [ "$securssh" != "yes" ] && [ "$securssh" != "no" ]
  36. do
  37. echo -n "Securing ssh (disabling root login)? [yes|no] "
  38. read securssh
  39. # securssh=${securssh:-y}
  40. done
  41. if [ "$securssh" = "yes" ]; then
  42. . bin/ssh.sh
  43. else
  44. echo 'root user can still conect through ssh'
  45. fi
  46. echo -n "Should we install ftp server? [Y|n] "
  47. read yn
  48. yn=${yn:-y}
  49. if [ "$yn" = "y" ]; then
  50. . bin/ftp.sh
  51. else
  52. echo 'ftp server not installed'
  53. fi
  54. while [ "$lemp" != "yes" ] && [ "$lemp" != "no" ]
  55. do
  56. echo -n "Should we install lemp ? [yes|no] "
  57. read lemp
  58. done
  59. if [ "$lemp" = "yes" ]; then
  60. . bin/lemp.sh
  61. else
  62. echo 'lemp server not installed'
  63. fi
  64. while [ "$_install_vhost" != "yes" ] && [ "$_install_vhost" != "no" ]
  65. do
  66. echo -n "Should we install a vhost ? [yes|no] "
  67. read _install_vhost
  68. done
  69. if [ "$_install_vhost" = "yes" ]; then
  70. # TODO bug vhost.sh file does not exists ...
  71. . bin/vhost.sh
  72. else
  73. echo 'no vhost installed'
  74. fi
  75. while [ "$_install_zabbix_agent" != "yes" ] && [ "$_install_zabbix_agent" != "no" ]
  76. do
  77. echo -n "Should we install zabbix-agent ? [yes|no] "
  78. read _install_zabbix_agent
  79. done
  80. if [ "$_install_zabbix_agent" = "yes" ]; then
  81. . bin/zabbix.sh
  82. else
  83. echo 'zabbix-agent not installed'
  84. fi
  85. while [ "$_install_urbackup" != "yes" ] && [ "$_install_urbackup" != "no" ]
  86. do
  87. echo -n "Should we install urbackup client ? [yes|no] "
  88. read _install_urbackup
  89. done
  90. if [ "$_install_urbackup" = "yes" ]; then
  91. . bin/urbackup.sh
  92. else
  93. echo 'urbackup client not installed'
  94. fi
  95. # ./install.sh: line 109: bin/dotfiles.sh: No such file or directory
  96. . bin/dotfiles.sh
  97. # . bin/autoupdate.sh
  98. # echo -e '\033[35m
  99. # ______________ _______
  100. # /_ __/ ____/ |/ / __ \
  101. # / / / __/ / /|_/ / /_/ /
  102. # / / / /___/ / / / ____/
  103. # /_/ /_____/_/ /_/_/
  104. # \033[0m'
  105. # function check_tmp_secured {
  106. # temp1=`grep -w "/var/tempFS /tmp ext3 loop,nosuid,noexec,rw 0 0" /etc/fstab | wc -l`
  107. # temp2=`grep -w "tmpfs /tmp tmpfs rw,noexec,nosuid 0 0" /etc/fstab | wc -l`
  108. # if [ $temp1 -gt 0 ] || [ $temp2 -gt 0 ]; then
  109. # return 1
  110. # else
  111. # return 0
  112. # fi
  113. # } # End function check_tmp_secured
  114. # function secure_tmp_tmpfs {
  115. # cp /etc/fstab /etc/fstab.bak
  116. # # Backup /tmp
  117. # cp -Rpf /tmp /tmpbackup
  118. # rm -rf /tmp
  119. # mkdir /tmp
  120. # mount -t tmpfs -o rw,noexec,nosuid tmpfs /tmp
  121. # chmod 1777 /tmp
  122. # echo "tmpfs /tmp tmpfs rw,noexec,nosuid 0 0" >> /etc/fstab
  123. # # Restore /tmp
  124. # cp -Rpf /tmpbackup/* /tmp/ >/dev/null 2>&1
  125. # #Remove old tmp dir
  126. # rm -rf /tmpbackup
  127. # # Backup /var/tmp and link it to /tmp
  128. # mv /var/tmp /var/tmpbackup
  129. # ln -s /tmp /var/tmp
  130. # # Copy the old data back
  131. # cp -Rpf /var/tmpold/* /tmp/ >/dev/null 2>&1
  132. # # Remove old tmp dir
  133. # rm -rf /var/tmpbackup
  134. # echo -e "\033[35;1m /tmp and /var/tmp secured using tmpfs. \033[0m"
  135. # } # End function secure_tmp_tmpfs
  136. # check_tmp_secured
  137. # if [ $? = 0 ]; then
  138. # secure_tmp_tmpfs
  139. # else
  140. # echo -e "\033[35;1mFunction canceled. /tmp already secured. \033[0m"
  141. # fi
  142. # TODO add warning message on ssh connection if system needs updates
  143. # TODO install and configure tmux
  144. echo -e '\033[35m
  145. __
  146. ___ ____ ____/ /
  147. / _ \/ __ \/ __ /
  148. / __/ / / / /_/ /
  149. \___/_/ /_/\__,_/
  150. \033[0m'
  151. echo -e "\033[35;1m* * script done * * \033[0m"