Created
July 2, 2015 02:35
-
-
Save hilotech/1cbf9410d505e07478ea to your computer and use it in GitHub Desktop.
ConoHa : ownCloudインストールスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -u | |
# must replace with your own configuration | |
MYSQL_ROOT_PASSWD=your_mysql_root_password | |
MYSQL_OWNCLOUD_PASSWD=your_owncloud_admin_password | |
MYSQL_HOST=localhost | |
MYSQL_ROOT_USER=root | |
MYSQL_OWNCLOUD_DBNAME=owncloud | |
DIST='https://download.owncloud.org/community/owncloud-8.0.3.tar.bz2' | |
# Prerequisite | |
yum -y install \ | |
postfix rsyslog cronie wget telnet w3m bzip2 tar expect perl \ | |
epel-release \ | |
httpd mysql mysql-server | |
# MySQL setup | |
chkconfig mysqld on | |
service mysqld start | |
expect <<_EOF | |
set timeout 10 | |
spawn /usr/bin/mysql_secure_installation | |
expect "Enter current password for root (enter for none):" | |
send "\n" | |
expect "Set root password? \[Y/n\]" | |
send "\n" | |
expect "New password:" | |
send "$MYSQL_ROOT_PASSWD\n" | |
expect "Re-enter new password:" | |
send "$MYSQL_ROOT_PASSWD\n" | |
expect "Remove anonymous users? \[Y/n\]" | |
send "\n" | |
expect "Disallow root login remotely? \[Y/n\]" | |
send "\n" | |
expect "Remove test database and access to it? \[Y/n\]" | |
send "\n" | |
expect "Reload privilege tables now? \[Y/n\]" | |
send "\n" | |
expect eof | |
_EOF | |
/usr/bin/mysql \ | |
--host=${MYSQL_HOST-} \ | |
--user=${MYSQL_ROOT_USER-} \ | |
--password=${MYSQL_ROOT_PASSWD-} \ | |
<<_EOF_ | |
CREATE | |
DATABASE ${MYSQL_OWNCLOUD_DBNAME-} | |
DEFAULT CHARACTER SET utf8 | |
; | |
GRANT | |
ALL PRIVILEGES | |
ON ${MYSQL_OWNCLOUD_DBNAME-}.* | |
TO ${MYSQL_OWNCLOUD_DBNAME-}@localhost | |
IDENTIFIED BY '${MYSQL_OWNCLOUD_PASSWD-}' | |
; | |
GRANT | |
ALL PRIVILEGES | |
ON ${MYSQL_OWNCLOUD_DBNAME-}.* | |
TO ${MYSQL_OWNCLOUD_DBNAME-}@'127.0.0.1' | |
IDENTIFIED BY '${MYSQL_OWNCLOUD_PASSWD-}' | |
; | |
_EOF_ | |
# Some repositories | |
rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm | |
perl \ | |
-07 -pi \ | |
-e 's/(\[rpmforge\].*?\nenabled)=0/$1=1/is;' \ | |
/etc/yum.repos.d/rpmforge.repo | |
rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/ius-release-1.0-11.ius.el6.noarch.rpm | |
# Replace PHP 5.3 -> 5.4 | |
yum -y erase php* | |
yum --enablerepo=ius,epel,rpmforge \ | |
-y install \ | |
curl curl-devel libidn zlib-devel \ | |
php54 php54-bz2 php54-cli php54-common php54-devel \ | |
php54-exif php54-ftp php54-gd php54-gmp php54-iconv \ | |
php54-intl php54-ldap php54-libxml php54-mbstring \ | |
php54-mcrypt php54-mysql php54-pear \ | |
php54-pecl-Fileinfo php54-pecl-zip php54-simplexml \ | |
php54-xcache php54-xml php54-xml php54-xmlwriter \ | |
php54-posix | |
# ownCloud | |
TMP_DIR=`mktemp -d` | |
cd $TMP_DIR | |
wget --no-check-certificate $DIST | |
fn=$(basename $DIST) | |
echo $fn | |
bzip2 -d $fn | |
unbzipped=${fn%.bz2} | |
echo $unbzipped | |
tar xvf $unbzipped | |
bs=${fn%-*.tar.bz2} | |
echo $bs | |
chown -R apache.apache $bs | |
mv $bs /var/www/owncloud.local | |
cd /tmp | |
/bin/rm -r $TMP_DIR | |
TEMPDIR=`mktemp -d` | |
cd $TEMPDIR | |
mkdir -p /tmp/_upload | |
wget -O /tmp/_upload/owncloud_apps.tgz \ | |
https://github.com/hilotech/Reckerfiles/raw/master/Reckerfiles/owncloud/_upload/owncloud_apps.tgz | |
tar xvzf /tmp/_upload/owncloud_apps.tgz | |
mv owncloud_apps/* /var/www/owncloud.local/apps | |
cd /tmp | |
/bin/rm -r $TEMPDIR | |
sed -i \ | |
-e 's|max_execution_time = 30|max_execution_time = 0|;' \ | |
-e 's|max_input_time = 60|max_input_time = 0|;' \ | |
-e 's|memory_limit = 128M|memory_limit = 4G|;' \ | |
-e 's|post_max_size = 8M|post_max_size = 4G|;' \ | |
-e 's|upload_max_filesize = 2M|upload_max_filesize = 4G|;' \ | |
-e 's|;default_charset = "UTF-8"|default_charset = "UTF-8"|;' \ | |
/etc/php.ini | |
[ -f /etc/httpd/conf.d/welcome.conf ] \ | |
&& /bin/rm /etc/httpd/conf.d/welcome.conf | |
echo 'ServerName localhost:80' > /etc/httpd/conf.d/servername.conf | |
echo 'AddHandler cgi-script .cgi' > /etc/httpd/conf.d/cgi.conf | |
echo 'DirectoryIndex index.cgi index.php index.html index.html.var' \ | |
> /etc/httpd/conf.d/index.conf | |
echo 'Include vhosts/*.conf' > /etc/httpd/conf.d/vhosts.conf | |
mkdir -p /etc/httpd/vhosts | |
cat <<_EOF_ > /etc/httpd/vhosts/owncloud.local.conf | |
<VirtualHost *:80> | |
ServerName owncloud.local | |
DocumentRoot /var/www/owncloud.local | |
<Directory /var/www/owncloud.local> | |
Options +ExecCGI | |
</Directory> | |
LimitRequestBody 0 | |
TimeOut 3600 | |
</VirtualHost> | |
_EOF_ | |
sed -i \ | |
-e 's@\(curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);\)@\1\n curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);@' \ | |
/var/www/owncloud.local/lib/private/httphelper.php | |
mkdir -p /var/www-data/owncloud.local | |
chown apache.apache /var/www-data/owncloud.local | |
for i in rsyslog crond postfix httpd ; | |
do | |
chkconfig $i on | |
service $i start | |
done | |
iptables -I INPUT -p tcp --dport http -j ACCEPT | |
service iptables save | |
service iptables reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment