5th September 2015, 21:42
#7
2 out of 2 members found this post helpful.
Un exemplu de script Bash pentru Debian.
Nu contine prostii, e foarte simplu, e adevarat e cam primitiv si mai trebuie lucrat un pic la el, finisat pe ici pe colo.
L-am facut din bucati, o bucata de cod de colo, o bucata din alta parte.
Creezi un fisier text ce contine codul de jos pe care il vei numi de exemplu " install-lamp-ajenti-smf " si vei avea grija sa il salvezi cu extensia .sh apoi il urci undeva.
Cod:
#!/bin/bash
if [ $EUID != 0 ]; then
echo "This script must be run as root (eg.: sudo ./install-lamp-ajenti-smf.sh)"
exit 1
fi
echo "***********************************************"
echo "1) Apache2, PHP, Ajenti Webserver Control Panel"
echo " "
echo "2) MySQL, phpMyAdmin and SMF on Debian 7 VPS"
echo "***********************************************"
echo "Upgrade your system to newer version"
echo "Press enter to continue"
read -r __foo
apt-get update && apt-get dist-upgrade
echo "******************************"
echo "1) Install Apache server & PHP"
echo "******************************"
echo "Press ENTER to continue"
read -r __foo
apt-get install apache2 apache2-utils && apt-get install vsftpd && apt-get install fail2ban && apt-get install nano && apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-mysql php-pear
echo "*******************"
echo "Configure localtime"
echo "*******************"
echo "Press ENTER to continue"
read -p "Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
dpkg-reconfigure tzdata
fi
echo "**********************************************************************"
echo "Before deleting default index.html page"
echo "open your public ip in a browser to see if apache is working properly"
echo "Delete the default index.html page "
echo "*********************************************************************"
echo "Press ENTER to continue"
read -r __foo
rm -rf /var/www/*
echo "*******************************************************"
echo "Install Ajenti Webserver Control Panel"
echo "You can use Ajenti Webserver Control Panel to configure"
echo "all your VPS config files, upload files and more"
echo "*******************************************************"
read -p "Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
wget -O- https://raw.github.com/Eugeny/ajenti/master/scripts/install-debian.sh | sh
fi
echo "***************************************************************"
echo "2) If you use only a static web page and no MySQL database"
echo "you can quit this step "
echo "***************************************************************"
echo "Install MySQL server & phpmyadmin"
echo "Configure database for phpmyadmin with dbconfig-common? <-- Yes"
echo "Secure your mysql installation"
echo "***************************************************************"
read -p "Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql && apt-get install phpmyadmin && mysql_install_db && /usr/bin/mysql_secure_installation
fi
echo "***************************************************************"
echo "Increase max phpmyadmin upload size from 2M to whatever"
echo "***************************************************************"
echo "fiind and change: upload_max_filesize = 2M"
read -p "Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
nano /etc/php5/apache2/php.ini
fi
echo "***************************************************************"
echo "Remove packages that are no more needed and clean the APT cache"
echo "***************************************************************"
echo "Press ENTER to continue"
read -r __foo
apt-get autoremove && apt-get autoclean
echo "************************************************"
echo "Download and unzip the SMF in /var/www directory"
echo "************************************************"
echo "Press ENTER to continue"
read -p "Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
cd /var/www
wget http://mirror.ord.simplemachines.org/downloads/smf_2-0-9_install.tar.gz
tar xvfz smf_2-0-9_install.tar.gz
rm -rf smf_2-0-9_install.tar.gz
fi
echo "******************************************************"
echo "Set directory and file permissions for SMF"
echo "******************************************************"
read -p "Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
cd /var/www
for dirs in attachments avatars cache Packages Packages/installed.list Smileys Themes agreement.txt Settings.php Settings_bak.php; do chmod 777 $dirs; done
fi
echo "******************************************************"
echo "Configure the vsftpd.conf"
echo "Copy this text into a text file before you press enter"
echo "anonymous_enable=YES -> change to NO"
echo "#local_enable=YES -> remove the #"
echo "#write_enable=YES -> remove the #"
echo "#chroot_local_user=YES -> remove the #"
echo "After you have finished press ctrl+x+Y+enter to save"
echo "******************************************************"
read -p "Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
nano /etc/vsftpd.conf
fi
echo "*************"
echo "Server Reboot"
echo "*************"
read -p "Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
reboot
fi
Dupa logare pe server ca root in terminal se introduce acest "cod" .
wget
Domeniu.com && chmod +x install-lamp-ajenti-smf.sh && ./install-lamp-ajenti-smf.sh
Sper sa nu sfarsesc ca Bruce Lee fiindca am dezvaluit "tainele ascunse" ale SysAdmin-ilor neinitiatilor in aceasta arta straveche.
Ultima modificare făcută de IulianC; 5th September 2015 la 22:02.