PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Konfigscript für CentOS by OCB



OCB
04.12.2011, 18:57
Ich habe mich die letzten 2 Tage mal hingesetzt und ein Bash-Script geschrieben für das automatische installieren und konfigurieren bestimmter Pakete und Dienste.
Das Skript ist für ein CentOS 64Bit geschrieben, für eine 32Bit Version müssten die Repositorys selbst konfiguriert werden.

Für das Konfigurieren von YUM und httpd läd das Script 2 tar Pakete aus dem Internet und überschreibt diese. Wer skeptisch ist, kann sich die Datein zuvor anschauen.
http://ocbslim.funpic.de/httpd.conf.tar
http://ocbslim.funpic.de/yum.repos.d.tar

Getestet habe ich das Skript nach einer CentOs 64Bit Minimal Installation. Sollte mit einer Basis oder Server Installation genauso funktionieren.

Der Ablauf ist wie folgt:
- Benutzer hinzufuegen
- Systemupdate
- Basisprogramme installieren
- YUM Konfiguration
- NTP installieren & einrichten
- httpd installieren & einrichten
- IpTables deaktivieren
- Mysql installieren & einrichten
- PHP installieren
- phpmyAdmin installieren und einrichten
- Sun JDK 7 installieren
- Tomcat6 installieren

Einfach mit chmod +x "Dateiname" ausführbar machen und let'z Fet'z
Downloadlink: http://ocbslim.funpic.de/ocb.sh
Hier ist der Code


#!/bin/bash
#Script zur Konfiguration eines 64Bit CentOs 6
#Written by OCB

#Systemvariablen
benutzer="OCB"
log="/tmp/config.log"
Konfigurationsdateinurl="http://ocbslim.funpic.de"

#Auswahl der Konfigurationskomponenten
checklist(){
echo "###--Dialogantworten--###" > $log
dialog --backtitle "Dialog - Konfigurationsauswahl" \
--checklist "Waehlen Sie Ihre Konfigurationsoptionen" 20 50 8 \
1 "Benutzer hinzufuegen" on \
2 "Systemupdate" on \
3 "Basisprogramme installieren" on \
4 "YUM Konfiguration" on \
5 "NTP installieren & einrichten" on \
6 "httpd installieren & einrichten" on \
7 "IpTables deaktivieren" on \
8 "Mysql installieren & einrichten" on \
9 "PHP installieren" on \
10 "phpmyAdmin installieren und einrichten" on \
11 "Sun JDK 7 installieren" on \
12 "Tomcat6 installieren" on 2>>$log
i=1
while [ $i -ne 13 ]; do
temp=`grep -c $i $log`
if [ $temp == 1 ]; then
ask[$i]="true";
fi
(( i++ )); unset temp
done
echo "Dialog-Phase beendet"
}
if [ `id -u` == 0 ]; then
cd /tmp
yum -y install dialog
checklist
if [ ${ask[1]} == "true" ]; then
sudo adduser $benutzer -G games,video,audio,cdrom,floppy,wheel -p OCB368
echo "Benutzer wurde hinzugefuegt" >>$log
fi
if [ ${ask[2]} == "true" ]; then
yum -y update
echo "System wurde geupdatet" >>$log
fi
if [ ${ask[3]} == "true" ]; then
yum -y install man wget
echo "Basisprogramme wurden installiert" >>$log
fi
if [ ${ask[4]} == "true" ]; then
yum -y install yum-plugin-priorities
cp -rfv /etc/yum.repos.d/ /etc/yum.repos.d.bak/
rm -rfv /etc/yum.repos.d/
wget $Konfigurationsdateinurl/yum.repos.d.tar
tar -xvf yum.repos.d.tar -C /etc
rm -rfv yum.repos.d.tar
echo check_obsoletes=1 >> /etc/yum/pluginconf.d/priorities.conf
echo "Yum-Priorits wurden installiert und Konfiguriert." >>$log
fi
if [ ${ask[5]} == "true" ]; then
yum -y install ntp
chkconfig --level 3456 ntpd on
echo "NTP wurde konfiguriert" >>$log
fi
if [ ${ask[6]} == "true" ]; then
yum -y install httpd
chkconfig --level 3456 httpd on
rm -rfv /etc/httpd/conf/httpd.conf
cd /etc/httpd/
wget $Konfigurationsdateinurl/httpd.conf.tar
tar -xvf httpd.conf.tar
rm -rfv httpd.conf.tar
service httpd start
echo "httpd wurde installiert und eingerichtet" >>$log
fi
if [ ${ask[7]} == "true" ]; then
service iptables stop
service ip6tables stop
chkconfig --level 0123456 iptables off
chkconfig --level 0123456 ip6tables off
echo "IPTables wurde deaktiviert" >>$log
fi
if [ ${ask[8]} == "true" ]; then
yum -y install mysql mysql-libs mysql-server
chkconfig --level 3456 mysqld on
service mysqld restart
echo "Mysql-Server wurde installiert und eingerichtet" >>$log
fi
if [ ${ask[9]} == "true" ]; then
yum -y install php php-cli php-common
service httpd restart
echo "php wurde installiert und eingerichtet" >>$log
fi
if [ ${ask[10]} == "true" ]; then
yum -y install phpMyAdmin
ln -s /usr/share/phpMyAdmin/ /var/www/html/phpMyAdmin
service httpd restart
echo "Phpmyadmin wurde installiert und eingerichtet" >>$log
fi
if [ ${ask[11]} == "true" ]; then
cd /tmp
wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.rpm
rpm -i jdk-7u1-linux-x64.rpm
echo "JDK wurde installiert und eingerichtet" >>$log
fi
if [ ${ask[12]} == "true" ]; then
yum -y install tomcat6
chkconfig --level 3456 tomcat6 on
echo "Tomcat wurde installiert und eingerichtet" >>$log
fi
echo "Konfiguration abgeschlossen."
echo "Ändern Sie das Standard-PW 'OCB368'"
echo "Erstellen Sie ein mysql-Root pw mit 'mysqladmin -u root -p password °WUNSCHPASSWORT°'"
echo "Passen sie die my.conf in /etc/httpd/conf.d/my.conf an"
echo "Wenn bei dem Befehl yum update, konfigurierte Pakete wie php,mysql,phpMyAdmin nicht geupdatet werden sollen, muss in der yum.conf der exclude befehl darauf angewiesen werden."
echo "Wenn phpMyAdmin installiert wurde, muss in der my.conf den Zugriff auf diesen Ordner auskommentiert werden"
echo "Außerdem kann ein Blick in den log nicht Schaden ("$log")"
echo "Viel Erfolg, OCB"
else
echo 'Führen Sie dieses Script mit root Rechten aus'
fi

SFX
04.12.2011, 19:50
- IpTables deaktivieren

haha

OCB
04.12.2011, 20:09
Du kannst den Punkt ja abwählen.
Mit der Firewall habe ich mich noch nicht beschäftigt und weil der Apache am Ende noch nicht ging, habe ich den Punkt da "Quick & Dirty" eingefügt.

Aber du hast schon Recht, ist jetzt das nicht das geilste :-D