1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/yumho-renhao

Клонировать/Скачать
damnp-actgod.sh 27 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
rensir Отправлено 30.12.2014 17:23 b999a57
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
#!/bin/bash
function check_install {
if [ -z "`which "$1" 2>/dev/null`" ]
then
executable=$1
shift
while [ -n "$1" ]
do
DEBIAN_FRONTEND=noninteractive apt-get -q -y --force-yes install "$1"
print_info "$1 installed for $executable"
shift
done
else
print_warn "$2 already installed"
fi
}
function check_remove {
if [ -n "`which "$1" 2>/dev/null`" ]
then
DEBIAN_FRONTEND=noninteractive apt-get -q -y remove --purge "$2"
print_info "$2 removed"
else
print_warn "$2 is not installed"
fi
}
function check_sanity {
# Do some sanity checking.
if [ $(/usr/bin/id -u) != "0" ]
then
die 'Must be run by root user'
fi
if [ ! -f /etc/debian_version ]
then
die "Distribution is not supported"
fi
}
function die {
echo "ERROR: $1" > /dev/null 1>&2
exit 1
}
function get_domain_name() {
# Getting rid of the lowest part.
domain=${1%.*}
lowest=`expr "$domain" : '.*\.\([a-z][a-z]*\)'`
case "$lowest" in
com|net|org|gov|edu|co)
domain=${domain%.*}
;;
esac
lowest=`expr "$domain" : '.*\.\([a-z][a-z]*\)'`
[ -z "$lowest" ] && echo "$domain" || echo "$lowest"
}
function get_password() {
# Check whether our local salt is present.
SALT=/var/lib/radom_salt
if [ ! -f "$SALT" ]
then
head -c 512 /dev/urandom > "$SALT"
chmod 400 "$SALT"
fi
password=`(cat "$SALT"; echo $1) | md5sum | base64`
echo ${password:0:13}
}
function install_dash {
check_install dash dash
rm -f /bin/sh
ln -s dash /bin/sh
}
function install_dropbear {
check_install dropbear dropbear
check_install /usr/sbin/xinetd xinetd
# Disable SSH
touch /etc/ssh/sshd_not_to_be_run
invoke-rc.d ssh stop
# Enable dropbear to start. We are going to use xinetd as it is just
# easier to configure and might be used for other things.
cat > /etc/xinetd.d/dropbear <<END
service dropbear
{
socket_type = stream
only_from = 0.0.0.0
wait = no
user = root
protocol = tcp
server = /usr/sbin/dropbear
server_args = -i
disable = no
port = 22
type = unlisted
}
END
invoke-rc.d xinetd restart
}
function install_exim4 {
check_install mail exim4
if [ -f /etc/exim4/update-exim4.conf.conf ]
then
sed -i \
"s/dc_eximconfig_configtype='local'/dc_eximconfig_configtype='internet'/" \
/etc/exim4/update-exim4.conf.conf
invoke-rc.d exim4 restart
fi
}
function install_mysql {
# Install the MySQL packages
check_install mysqld mysql-server
check_install mysql mysql-client
# all the related files.
invoke-rc.d mysql stop
rm -f /var/lib/mysql/ib*
cat > /etc/mysql/conf.d/actgod.cnf <<END
[mysqld]
key_buffer = 8M
query_cache_size = 0
skip-innodb
END
invoke-rc.d mysql start
# Generating a new password for the root user.
passwd=`get_password root@mysql`
mysqladmin password "$passwd"
cat > ~/.my.cnf <<END
[client]
user = root
password = $passwd
END
chmod 600 ~/.my.cnf
}
function install_nginx {
check_install nginx nginx
# Need to increase the bucket size for Debian 5.
if [ ! -d /etc/nginx ];
then
mkdir /etc/nginx
fi
if [ ! -d /etc/nginx/conf.d ];
then
mkdir /etc/nginx/conf.d
fi
cat > /etc/nginx/conf.d/actgod.conf <<END
client_max_body_size 20m;
server_names_hash_bucket_size 64;
END
sed -i s/'^worker_processes [0-9];'/'worker_processes 1;'/g /etc/nginx/nginx.conf
invoke-rc.d nginx restart
if [ ! -d /var/www ];
then
mkdir /var/www
fi
cat > /etc/nginx/proxy.conf <<EXND
proxy_connect_timeout 30s;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_set_header Host \$host;
proxy_set_header Referer \$http_referer;
proxy_set_header Cookie \$http_cookie;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
EXND
}
function install_php {
apt-get -q -y --force-yes install php5-cli php5-mysql php5-gd
}
function install_apache {
apt-get -q -y --force-yes install apache2 libapache2-mod-php5 libapache2-mod-rpaf
sed -i s/'NameVirtualHost \*:80'/'NameVirtualHost \*:168'/g /etc/apache2/ports.conf
sed -i s/'Listen 80'/'Listen 127.0.0.1:168'/g /etc/apache2/ports.conf
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.old
cat > /etc/apache2/apache2.conf <<EXNDDQW
LockFile \${APACHE_LOCK_DIR}/accept.lock
PidFile \${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 2
MaxSpareServers 2
MaxClients 3
MaxRequestsPerChild 10000
</IfModule>
User \${APACHE_RUN_USER}
Group \${APACHE_RUN_GROUP}
AccessFileName .htaccess
DefaultType text/plain
HostnameLookups Off
ErrorLog \${APACHE_LOG_DIR}/error.log
LogLevel warn
Include mods-enabled/*.load
Include mods-enabled/*.conf
Include httpd.conf
Include ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
Include conf.d/
Include sites-enabled/
EXNDDQW
echo "rewrite headers expires" | a2enmod
echo "alias auth_basic authn_file authz_default authz_groupfile authz_host authz_user autoindex cgi env negotiation status" | a2dismod
rm /etc/apache2/sites-enabled/000-default
/etc/init.d/apache2 restart
/etc/init.d/nginx restart
}
function install_syslogd {
# We just need a simple vanilla syslogd. Also there is no need to log to
# so many files (waste of fd). Just dump them into
# /var/log/(cron/mail/messages)
check_install /usr/sbin/syslogd inetutils-syslogd
invoke-rc.d inetutils-syslogd stop
for file in /var/log/*.log /var/log/mail.* /var/log/debug /var/log/syslog
do
[ -f "$file" ] && rm -f "$file"
done
for dir in fsck news
do
[ -d "/var/log/$dir" ] && rm -rf "/var/log/$dir"
done
cat > /etc/syslog.conf <<END
*.*;mail.none;cron.none -/var/log/messages
cron.* -/var/log/cron
mail.* -/var/log/mail
END
[ -d /etc/logrotate.d ] || mkdir -p /etc/logrotate.d
cat > /etc/logrotate.d/inetutils-syslogd <<END
/var/log/cron
/var/log/mail
/var/log/messages {
rotate 4
weekly
missingok
notifempty
compress
sharedscripts
postrotate
/etc/init.d/inetutils-syslogd reload >/dev/null
endscript
}
END
invoke-rc.d inetutils-syslogd start
}
function install_eaccelerator {
apt-get -y --force-yes install build-essential php5-dev bzip2
cd /tmp
wget http://nchc.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
unzip eaccelerator-0.9.6.1.zip
cd eaccelerator-0.9.6.1
phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config --without-eaccelerator-use-inode
make
make install
cat >> /etc/php5/apache2/php.ini<<end
extension=eaccelerator.so
[eaccelerator]
eaccelerator.shm_size=8
eaccelerator.cache_dir=/tmp/eaccelerator
eaccelerator.enable=1
eaccelerator.optimizer=1
eaccelerator.check_mtime=1
eaccelerator.debug=0
eaccelerator.filter=""
eaccelerator.shm_max=0
eaccelerator.shm_ttl=0
eaccelerator.shm_prune_period=0
eaccelerator.shm_only=0
eaccelerator.compress=1
eaccelerator.compress_level=9
end
mkdir /tmp/eaccelerator
chmod 777 /tmp/eaccelerator
sed -i '2a chmod 777 /tmp/eaccelerator' /etc/rc.local
sed -i '2a mkdir /tmp/eaccelerator' /etc/rc.local
/etc/init.d/apache2 restart
}
function install_vhost {
check_install wget wget
if [ -z "$1" ]
then
die "Usage: `basename $0` wordpress <hostname>"
fi
if [ ! -d /var/www ];
then
mkdir /var/www
fi
mkdir "/var/www/$1"
chown -R www-data "/var/www/$1"
chmod -R 755 "/var/www/$1"
# Setting up Nginx mapping
cat > "/etc/nginx/conf.d/$1.conf" <<END
server {
server_name $1;
root /var/www/$1;
location / {
index index.html index.htm;
}
}
END
invoke-rc.d nginx reload
cat > "/var/www/$1/index.html" <<END
Hello world!
----$2
END
invoke-rc.d nginx reload
}
function install_dhost {
check_install wget wget
if [ ! -d /var/www ];
then
mkdir /var/www
fi
if [ -z "$1" ]
then
die "Usage: `basename $0` wordpress <hostname>"
fi
mkdir "/var/www/$1"
chown -R www-data "/var/www/$1"
chmod -R 755 "/var/www/$1"
wget -P "/var/www/$1" http://linux-bash.googlecode.com/files/tz.php
cat > "/var/www/$1/phpmyadmin.sh" <<END
#!/bin/bash
mkdir /tmp/wordpress.\$$
wget -O - http://linux-bash.googlecode.com/files/phpMyAdmin.tar.gz | \
tar zxf - -C /tmp/wordpress.\$$
mv /tmp/wordpress.\$$/phpMyAdmin \${PWD}
rm -rf /tmp/wordpress.\$$
END
# Setting up Nginx mapping
cat > "/etc/nginx/conf.d/$1.conf" <<END
server
{
listen 80;
server_name $1;
index index.html index.htm index.php default.html default.htm default.php;
root /var/www/$1;
location / {
try_files \$uri @apache;
}
location @apache {
internal;
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(php|php5)?$
{
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
$al
}
END
invoke-rc.d nginx reload
ServerAdmin=""
read -p "Please input Administrator Email Address:" ServerAdmin
if [ "$ServerAdmin" == "" ]; then
echo "Administrator Email Address will set to webmaster@example.com!"
ServerAdmin="webmaster@example.com"
else
echo "==========================="
echo Server Administrator Email="$ServerAdmin"
echo "==========================="
fi
cat >/etc/apache2/conf.d/$1.conf<<eof
<VirtualHost *:168>
ServerAdmin $ServerAdmin
php_admin_value open_basedir "/var/www/$1:/tmp/:/var/tmp/:/proc/"
DocumentRoot /var/www/$1
ServerName $1
ErrorLog /var/log/apache2/$1_error.log
CustomLog /var/log/apache2/$1_access.log combined
</VirtualHost>
eof
/etc/init.d/apache2 restart
}
function install_typecho {
check_install wget wget
if [ ! -d /var/www ];
then
mkdir /var/www
fi
if [ -z "$1" ]
then
die "Usage: `basename $0` wordpress <hostname>"
fi
# Downloading the WordPress' latest and greatest distribution.
rm -rf /tmp/build
wget -O - "http://typecho.googlecode.com/files/0.8(10.8.15)-release.tar.gz" | \
tar zxf - -C /tmp/
mv /tmp/build/ "/var/www/$1"
rm -rf /tmp/build
chown -R www-data "/var/www/$1"
chmod -R 755 "/var/www/$1"
wget -P "/var/www/$1" http://linux-bash.googlecode.com/files/tz.php
cat > "/var/www/$1/phpmyadmin.sh" <<END
#!/bin/bash
mkdir /tmp/wordpress.\$$
wget -O - http://linux-bash.googlecode.com/files/phpMyAdmin.tar.gz | \
tar zxf - -C /tmp/wordpress.\$$
mv /tmp/wordpress.\$$/phpMyAdmin \${PWD}
rm -rf /tmp/wordpress.\$$
END
# Setting up the MySQL database
dbname=`echo $1 | tr . _`
userid=`get_domain_name $1`
# MySQL userid cannot be more than 15 characters long
userid="${userid:0:15}"
passwd=`get_password "$userid@mysql"`
mysqladmin create "$dbname"
echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \
mysql
# Setting up Nginx mapping
cat > "/etc/nginx/conf.d/$1.conf" <<END
server
{
listen 80;
server_name $1;
index index.html index.htm index.php default.html default.htm default.php;
root /var/www/$1;
location / {
try_files \$uri @apache;
}
location @apache {
internal;
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(php|php5)?$
{
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
$al
}
END
cat >> "/root/$1.mysql.txt" <<END
[wordpress_myqsl]
dbname = $dbname
username = $userid
password = $passwd
END
invoke-rc.d nginx reload
ServerAdmin=""
read -p "Please input Administrator Email Address:" ServerAdmin
if [ "$ServerAdmin" == "" ]; then
echo "Administrator Email Address will set to webmaster@example.com!"
ServerAdmin="webmaster@example.com"
else
echo "==========================="
echo Server Administrator Email="$ServerAdmin"
echo "==========================="
fi
cat >/etc/apache2/conf.d/$1.conf<<eof
<VirtualHost *:168>
ServerAdmin $ServerAdmin
php_admin_value open_basedir "/var/www/$1:/tmp/:/var/tmp/:/proc/"
DocumentRoot /var/www/$1
ServerName $1
</VirtualHost>
#ErrorLog /var/log/apache2/$1_error.log
#CustomLog /var/log/apache2/$1_access.log combined
eof
/etc/init.d/apache2 restart
cat >> "/root/$1.mysql.txt" <<END
[typycho_myqsl]
dbname = $dbname
username = $userid
password = $passwd
END
echo "mysql dataname:" $dbname
echo "mysql username:" $userid
echo "mysql passwd:" $passwd
}
function install_wordpress_cn {
check_install wget wget
if [ -z "$1" ]
then
die "Usage: `basename $0` wordpress <hostname>"
fi
# Downloading the WordPress' latest and greatest distribution.
mkdir /tmp/wordpress.$$
wget -O - http://cn.wordpress.org/latest-zh_CN.tar.gz | \
tar zxf - -C /tmp/wordpress.$$
mv /tmp/wordpress.$$/wordpress "/var/www/$1"
rm -rf /tmp/wordpress.$$
chown -R www-data "/var/www/$1"
chmod -R 755 "/var/www/$1"
wget -P "/var/www/$1" http://linux-bash.googlecode.com/files/tz.php
cat > "/var/www/$1/phpmyadmin.sh" <<END
#!/bin/bash
mkdir /tmp/wordpress.\$$
wget -O - http://linux-bash.googlecode.com/files/phpMyAdmin.tar.gz | \
tar zxf - -C /tmp/wordpress.\$$
mv /tmp/wordpress.\$$/phpMyAdmin \${PWD}
rm -rf /tmp/wordpress.\$$
cat ~/.my.cnf
END
# Setting up the MySQL database
dbname=`echo $1 | tr . _`
userid=`get_domain_name $1`
# MySQL userid cannot be more than 15 characters long
userid="${userid:0:15}"
passwd=`get_password "$userid@mysql"`
cp "/var/www/$1/wp-config-sample.php" "/var/www/$1/wp-config.php"
sed -i "s/database_name_here/$dbname/; s/username_here/$userid/; s/password_here/$passwd/" \
"/var/www/$1/wp-config.php"
sed -i "31a define(\'WP_CACHE\', true);" "/var/www/$1/wp-config.php"
mysqladmin create "$dbname"
echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \
mysql
# Setting up Nginx mapping
cat > "/etc/nginx/conf.d/$1.conf" <<END
server
{
listen 80;
server_name $1;
index index.html index.htm index.php default.html default.htm default.php;
root /var/www/$1;
location / {
try_files \$uri @apache;
}
location @apache {
internal;
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(php|php5)?$
{
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
$al
}
END
cat >> "/root/$1.mysql.txt" <<END
[wordpress_myqsl]
dbname = $dbname
username = $userid
password = $passwd
END
invoke-rc.d nginx reload
ServerAdmin=""
read -p "Please input Administrator Email Address:" ServerAdmin
if [ "$ServerAdmin" == "" ]; then
echo "Administrator Email Address will set to webmaster@example.com!"
ServerAdmin="webmaster@example.com"
else
echo "==========================="
echo Server Administrator Email="$ServerAdmin"
echo "==========================="
fi
cat >/etc/apache2/conf.d/$1.conf<<eof
<VirtualHost *:168>
ServerAdmin $ServerAdmin
php_admin_value open_basedir "/var/www/$1:/tmp/:/var/tmp/:/proc/"
DocumentRoot /var/www/$1
ServerName $1
#ErrorLog /var/log/apache2/$1_error.log
#CustomLog /var/log/apache2/$1_access.log combined
</VirtualHost>
eof
/etc/init.d/apache2 restart
}
function install_wordpress_en {
check_install wget wget
if [ -z "$1" ]
then
die "Usage: `basename $0` wordpress <hostname>"
fi
# Downloading the WordPress' latest and greatest distribution.
mkdir /tmp/wordpress.$$
wget -O - http://wordpress.org/latest.tar.gz | \
tar zxf - -C /tmp/wordpress.$$
mv /tmp/wordpress.$$/wordpress "/var/www/$1"
rm -rf /tmp/wordpress.$$
chown -R www-data "/var/www/$1"
chmod -R 755 "/var/www/$1"
wget -P "/var/www/$1" http://linux-bash.googlecode.com/files/tz.php
cat > "/var/www/$1/phpmyadmin.sh" <<END
#!/bin/bash
mkdir /tmp/wordpress.\$$
wget -O - http://linux-bash.googlecode.com/files/phpMyAdmin.tar.gz | \
tar zxf - -C /tmp/wordpress.\$$
mv /tmp/wordpress.\$$/phpMyAdmin \${PWD}
rm -rf /tmp/wordpress.\$$
cat ~/.my.cnf
END
# Setting up the MySQL database
dbname=`echo $1 | tr . _`
userid=`get_domain_name $1`
# MySQL userid cannot be more than 15 characters long
userid="${userid:0:15}"
passwd=`get_password "$userid@mysql"`
cp "/var/www/$1/wp-config-sample.php" "/var/www/$1/wp-config.php"
sed -i "s/database_name_here/$dbname/; s/username_here/$userid/; s/password_here/$passwd/" \
"/var/www/$1/wp-config.php"
sed -i "31a define(\'WP_CACHE\', true);" "/var/www/$1/wp-config.php"
mysqladmin create "$dbname"
echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \
mysql
# Setting up Nginx mapping
cat > "/etc/nginx/conf.d/$1.conf" <<END
server
{
listen 80;
server_name $1;
index index.html index.htm index.php default.html default.htm default.php;
root /var/www/$1;
location / {
try_files \$uri @apache;
}
location @apache {
internal;
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(php|php5)?$
{
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
$al
}
END
cat >> "/root/$1.mysql.txt" <<END
[wordpress_myqsl]
dbname = $dbname
username = $userid
password = $passwd
END
invoke-rc.d nginx reload
ServerAdmin=""
read -p "Please input Administrator Email Address:" ServerAdmin
if [ "$ServerAdmin" == "" ]; then
echo "Administrator Email Address will set to webmaster@example.com!"
ServerAdmin="webmaster@example.com"
else
echo "==========================="
echo Server Administrator Email="$ServerAdmin"
echo "==========================="
fi
cat >/etc/apache2/conf.d/$1.conf<<eof
<VirtualHost *:168>
ServerAdmin $ServerAdmin
php_admin_value open_basedir "/var/www/$1:/tmp/:/var/tmp/:/proc/"
DocumentRoot /var/www/$1
ServerName $1
#ErrorLog /var/log/apache2/$1_error.log
#CustomLog /var/log/apache2/$1_access.log combined
</VirtualHost>
eof
/etc/init.d/apache2 restart
}
function install_phpmyadmin {
check_install wget wget
if [ -z "$1" ]
then
die "Usage: `basename $0` wordpress <hostname>"
fi
# Downloading the WordPress' latest and greatest distribution.
mkdir /tmp/wordpress.$$
wget -O - http://linux-bash.googlecode.com/files/phpMyAdmin.tar.gz | \
tar zxf - -C /tmp/wordpress.$$
mv /tmp/wordpress.$$/phpMyAdmin "/var/www/$1"
rm -rf /tmp/wordpress.$$
chown -R www-data "/var/www/$1"
chmod -R 755 "/var/www/$1"
# Setting up Nginx mapping
cat > "/etc/nginx/conf.d/$1.conf" <<END
server
{
listen 80;
server_name $1;
index index.html index.htm index.php default.html default.htm default.php;
root /var/www/$1;
location / {
try_files \$uri @apache;
}
location @apache {
internal;
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(php|php5)?$
{
proxy_pass http://127.0.0.1:168;
include proxy.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
$al
}
END
invoke-rc.d nginx reload
ServerAdmin=""
read -p "Please input Administrator Email Address:" ServerAdmin
if [ "$ServerAdmin" == "" ]; then
echo "Administrator Email Address will set to webmaster@example.com!"
ServerAdmin="webmaster@example.com"
else
echo "==========================="
echo Server Administrator Email="$ServerAdmin"
echo "==========================="
fi
cat >/etc/apache2/conf.d/$1.conf<<eof
<VirtualHost *:168>
ServerAdmin $ServerAdmin
php_admin_value open_basedir "/var/www/$1:/tmp/:/var/tmp/:/proc/"
DocumentRoot /var/www/$1
ServerName $1
#ErrorLog /var/log/apache2/$1_error.log
#CustomLog /var/log/apache2/$1_access.log combined
</VirtualHost>
eof
/etc/init.d/apache2 restart
cat ~/.my.cnf
}
function print_info {
echo -n -e '\e[1;36m'
echo -n $1
echo -e '\e[0m'
}
function print_warn {
echo -n -e '\e[1;33m'
echo -n $1
echo -e '\e[0m'
}
function check_version {
cat /etc/issue | grep "Linux 5"
if [ $? -ne 0 ]; then
cat > /etc/init.d/vzquota << EndFunc
#!/bin/sh
### BEGIN INIT INFO
# Provides: vzquota
# Required-Start:
# Required-Stop:
# Should-Start: $local_fs $syslog
# Should-Stop: $local_fs $syslog
# Default-Start: 0 1 2 3 4 5 6
# Default-Stop:
# Short-Description: Fixed(?) vzquota init script
### END INIT INFO
EndFunc
fi
}
function remove_unneeded {
# Some Debian have portmap installed. We don't need that.
check_remove /sbin/portmap portmap
# Remove rsyslogd, which allocates ~30MB privvmpages on an OpenVZ system,
# which might make some low-end VPS inoperatable. We will do this even
# before running apt-get update.
check_remove /usr/sbin/rsyslogd rsyslog
# Other packages that seem to be pretty common in standard OpenVZ
# templates.
check_remove /usr/sbin/apache2 'apache2*'
check_remove /usr/sbin/named bind9
check_remove /usr/sbin/smbd 'samba*'
check_remove /usr/sbin/nscd nscd
# Need to stop sendmail as removing the package does not seem to stop it.
if [ -f /usr/lib/sm.bin/smtpd ]
then
invoke-rc.d sendmail stop
check_remove /usr/lib/sm.bin/smtpd 'sendmail*'
fi
}
function update_stable {
cp /etc/apt/sources.list /etc/apt/sources.list.backup
cat > /etc/apt/sources.list <<END
deb http://mirror.peer1.net/debian/ squeeze main
deb-src http://mirror.peer1.net/debian/ squeeze main
deb http://mirror.peer1.net/debian/ squeeze-updates main
deb-src http://mirror.peer1.net/debian/ squeeze-updates main
deb http://mirror.peer1.net/debian-security/ squeeze/updates main
deb-src http://mirror.peer1.net/debian-security/ squeeze/updates main
deb http://nginx.org/packages/debian/ squeeze nginx
deb-src http://nginx.org/packages/debian/ squeeze nginx
END
apt-get -q -y update
apt-get -y install libc6 perl libdb2 debconf
apt-get -y install apt apt-utils dselect dpkg
#~ apt-get -q -y upgrade
}
function update_nginx {
apt-get -q -y update
invoke-rc.d nginx stop
apt-get -q -y remove nginx
apt-get -q -y --force-yes install nginx
if [ ! -d /etc/nginx ];
then
mkdir /etc/nginx
fi
if [ ! -d /etc/nginx/conf.d ];
then
mkdir /etc/nginx/conf.d
fi
cat > /etc/nginx/conf.d/actgod.conf <<END
client_max_body_size 20m;
server_names_hash_bucket_size 64;
END
sed -i s/'^worker_processes [0-9];'/'worker_processes 1;'/g /etc/nginx/nginx.conf
invoke-rc.d nginx restart
if [ ! -d /var/www ];
then
mkdir /var/www
fi
cat > /etc/nginx/proxy.conf <<EXND
proxy_connect_timeout 30s;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_set_header Host \$host;
proxy_set_header Referer \$http_referer;
proxy_set_header Cookie \$http_cookie;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
EXND
invoke-rc.d nginx restart
}
########################################################################
# START OF PROGRAM
########################################################################
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
check_sanity
case "$1" in
exim4)
install_exim4
;;
mysql)
install_mysql
;;
nginx)
install_nginx
;;
php)
install_php
;;
apache)
install_apache
;;
system)
check_version
remove_unneeded
update_stable
install_dash
install_syslogd
install_dropbear
;;
typecho)
install_typecho $2
;;
dhost)
install_dhost $2
;;
vhost)
install_vhost $2
;;
wordpress)
install_wordpress_cn $2
;;
wordpress_en)
install_wordpress_en $2
;;
stable)
check_version
remove_unneeded
update_stable
install_dash
install_syslogd
install_dropbear
install_exim4
install_mysql
install_nginx
install_php
install_apache
;;
updatenginx)
update_nginx
;;
phpmyadmin)
install_phpmyadmin $2
;;
eaccelerator)
install_eaccelerator
;;
sshport)
cat > /etc/xinetd.d/dropbear <<END
service dropbear
{
socket_type = stream
only_from = 0.0.0.0
wait = no
user = root
protocol = tcp
server = /usr/sbin/dropbear
server_args = -i
disable = no
port = $2
type = unlisted
}
END
echo "Please reboot.."
;;
addnginx)
sed -i s/'^worker_processes [0-9];'/'worker_processes iGodactgod;'/g /etc/nginx/nginx.conf
sed -i s/iGodactgod/$2/g /etc/nginx/nginx.conf
invoke-rc.d nginx restart
;;
addapache)
cat > /etc/apache2/apache2.conf <<EXNDDQW
LockFile \${APACHE_LOCK_DIR}/accept.lock
PidFile \${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
StartServers $2
MinSpareServers 2
MaxSpareServers 3
MaxClients $3
MaxRequestsPerChild 10000
</IfModule>
User \${APACHE_RUN_USER}
Group \${APACHE_RUN_GROUP}
AccessFileName .htaccess
DefaultType text/plain
HostnameLookups Off
ErrorLog \${APACHE_LOG_DIR}/error.log
LogLevel warn
Include mods-enabled/*.load
Include mods-enabled/*.conf
Include httpd.conf
Include ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
Include conf.d/
Include sites-enabled/
EXNDDQW
/etc/init.d/apache2 restart
;;
ssh)
cat >> /etc/shells <<END
/sbin/nologin
END
useradd $2 -s /sbin/nologin
echo $2:$3 | chpasswd
;;
httpproxy)
cat > /etc/nginx/sites-enabled/httpproxy.conf <<END
server {
listen $2;
resolver 8.8.8.8;
location / {
proxy_pass http://\$http_host\$request_uri;
}
}
END
invoke-rc.d nginx restart
;;
*)
echo 'Usage:' `basename $0` '[option]'
echo 'Available option:'
for option in system exim4 mysql nginx php wordpress wordpress_en typecho ssh addnginx stable testing dhost vhost httpproxy eaccelerator apache addapache sshport phpmyadmin
do
echo ' -' $option
done
;;
esac

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/yumho-renhao.git
git@api.gitlife.ru:oschina-mirror/yumho-renhao.git
oschina-mirror
yumho-renhao
yumho-renhao
master