-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinitial.centos.4.1
executable file
·147 lines (122 loc) · 4.36 KB
/
initial.centos.4.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/sh
function plugin_install(){
cd /tmp
if [ -f /tmp/${1}.zip ]; then
rm -r /tmp/${1}.zip
fi
/usr/bin/wget http://downloads.wordpress.org/plugin/${1}.zip
if [ -d /var/www/vhosts/${2}/wp-content/plugins/${1} ]; then
/bin/rm -rf /var/www/vhosts/${2}/wp-content/plugins/${1}
fi
/usr/bin/unzip /tmp/${1}.zip -d /var/www/vhosts/${2}/wp-content/plugins/
/bin/rm -r /tmp/${1}.zip
}
WP_VER=4.1
WRK_DIR=/opt/local
SRC_DIR=$WRK_DIR/conoha
/bin/cp /dev/null /root/.mysql_history > /dev/null 2>&1
/bin/cp /dev/null /root/.bash_history > /dev/null 2>&1; history -c
/usr/bin/yes | /usr/bin/crontab -r
echo "start..."
echo ""
if [ ! -d $WRK_DIR ]; then
mkdir -p $WRK_DIR
fi
if [ ! -f $SRC_DIR/.git/config ]; then
if [ -d $SRC_DIR ]; then
/bin/rm -Rf $SRC_DIR
fi
/usr/bin/git clone git://github.com/megumiteam/amimoto.git $SRC_DIR
else
cd $SRC_DIR
/usr/bin/git pull origin master
fi
SERVERNAME=default
TZ="Asia\/Tokyo"
cd $SRC_DIR
/sbin/service monit stop
/sbin/service nginx stop
/bin/cp -Rf $SRC_DIR/etc/nginx/* /etc/nginx/
sed -e "s/\$host\([;\.]\)/$SERVERNAME\1/" $SRC_DIR/etc/nginx/conf.d/default.conf > /etc/nginx/conf.d/default.conf
sed -e "s/\$host\([;\.]\)/$SERVERNAME\1/" $SRC_DIR/etc/nginx/conf.d/default.backend.conf > /etc/nginx/conf.d/default.backend.conf
/bin/rm -rf /var/log/nginx/*
/bin/rm -rf /var/cache/nginx/*
/sbin/service php-fpm stop
sed -e "s/date\.timezone = \"UTC\"/date\.timezone = \"$TZ\"/" $SRC_DIR/etc/php.ini > /etc/php.ini
/bin/cp -Rf $SRC_DIR/etc/php.d/* /etc/php.d/
/bin/cp $SRC_DIR/etc/php-fpm.conf /etc/
/bin/cp -Rf $SRC_DIR/etc/php-fpm.d/* /etc/php-fpm.d/
/bin/rm -rf /var/log/php-fpm/*
if [ -f /etc/php.d/apc.ini ]; then
/bin/rm /etc/php.d/apc.ini
fi
/sbin/service mysql stop
/bin/cp $SRC_DIR/etc/my.cnf /etc/
/bin/rm /var/lib/mysql/ib_logfile*
/bin/rm /var/log/mysqld.log*
/sbin/service nginx start
/sbin/service php-fpm start
/sbin/service mysql start
/sbin/service monit start
echo "WordPress install ..."
WP_CLI=/usr/local/bin/wp
if [ ! -f $WP_CLI ]; then
cd /usr/local/bin
/usr/bin/curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
chmod +x /usr/local/bin/wp
fi
if [ ! -d /var/www/vhosts/$SERVERNAME ]; then
mkdir -p /var/www/vhosts/$SERVERNAME
fi
cd /var/www/vhosts/$SERVERNAME
$WP_CLI core download --locale=ja --version=$WP_VER --force --allow-root
if [ -f $SRC_DIR/centos/wp-setup.php ]; then
/usr/bin/php $SRC_DIR/centos/wp-setup.php $SERVERNAME $SERVERNAME
fi
# Performance
plugin_install "nginx-champuru" "$SERVERNAME" > /dev/null 2>&1
plugin_install "wpbooster-cdn-client" "$SERVERNAME" > /dev/null 2>&1
plugin_install "nephila-clavata" "$SERVERNAME" > /dev/null 2>&1
# Developer
plugin_install "debug-bar" "$SERVERNAME" > /dev/null 2>&1
plugin_install "debug-bar-extender" "$SERVERNAME" > /dev/null 2>&1
plugin_install "debug-bar-console" "$SERVERNAME" > /dev/null 2>&1
#Security
plugin_install "crazy-bone" "$SERVERNAME" > /dev/null 2>&1
plugin_install "login-lockdown" "$SERVERNAME" > /dev/null 2>&1
plugin_install "google-authenticator" "$SERVERNAME" > /dev/null 2>&1
#Other
plugin_install "nginx-mobile-theme" "$SERVERNAME" > /dev/null 2>&1
plugin_install "flamingo" "$SERVERNAME" > /dev/null 2>&1
plugin_install "contact-form-7" "$SERVERNAME" > /dev/null 2>&1
plugin_install "simple-ga-ranking" "$SERVERNAME" > /dev/null 2>&1
MU_PLUGINS="/var/www/vhosts/${SERVERNAME}/wp-content/mu-plugins"
if [ ! -d ${MU_PLUGINS} ]; then
/bin/mkdir -p ${MU_PLUGINS}
fi
cp $SRC_DIR/mu-plugins/mu-plugins.php $MU_PLUGINS
echo "... WordPress installed"
if [ ! -d /var/tmp/php ]; then
mkdir -p /var/tmp/php
fi
if [ ! -d /var/lib/php ]; then
mkdir -p /var/lib/php
fi
/bin/chown -R nginx:nginx /var/log/nginx
/bin/chown -R nginx:nginx /var/log/php-fpm
/bin/chown -R nginx:nginx /var/cache/nginx
/bin/chown -R nginx:nginx /var/tmp/php
/bin/chown -R nginx:nginx /var/lib/php
/bin/chown -R nginx:nginx /var/www/vhosts/$SERVERNAME
PHP_MY_ADMIN_VER="4.3.3"
PHP_MY_ADMIN="phpMyAdmin-${PHP_MY_ADMIN_VER}-all-languages"
if [ ! -d /usr/share/${PHP_MY_ADMIN} ]; then
cd /usr/share/
/usr/bin/wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/${PHP_MY_ADMIN_VER}/${PHP_MY_ADMIN}.zip
/usr/bin/unzip /usr/share/${PHP_MY_ADMIN}.zip
/bin/rm /usr/share/${PHP_MY_ADMIN}.zip
/bin/ln -s /usr/share/${PHP_MY_ADMIN} /usr/share/phpMyAdmin
fi
echo ""
echo "...done"