Advertisement
tkopic123

TerraFormer (automatic server instalation)

Dec 8th, 2016
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.99 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #TerraFormer is an automatic server environment installer script
  4. #Run it using ./TerraFormer <option> or sh TerraFormer <option>  use --help for more info
  5. #Don't forget to "chmod +x" it
  6. #To get this script directly to your server use the following commands
  7. #
  8. # wget http://pastebin.com/raw/rTD74xCd && mv rTD74xCd TerraFormer && sudo apt-get install dos2unix && dos2unix TerraFormer && chmod +x TerraFormer && ./TerraFormer
  9. #
  10. #This script was written and tested on Debian 8 "Jessie"
  11.  
  12. #to do : Incremental backup,Database backup,fail2ban advanced settings
  13.  
  14. #DONE: Install the basics,setup hostnames,configure the webserver(mysql,php,...),configure e-mail server,configure security,FTP server,email S.M.A.R.T. reports,ISPConfig,postfix reconfiguration,Cool animations :) ,Full guided instalation,ETCKeeper,DNS...
  15.  
  16.  
  17. if [ -z $1 ]; then
  18.  
  19.     echo "TerraFormer:"
  20.     echo "Use --help for more info"
  21.     exit
  22. fi
  23.  
  24. if [ $1 = "--help" ]; then
  25.  
  26.     echo "-----------------------------------------------------------------------------------------------"
  27.     echo " The 'TerraFormer' script for automatic installation of the server enviroment on"
  28.     echo " Debian based systems,you must be root to run it,use --apache or --nginx to select"
  29.     echo " the webserver you want to use on your server"
  30.     echo " This script upgrades packages and installs everything you need to have an operational webserver"
  31.     echo " You can use --self-destruct to uninstall everything"
  32.     echo " It needs some manual settings explainded at the end"
  33.     echo " Note that the script is still under development and may not work as expected"
  34.     echo " written by tkopic"
  35.     echo "-----------------------------------------------------------------------------------------------"
  36.     exit
  37.  
  38. elif [ $1 = "--apache" ]; then
  39.  
  40.         websrv="apache2"
  41.  
  42. elif [ $1 = "--nginx" ]; then
  43.  
  44.         websrv="nginx"
  45.  
  46. elif [ $1 = "--self-destruct" ]; then
  47.  
  48.         for blow in 3 2 1
  49.         do
  50.             clear
  51.             echo "You can still CTRL + C!!!"
  52.             echo "self-destruct in" $blow
  53.             sleep 1
  54.         done
  55.  
  56. apt-get remove --purge postfix postfix-mysql postfix-doc mysql-client mysql-server openssl getmail4 rkhunter binutils dovecot-imapd dovecot-pop3d dovecot-mysql dovecot-sieve amavisd-new spamassassin clamav clamav-daemon zoo unzip bzip2 arj nomarch lzop cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl libnet-ident-perl zip libnet-dns-perl php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-memcached php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl memcached php-apc pure-ftpd-common pure-ftpd-mysql quota quotatool bind9 dnsutils nginx apache2
  57.        
  58.         sleep 1
  59.         clear
  60.         echo "BOOM!"
  61.         sleep 1
  62.         exit
  63.  
  64. else
  65.  
  66.     echo "Not sure what you want :/"
  67.     echo "You didn't read the --help,did you? >:("
  68.     exit
  69.  
  70. fi
  71.  
  72.  
  73. if [ "$(id -u)" != "0" ]; then
  74.  
  75.     echo "You are not root :("
  76.     echo "use TerraFormer --help for more info"
  77.     exit
  78.  
  79. fi
  80.  
  81.  
  82. echo "Thank you for using TerraFormer :)"
  83. echo "you have selected to install an $websrv server"
  84. sleep 2
  85.  
  86. for i in 1 2
  87. do
  88.     clear
  89.     echo "--------------------------------------------------------------------------"
  90.     echo "          Starting server enviroment installer script .                   "
  91.     echo "--------------------------------------------------------------------------"
  92.     sleep 0.3              
  93.     clear
  94.     echo "--------------------------------------------------------------------------"
  95.     echo "          Starting server enviroment installer script ..                  "
  96.     echo "--------------------------------------------------------------------------"
  97.     sleep 0.3
  98.     clear
  99.     echo "--------------------------------------------------------------------------"
  100.     echo "          Starting server enviroment installer script ...                 "
  101.     echo "--------------------------------------------------------------------------"
  102.     sleep 0.3
  103. done
  104.  
  105. clear
  106. echo "If this is the first time you are running this script on this server press enter"
  107. echo "However if this is the second time and you already configured the hostnames just type 'skip'"
  108. read cnf3
  109.  
  110. if [ "$cnf3" = "skip" ]; then
  111.  
  112.     echo "Skipping the upgrade process... server installation executing"
  113.     sleep 2
  114.  
  115. else
  116.  
  117.     clear
  118.     echo "Talking to the universe..."
  119.     echo "--------------------------"
  120.     sleep 2
  121.     apt-get update
  122.     wait   
  123.     sleep 1
  124.  
  125.     clear
  126.     echo "Universe responded,upgrading..."
  127.     echo "-------------------------------"
  128.     sleep 2
  129.     apt-get upgrade -y
  130.     wait
  131.     sleep 1
  132.  
  133.     clear
  134.     echo "Creating basic enviroment"
  135.     echo "-------------------------"
  136.     sleep 2
  137.     apt-get install -y ssh openssh-server vim-nox nano ntp ntpdate sudo aptitude
  138.     wait
  139.     sleep 1
  140.  
  141.     clear
  142.     echo "Basic enviroment created,do you wish to change the hostname?[y/n] current hostame:" $(hostname)
  143.     read cnf2
  144.  
  145.     if [ "$cnf2" = "n" ]; then
  146.  
  147.         echo "Yeah,i liked that name too"
  148.         sleep 1
  149.  
  150.     else
  151.  
  152.         nano /etc/hosts
  153.         nano /etc/hostname
  154.         wait
  155.  
  156.         echo "Reboot is required to apply these changes.Run this script again after the reboot"
  157.         sleep 5
  158.         echo "Do you want to reboot now? [y/n]"
  159.         read cnfr
  160.  
  161.         if [ "$cnfr" = "y" ]; then
  162.  
  163.             reboot
  164.  
  165.         else
  166.  
  167.             echo "Skipping reboot,you should reboot manualy"
  168.             exit
  169.  
  170.        
  171.         fi
  172.  
  173.     fi
  174.  
  175. fi
  176.  
  177.  
  178.  
  179. #Second phase loading animation
  180.  
  181. for i in 1 2
  182. do
  183.     clear
  184.     echo "Installing server"
  185.     sleep 0.5
  186.     clear
  187.     echo "Installing server."
  188.     sleep 0.5
  189.     clear
  190.     echo "Installing server.."
  191.     sleep 0.5
  192.     clear
  193.     echo "Installing server..."
  194.     sleep 0.5
  195. done
  196.  
  197. #installing the server
  198.  
  199. clear
  200.  
  201. #Dash script reconfigure
  202. echo "It is recomended to select 'no' for dash"
  203. sleep 2
  204.  
  205. dpkg-reconfigure dash
  206. wait
  207.  
  208. #Installing mysql,postfix,rkhunter...
  209. echo "installing server environment basics"
  210. sleep 2
  211. apt-get install -y postfix postfix-mysql postfix-doc mysql-client mysql-server openssl getmail4 binutils dovecot-imapd dovecot-pop3d dovecot-mysql dovecot-sieve
  212. wait
  213.  
  214.  
  215. #Configuring Postfix
  216. clear
  217. echo "Next you are going to configure postfix"
  218. sleep 2
  219. echo "Note that auto is still testing and if you use it you should manualy check the file"
  220. echo "Enter 'y' to set it up automatically,or 'n' to do it manualy?[y/n]"
  221. read cnf10
  222.  
  223. #Automatized postfix config
  224. if [ "$cnf10" = "y" ]; then
  225.  
  226.     #still testing it
  227.     sed -i -- 's/#  -o syslog_name=postfix/-o syslog_name=postfix/g' /etc/postfix/master.cf
  228.     sed -i -- 's/#submission/submission/g' /etc/postfix/master.cf
  229.     sed -i -- 's/#  -o smtpd_tls_security_level=encrypt/-o smtpd_tls_security_level=encrypt/g' /etc/postfix/master.cf
  230.     sed -i -- 's/#  -o smtpd_sasl_auth_enable=yes/-o smtpd_sasl_auth_enable=yes/g' /etc/postfix/master.cf
  231.     sed -i -- 's/#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject/-o smtpd_client_restrictions=permit_sasl_authenticated,reject/g' /etc/postfix/master.cf
  232.     sed -i -- 's/#smtps/smtps/g' /etc/postfix/master.cf
  233.     sed -i -- 's/#  -o syslog_name=postfix/-o syslog_name=postfix/g' /etc/postfix/master.cf
  234.     sed -i -- 's/#  -o smtpd_tls_wrappermode=yes/-o smtpd_tls_wrappermode=yes   /g' /etc/postfix/master.cf
  235.     sed -i -- 's/#  -o smtpd_sasl_auth_enable=yes/-o smtpd_sasl_auth_enable=yes/g' /etc/postfix/master.cf
  236.     sed -i -- 's/#  -o smtpd_client_restrictions/-o smtpd_client_restrictions/g' /etc/postfix/master.cf
  237.     wait
  238.  
  239. else
  240.  
  241.     nano /etc/postfix/master.cf
  242.     wait
  243.  
  244. fi
  245.  
  246.  
  247. echo "Restarting postfix to apply the configuration"
  248. sleep 1
  249. /etc/init.d/postfix restart
  250. wait
  251. sleep 2
  252.  
  253. clear
  254.  
  255. #Animation
  256.  
  257. for rp0 in 1 2 3
  258. do
  259.     for my0 in "Configuring MySQL" "Configuring MySQL." "Configuring MySQL.." "Configuring MySQL..."
  260.     do
  261.         clear
  262.         echo  $my0
  263.         sleep 0.2
  264.     done
  265. done
  266.  
  267.  
  268. #Open mysql to the outside
  269. sed -i -- 's/bind-address/#bind-address/g' /etc/mysql/my.cnf
  270. echo "Done! Restarting MySQL service"
  271. sleep 1
  272. /etc/init.d/mysql restart
  273. wait
  274.  
  275. sleep 2
  276. for rp1 in 1 2 3
  277. do  
  278.     for my1 in "Setting up malware protection" "Setting up malware protection." "Setting up malware protection.." "Setting up malware protection..."
  279.     do     
  280.         clear
  281.         echo  $my1
  282.         sleep 0.2
  283.     done
  284. done
  285.  
  286.  
  287. apt-get install -y amavisd-new clamav clamav-daemon zoo unzip bzip2 arj nomarch lzop cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl libnet-ident-perl zip libnet-dns-perl
  288. wait
  289.  
  290. echo "Do you wish to install spamassassin?[y/n]"
  291. read cnfspam
  292.  
  293. if [ "$cnfspam" = "y" ]; then
  294.  
  295.     apt-get install spamassassin
  296.     wait
  297.    
  298. else
  299.  
  300.     echo "Skipping"
  301.     sleep 1
  302.  
  303. fi
  304.  
  305. echo "Do you wish to install rkhunter?[y/n]"
  306. read cnfrkh
  307.  
  308. if [ "$cnfrkh" = "y" ]; then
  309.  
  310.     apt-get install rkhunter
  311.     wait
  312.  
  313. echo
  314.  
  315.     echo "Skipping"
  316.     sleep 1
  317.  
  318. fi 
  319.  
  320.  
  321. sleep 1
  322. for rp2 in 1 2 3
  323. do
  324.     for my2 in "Setting up $websrv" "Setting up $websrv." "Setting up $websrv.." "Setting up $websrv..."
  325.     do
  326.         clear
  327.         echo  $my2
  328.         sleep 0.2
  329.     done
  330. done
  331.  
  332. #Webserver instalation
  333. apt-get install -y $websrv
  334. wait
  335.  
  336. echo "Starting $websrv"
  337. /etc/init.d/$websrv start
  338.  
  339. sleep 1
  340. for rp3 in 1 2 3
  341. do
  342.     for my3 in "Setting up PHP" "Setting up PHP." "Setting up PHP.." "Setting up PHP..."
  343.     do
  344.         clear
  345.         echo  $my3
  346.         sleep 0.2
  347.     done
  348. done
  349.  
  350. apt-get install -y php5-fpm
  351.  
  352. wait
  353.  
  354. apt-get install -y php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-memcached php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl memcached php-apc
  355.  
  356. wait
  357.  
  358. echo "Do you wish to install phpbrew?[y/n]"
  359. read cnfphpb
  360.  
  361. if [ "$cnfphpb" = "y" ]; then
  362.  
  363.     apt-get install curl
  364.     wait
  365.     curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
  366.     wait
  367.     chmod +x phpbrew
  368.     wait
  369.     mv phpbrew /usr/bin/phpbrew
  370.  
  371. else
  372.  
  373.     echo "Skipping"
  374.     sleep 1
  375.  
  376. fi
  377.  
  378. sleep 1
  379. for rp4 in 1 2 3
  380. do
  381.     for my4 in "Setting up PHP timezones" "Setting up PHP timezones." "Setting up PHP timezones.." "Setting up PHP timezones..."
  382.     do
  383.         clear
  384.         echo  $my4
  385.         sleep 0.2
  386.     done
  387. done
  388.  
  389. sed -i -- 's/cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini
  390. sed -i -- 's/;cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini
  391. sed -i -- 's/;date.timezone =/date.timezone = "GMT0"/g' /etc/php5/fpm/php.ini
  392.  
  393. apt-get install -y fcgiwrap
  394. wait
  395. /etc/init.d/fcgiwrap start
  396. wait
  397.  
  398. clear
  399.  
  400. #Optional installs
  401. echo "Do you wish to install phpmyadmin? [y/n]"
  402. read cnf100
  403. if [ "$cnf100" = "y" ]; then
  404.  
  405.     apt-get install -y phpmyadmin
  406.     wait
  407. else
  408.  
  409.     sleep 0.2
  410.  
  411. fi
  412.  
  413. clear
  414. echo "Do you wish to install mailman? [y/n]"
  415. read cnf101
  416.  
  417. if [ "$cnf101" = "y" ]; then
  418.  
  419.     apt-get install -y mailman
  420.     wait
  421. else
  422.  
  423.     sleep 0.2
  424.  
  425. fi
  426.  
  427. sleep 1
  428.  
  429. for rp5 in 1 2 3
  430. do
  431.     for my5 in "Setting up FTP" "Setting up FTP." "Setting up FTP.." "Setting up FTP..."
  432.     do
  433.         clear
  434.         echo  $my5
  435.         sleep 0.2
  436.     done
  437. done
  438.  
  439. apt-get install -y pure-ftpd-common pure-ftpd-mysql quota quotatool
  440. wait
  441.  
  442. sed -i -- 's/VIRTUALCHROOT=false/VIRTUALCHROOT=true/g' /etc/default/pure-ftpd-common
  443.  
  444. wait
  445.  
  446. sleep 1
  447. echo "Starting FTP session"
  448. sleep 1
  449. echo 1 > /etc/pure-ftpd/conf/TLS
  450. wait
  451. mkdir -p /etc/ssl/private/
  452. wait
  453. openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem
  454. wait
  455. chmod 600 /etc/ssl/private/pure-ftpd.pem
  456. wait
  457. /etc/init.d/pure-ftpd-mysql restart
  458. wait
  459. echo "Session created"
  460. sleep 1
  461.  
  462. sleep 1
  463. for rp6 in 1 2 3
  464. do
  465.     for my6 in "Setting up DNS" "Setting up DNS." "Setting up DNS.." "Setting up DNS..."
  466.     do
  467.         clear
  468.         echo  $my6
  469.         sleep 0.2
  470.     done
  471. done
  472.  
  473. apt-get install -y bind9 dnsutils
  474. wait
  475.  
  476. sleep 1
  477.  
  478.  
  479. clear
  480. echo "Do you wish to install fail2ban?[y/n]"
  481. read cnfftb2
  482.  
  483. if [ "$cnfftb2" = "y" ]; then
  484.    
  485.     apt-get install -y fail2ban
  486.     wait
  487.     clear
  488.     echo "Do you wish setup an automatic fail2ban security policy?[y/n]"
  489.     read cnfftb
  490.  
  491.     if [ "$cnfftb" = "y" ]; then
  492.  
  493.         echo "Setting up fail2ban security policy"
  494.         sleep 1
  495.        
  496.         echo "Populating /etc/fail2ban/jail.local"
  497.         sleep 1
  498.         echo "  [pureftpd]                                                 
  499.             enabled  = true                                                
  500.             port     = ftp                                                 
  501.             filter   = pureftpd                                            
  502.             logpath  = /var/log/syslog                                         
  503.             maxretry = 3                                                   
  504.                                                                    
  505.             [dovecot-pop3imap]                                             
  506.             enabled = true                                                 
  507.             filter = dovecot-pop3imap                                          
  508.             action = iptables-multiport[name=dovecot-pop3imap, port="pop3,pop3s,imap,imaps", protocol=tcp]         
  509.             logpath = /var/log/mail.log                                        
  510.             maxretry = 5                                                   
  511.                                                                    
  512.             [sasl]                                                     
  513.             enabled  = true                                                
  514.             port     = smtp                                                
  515.             filter   = sasl                                                
  516.             logpath  = /var/log/mail.log                                           
  517.             maxretry = 3" > /etc/fail2ban/jail.local
  518.        
  519.         echo "Writing to /etc/fail2ban/filter.d/pureftpd.conf"
  520.         sleep 1
  521.        
  522.             echo "[Definition]                                     
  523.             failregex = .*pure-ftpd: \(.*@<HOST>\) \[WARNING\] Authentication failed for user.*
  524.             ignoreregex =                                      
  525.                             " > /etc/fail2ban/filter.d/pureftpd.conf
  526.        
  527.         echo "Rewriting /etc/fail2ban/filter.d/dovecot-pop3imap.conf"
  528.         sleep 1
  529.  
  530.         echo "[Definition]
  531.         failregex = (?: pop3-login|imap-login): .*(?:Authentication failure|Aborted login \(auth failed|Aborted login \(tried to use disabled|Disconnected \(auth failed    Aborted login \(\d+ authentication attempts).*rip=(?P<host>\S*),.*
  532. ignoreregex =" > /etc/fail2ban/filter.d/dovecot-pop3imap.conf
  533.  
  534.         echo "Restarting fail2ban"
  535.         sleep 1    
  536.         /etc/init.d/fail2ban restart
  537.         wait
  538.         echo "All done!"
  539.         sleep 1
  540.     fi
  541. else
  542.     sleep 0.2
  543. fi
  544.  
  545.  
  546. sleep 1
  547. clear
  548. echo "Do you wish to install zabbix-agent? [y/n]"
  549. read cnfzab
  550.  
  551. if [ "$cnfzab" = "y"  ]; then
  552.  
  553.     for rp10 in 1 2 3
  554.     do
  555.         for my10 in "Setting up Zabbix" "Setting up Zabbix." "Setting up Zabbix.." "Setting up Zabbix..."
  556.         do
  557.         clear
  558.         echo  $my10
  559.         sleep 0.2
  560.         done
  561.     done
  562.  
  563.     clear
  564.     echo "Setting up repos"
  565.     sleep 1
  566.     wget http://repo.zabbix.com/zabbix/3.0/debian/pool/main/z/zabbix-release/zabbix-release_3.0-1+jessie_all.deb
  567.     wait
  568.     dpkg -i zabbix-release_3.0-1+jessie_all.deb
  569.     wait
  570.     apt-get update
  571.     wait
  572.     apt-get install -y zabbix-agent
  573.     wait
  574.     clear
  575.     echo "Please setup servers for your zabbix agent:"
  576.     sleep 5
  577.     nano /etc/zabbix/zabbix_agentd.conf
  578.     wait
  579.     echo "Opening port 10050"
  580.     sleep 1
  581.     sudo iptables -A INPUT -p tcp --dport 10050 -j ACCEPT
  582.     sudo iptables -A OUTPUT -p tcp --dport 10050 -j ACCEPT
  583.     wait
  584.     /etc/init.d/zabbix-agent restart
  585.     wait
  586.     rm -rf zabbix-release_3.0-1+jessie_all.deb
  587.     echo "Zabbix installed!"
  588. else
  589.  
  590.     sleep 1
  591.  
  592. fi
  593.  
  594. sleep 1
  595. clear
  596. echo "Do you wish to install ETCKeeper?[y/n]"
  597. read cnfetc
  598.  
  599. if [ "$cnfetc" = "y" ]; then
  600.  
  601.     echo "Installing"
  602.     sleep 1
  603.     apt-get install -y git git-core etckeeper
  604.     wait
  605.     echo "Making sure ETCKeeper runs with git"
  606.     sleep 1
  607.     sed -i -- 's/VCS="bzr"/#VCS="bzr"/g' /etc/etckeeper/etckeeper.conf
  608.     sed -i -- 's/#VCS="git"/VCS="git"/g' /etc/etckeeper/etckeeper.conf
  609.     wait
  610.     clear
  611.     echo "Please create a git project for this server,you need to configure it for git manually after the installation,sorry :("
  612.     sleep 5
  613.    
  614. else
  615.  
  616. echo "Skipping"
  617. sleep 0.5
  618.  
  619. fi 
  620.  
  621.  
  622. sleep 1
  623. clear
  624. echo "Do you wish to install ISPConfig?[y/n]"
  625. read cnfisp
  626.  
  627. if [ "$cnfisp" = "y" ]; then
  628.  
  629.     wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
  630.     wait   
  631.     tar xfz ISPConfig-3-stable.tar.gz
  632.     wait   
  633.     php -q ispconfig3_install/install/install.php
  634.     wait
  635.     sleep 2
  636.     echo "Removing ISPConfig leftovers"
  637.     sleep 1
  638.     rm -rf ISPConfig-3-stable.tar.gz ispconfig3_install/
  639.     echo "Removed!"
  640.     sleep 1
  641.  
  642.  
  643. else
  644.    
  645.     echo " y u no install :( "
  646.     sleep 3
  647.  
  648. fi
  649.  
  650.  
  651. #S.M.A.R.T. script
  652. clear
  653. echo "Do you wish to setup e-mail S.M.A.R.T. disk reporting?[y/n]"
  654. read cnfsma
  655.  
  656. if [ "$cnfsma" = "y" ]; then
  657.  
  658.     echo '
  659. #/bin/bash
  660.  
  661.  
  662. # get server hostname
  663. # if Debian use
  664. hostname=`cat /etc/hostname`
  665.  
  666.  
  667. yourEmail="<yourmail here>"
  668.  
  669.  
  670. fileEmail="smart_result_$hostname.txt"
  671.  
  672.  
  673. # check server disk sda
  674. # check server disk sdb
  675. /usr/sbin/smartctl -a /dev/sda > $fileEmail
  676. /usr/sbin/smartctl -a /dev/sdb >> $fileEmail
  677.  
  678.  
  679.  
  680.  
  681. cat $fileEmail | mail -s "Daily smart disk check on $hostname - `date +'%F'`" "$yourEmail"
  682.  
  683. ' > /root/smart.sh
  684.     wait
  685.     chmod +x /root/smart.sh
  686.     wait
  687.     clear
  688.     echo "You need to set emails for the script and add it to the crontab,it is located in /root/smart.sh"
  689.     sleep 5
  690.     echo "Do you wish to do it now?[y/n]"
  691.     read cnfsmt2
  692.  
  693.     if [ "$cnfsmt2" = "y" ]; then
  694.  
  695.         nano /root/smart.sh
  696.         wait
  697.         crontab -e
  698.         wait
  699.     else
  700.  
  701.     echo "Set it up manually then"
  702.     sleep 2
  703.    
  704.     fi
  705.  
  706. else
  707.  
  708.     echo "Skipping"
  709.     sleep 1
  710.  
  711. fi
  712.  
  713. sleep 1
  714. clear
  715. sleep 1
  716.  
  717. echo "Do you wish to setup auto updates? [y/n]"
  718. read cnfauto
  719.  
  720. if [ "$cnfauto" = "y" ]; then
  721.  
  722.     apt-get install unattended-upgrades
  723.     wait
  724.     sleep 1
  725.    
  726.     echo "The default setting should work fine but it is recommended to read the file and tweak it"
  727.     sleep 1
  728.     echo "Do you want to do it now?[y/n]"
  729.     read cnfauto2
  730.    
  731.     if [ "$cnfauto2" = "y" ]; then
  732.        
  733.         nano /etc/apt/apt.conf.d/50unattended-upgrades
  734.         wait
  735.  
  736.     else
  737.    
  738.     echo "As you wish"
  739.     sleep 1
  740.  
  741.     fi
  742.  
  743. echo "Activating auto upgrades..."
  744. dpkg-reconfigure -plow unattended-upgrades
  745. wait
  746.  
  747.  
  748. else
  749.  
  750.     echo "Skipping"
  751.     sleep 1
  752.  
  753. fi
  754.  
  755.  
  756. clear
  757. sleep 1
  758. echo "Do you wish to disable ssh root login?[y/n]"
  759. read cnfssh
  760.  
  761. if [ "$cnfssh" = "y" ]; then
  762.  
  763.     sed -i -- 's/PermitRootLogin without-password/PermitRootLogin no/g' /etc/ssh/sshd_config
  764.     wait
  765.     sed -i -- 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
  766.     wait
  767.     sleep 1
  768.    
  769.    
  770.     echo "Restarting ssh..."
  771.     sleep 1
  772.     /etc/init.d/ssh restart
  773.     wait
  774.  
  775.     echo "Done! you should change the ssh port too"
  776.     sleep 2
  777.  
  778. else
  779.  
  780.     echo "This is a recommended security measure,but ok,you can edit it later at /etc/ssh/sshd_config"
  781.     sleep 2
  782.  
  783. fi
  784.  
  785. #This is the last step and it should be the last step so don't move it
  786. clear
  787. echo "Reconfiguring postfix"
  788. sleep 2
  789. dpkg-reconfigure postfix
  790. wait
  791.  
  792. for en in 1 2
  793. do
  794.  
  795. clear
  796.     echo "xxxxxxxxxxxxxxxxx"
  797.     echo " Congratulations "
  798.     echo "xxxxxxxxxxxxxxxxx"
  799.     sleep 0.1
  800. clear
  801.     echo "Xxxxxxxxxxxxxxxxx"
  802.     echo " Congratulations "
  803.     echo "xxxxxxxxxxxxxxxxX"
  804.     sleep 0.1
  805. clear
  806.     echo "xXxxxxxxxxxxxxxxx"
  807.     echo " Congratulations "
  808.     echo "xxxxxxxxxxxxxxxXx"
  809.     sleep 0.1
  810. clear
  811.     echo "xxXxxxxxxxxxxxxxx"
  812.     echo " Congratulations "
  813.     echo "xxxxxxxxxxxxxxXxx"
  814.     sleep 0.1
  815. clear
  816.     echo "xxxXxxxxxxxxxxxxx"
  817.     echo " Congratulations "
  818.     echo "xxxxxxxxxxxxxXxxx"
  819.     sleep 0.1
  820. clear
  821.     echo "xxxxXxxxxxxxxxxxx"
  822.     echo " Congratulations "
  823.     echo "xxxxxxxxxxxxXxxxx"
  824.     sleep 0.1
  825. clear
  826.     echo "xxxxxXxxxxxxxxxxx"
  827.     echo " Congratulations "
  828.     echo "xxxxxxxxxxxXxxxxx"
  829.     sleep 0.1
  830. clear
  831.     echo "xxxxxxXxxxxxxxxxx"
  832.     echo " Congratulations "
  833.     echo "xxxxxxxxxxXxxxxxx"
  834.     sleep 0.1
  835. clear
  836.     echo "xxxxxxxXxxxxxxxxx"
  837.     echo " Congratulations "
  838.     echo "xxxxxxxxxXxxxxxxx"
  839.     sleep 0.1
  840. clear
  841.     echo "xxxxxxxxXxxxxxxxx"
  842.     echo " Congratulations "
  843.     echo "xxxxxxxxXxxxxxxxx"
  844.     sleep 0.1
  845. clear
  846.     echo "xxxxxxxxxXxxxxxxx"
  847.     echo " Congratulations "
  848.     echo "xxxxxxxXxxxxxxxxx"
  849.     sleep 0.1
  850. clear
  851.     echo "xxxxxxxxxxXxxxxxx"
  852.     echo " Congratulations "
  853.     echo "xxxxxxXxxxxxxxxxx"
  854.     sleep 0.1
  855. clear
  856.     echo "xxxxxxxxxxxXxxxxx"
  857.     echo " Congratulations "
  858.     echo "xxxxxXxxxxxxxxxxx"
  859.     sleep 0.1
  860. clear
  861.     echo "xxxxxxxxxxxxXxxxx"
  862.     echo " Congratulations "
  863.     echo "xxxxXxxxxxxxxxxxx"
  864.     sleep 0.1
  865. clear
  866.     echo "xxxxxxxxxxxxxXxxx"
  867.     echo " Congratulations "
  868.     echo "xxxXxxxxxxxxxxxxx"
  869.     sleep 0.1
  870. clear
  871.     echo "xxxxxxxxxxxxxxXxx"
  872.     echo " Congratulations "
  873.     echo "xxXxxxxxxxxxxxxxx"
  874.     sleep 0.1
  875. clear
  876.     echo "xxxxxxxxxxxxxxxXx"
  877.     echo " Congratulations "
  878.     echo "xXxxxxxxxxxxxxxxx"
  879.     sleep 0.1
  880. clear
  881.     echo "xxxxxxxxxxxxxxxxX"
  882.     echo " Congratulations "
  883.     echo "Xxxxxxxxxxxxxxxxx"
  884.     sleep 0.1
  885.  
  886. done   
  887.  
  888. clear
  889. echo "------------------------------------------------------------------------"
  890. echo "your server is all set up,or at least it should be..."
  891. sleep 2
  892. echo "You should now add users for your server"
  893. sleep 2
  894. echo "Please note that this script is still under development"
  895. sleep 2
  896. echo "and you should still manualy check if everything was installed correctly."
  897. sleep 2
  898. echo "Feel free to send me bugs and errors that might have slipped by   "
  899. echo "on my e-mail tomislav.kopic@orion-web.hr,thank you!"
  900. sleep 2
  901. echo "Bye,Good luck with your server :)"
  902.  
  903.  
  904. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement