Apache-vhost: Auto-Complete installation, basic configuration
Complete the Add work of the virtual host by prompting for the domain name, Web site root, and other information
Service httpd Stop &>/dev/null
conf= "/usr/local/apache/conf/httpd.conf"
vhostconf= "/usr/local/apache/conf/extra/httpd-vhosts.conf"
Bin= "/usr/local/apache/bin/apachectl"
Rootdir=/www
Mkdir-p $rootdir
grep "Vhost" $conf | grep "#" &>/dev/null
If [$?-eq 0]; Then
vhost=$ (grep "vhost" $conf | sed "s/#//")
Sed-i '/vhost/d ' $conf &>/dev/null
echo "$vhost" >> $conf
echo "Namevirtualhost *:80" > $vhostconf
echo "<directory $rootdir >
Order Allow,deny
Allow from all
</Directory> ">> $vhostconf
Fi
While True
Do
Read-p "hostname of FDQN:" FDQN
Read-p "Directory of website:" SiteDir
Mkdir-p $rootdir/$sitedir/html
Mkdir-p $rootdir/$sitedir/logs
domain=$ (echo $fdqn | awk-f. ' {print $ '. $ $} ')
echo "<virtualhost *:80>
ServerAdmin [email protected] $domain
DocumentRoot $rootdir/$sitedir/html
ServerName $FDQN
Errorlog $rootdir/$sitedir/logs/error_log
Customlog $rootdir/$sitedir/logs/access_log Common
</VirtualHost> ">> $vhostconf
Read-p "continue to do? (yes/no) "yn
if [$yn = no];then
$bin Start &>/dev/null
Exit 0
Fi
Done
DHCP: Auto-Complete installation, basic configuration
: Complete scope additions by prompting for information such as network segment, subnet mask, gateway, DNS, IP start and end address, etc.
#!/bin/bash
conf= "/etc/dhcpd.conf"
Rpm-q DHCP &>/dev/null
If [$?-ne 0];then
Yum-y Install DHCP
Fi
grep "Subnet" $conf &>/dev/null
If [$?-ne 0]; Then
echo "
Ddns-update-style Interim;
Ignore client-updates;
Default-lease-time 21600;
Max-lease-time 43200;
"> $conf
Fi
Read-p "Please input network:" Network
Read-p "Please input netmask:" Netmask
Read-p "Please input gateway:" Gateway
Read-p "Please input DNS:" DNS
Read-p "Please input start_ip:" Start_ip
Read-p "Please input end_ip:" End_ip
echo "
Subnet $network netmask $netmask {
option routers $gateway;
Option Subnet-mask $netmask;
Option Domain-name-servers $dns;
Range DYNAMIC-BOOTP $start _ip $end _ip;
}
">> $conf
Service DHCPD Restart
DNS: Complete DNS basic configuration
According to the prompt input domain name, zone file name, record type, host header, IP address and other information to complete the work of adding fields and records
Conf=/var/named/chroot/etc/named.conf
Datadir=/var/named/chroot/var/named
Rpm-q bind &>/dev/null
If [$?-ne 0]; Then
Yum-y Install bind Bind-chroot caching-nameserver
Fi
if [!-F $conf];then
echo "Options {
Directory \ "/var/named\";
}; "> $conf
Fi
Read-p "Please input domain_name:" Domain
grep $domain $conf &>/dev/null
If [$?-ne 0]; Then
echo "zone \" $domain \ "in {
Type master;
File \ "$domain \";
}; ">> $conf
echo "\ $ttl 86400
@ in SOA ${domain}. Root.${domain}. (
2013010101
3h
15m
1w
1d
) "> $datadir/$domain
While True
Do
Read-p "type of Recond (ns/a/cname/mx/ptr):" Type
Case $type in
ns
echo $domain | grep "In-addr.arpa" &>/dev/null
If [$?-eq 0]; Then
Read-p "hostname of FDQN:" FDQN
echo "@ in NS $FDQN." >> $datadir/$domain
Else
Read-p "Head of hostname:" Head
echo "@inns$head" >> $datadir/$domain
Fi
;;
A
Read-p "Head of hostname:" Head
Read-p "IP address:" IP
echo "$headina$ip" >> $datadir/$domain
;;
ptr
Read-p "IP address:" IP
READ-P "hostname of FQDN:" FQDN
host=$ (echo $ip | awk-f. ' {print $4} ')
echo "$hostinptr$fqdn." >> $datadir/$domain
;;
mx
Read-p "Priority of Recond:" Priority
Read-p "Head of hostname:" Head
Read-p "IP address:" IP
echo "@inmx$priority$head" >> $datadir/$domain
echo "$headina$ip" >> $datadir/$domain
;;
CName
Read-p "Please input aliase:" Aliase
Read-p "Head of hostname:" Head
echo "$aliaseincname$head" >> $datadir/$domain
;;
Esac
Read-p "continue to Do (yes/no)?" yn
if [$yn = no]; Then
Exit 0
Fi
Done
Fi
VSFTPD: Close anonymous user logon, support local user login
Implement directory and permission settings by interactively entering user names, department names
The directory structure is as follows:
/data/public(Corporate Public directory, all employees are readable and writable, but cannot delete other people's files)
/data/Department Directory (department staff readable, departmental admin writable, others inaccessible)
/data/Department directory/user Directory
Note: The continue/break/exit is used in the instance script, the main purpose is to let everyone know the difference between the three
Conf=/etc/vsftpd/vsftpd.conf
Rpm-q vsftpd &>/dev/null
If [$?-ne 0]; Then
Yum-y Install VSFTPD
Sed-i ' s/anonymous_enable=yes/anonymous_enable=no/' $conf
echo "Local_root=/data" >> $conf
Mkdir-p/data/public
chmod 1777/data/public
Fi
While True
Do
Read-p "Please input username:" Username
Read-p "Please input bumen:" Bumen
Read-p "Is you sure?" (yes/no) "yn
if [$yn = no]; Then
Continue
Fi
if [!-d/data/$bumen]; Then
Mkdir-p/data/$bumen
Groupadd $bumen
Useradd-g $bumen-D/data/$bumen/${bumen}-adm ${bumen}-adm
echo "${bumen}-adm:123,qwe." | chpasswd
chage-d 0 ${bumen}-adm
Chown ${bumen}-adm: $bumen/data/$bumen
chmod o-rx/data/$bumen
Fi
grep "$username"/etc/passwd &>/dev/null
If [$?-ne 0]; Then
Useradd-g $bumen-D/data/$bumen/$username $username
echo "$username: 123456" | chpasswd
chage-d 0 $username
Else
echo "$username is exist."
Fi
Read-p "continue to yes/no?" yn
if [$yn = no]; Then
Break
Fi
Done
Service VSFTPD Status &>/dev/null
If [$?-eq 0]; Then
Exit 0
Else
Service VSFTPD Start
Fi
Server-install-shell