2017年11月1日水曜日

Vagrantでseafileをインストールした仮想マシン(CentOS7.4)を構築する

以下のVagrantfileを使用して、seafileがインストールされた仮想マシンを構築する事ができます。
仮想マシン構築後、ブラウザからhttp://192.168.55.103:8000/にアクセスします。

Vagratfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/centos-7.4"
  config.vm.hostname = "co74seafile"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "co74seafile"
     vbox.cpus = 4
     vbox.memory = 4096
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
  config.vm.network "private_network", ip: "192.168.55.103", :netmask => "255.255.255.0"
  config.vm.network "public_network", ip:"192.168.1.103", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
# mysqlのインストール
sudo yum -y remove mariadb-libs
yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum -y install mysql mysql-devel mysql-server mysql-utilities
sudo systemctl enable mysqld.service
sudo systemctl start mysqld.service

# change password and create users and databases.
chkconfig mysqld on
service mysqld start
export MYSQL_ROOTPWD='Root123#'
export MYSQL_PWD=`cat /var/log/mysqld.log | awk '/temporary password/ {print $NF}'`
mysql -uroot --connect-expired-password -e "SET PASSWORD = PASSWORD('$MYSQL_ROOTPWD');"
export MYSQL_PWD=$MYSQL_ROOTPWD
export MYSQL_ROOTPWD='root'
mysql -uroot --connect-expired-password -e "UNINSTALL PLUGIN validate_password;"
mysql -uroot --connect-expired-password -e "SET PASSWORD = PASSWORD('$MYSQL_ROOTPWD');"
export MYSQL_PWD=$MYSQL_ROOTPWD

mysql -uroot --connect-expired-password -e "CREATE USER seafile@localhost IDENTIFIED BY 'seafile';"
mysql -uroot --connect-expired-password -e "GRANT ALL PRIVILEGES ON *.* TO 'seafile'@'localhost';"

cp /etc/my.cnf /etc/my.cnf.org
cat << EOF > /etc/my.cnf
[client]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
default-character-set=utf8

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
bind-address = 0.0.0.0
port            = 3306
key_buffer_size = 256M
max_allowed_packet = 16M
table_open_cache = 16
innodb_buffer_pool_size = 512M
innodb_log_file_size = 32M
sort_buffer_size = 8M
read_buffer_size = 8M
read_rnd_buffer_size = 8M
join_buffer_size = 8M
thread_stack = 4M
character-set-server=utf8
lower_case_table_names = 1
innodb_lock_wait_timeout=120
skip-innodb-doublewrite

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
EOF

sudo systemctl stop mysqld.service
sudo cp /vagrant/my.cnf /etc

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
sudo systemctl start mysqld.service

# ダウンロードとインストール
wget https://download.seadrive.org/seafile-server_6.2.2_x86-64.tar.gz
tar xvfz seafile-server_6.2.2_x86-64.tar.gz
mv seafile-server-6.2.2/ /opt/seafile

yum -y install python-distribute python-imaging MySQL-python
/opt/seafile/setup-seafile-mysql.sh auto -n `hostname` -i 192.168.55.103 -p 8082 -d /opt/seafile/data -e 0 -o localhost -t 3306 -r root -u seafile -w seafile -q 192.168.55.103 -c ccnetdb -s seafiledb -b seahubdb

cat << EOF > /etc/systemd/system/seafile.service
[Unit]
Description=seafile
Requires=network.target
After=zookeepepr.service

[Service]
Type=forking
ExecStart=/opt/seafile/seafile.sh start
ExecStop=/opt/seafile/seafile.sh stop

[Install]
WantedBy=multi-user.target
EOF
systemctl enable seafile.service
systemctl start seafile.service

cat << EOF > /etc/systemd/system/seahub.service
[Unit]
Description=seahub
Requires=network.target
After=zookeepepr.service

[Service]
Type=forking
ExecStart=/opt/seafile/seahub.sh start
ExecStop=/opt/seafile/seahub.sh stop

[Install]
WantedBy=multi-user.target
EOF
systemctl enable seahub.service
systemctl start seahub.service

cat << EOF | /opt/seafile/reset-admin.sh
admin@example.com
admin
admin
EOF

echo 'access to http://192.168.55.103:8000/';
echo 'user: admin@example.com    password: admin'
SHELL
end

○seafileのログイン画面


○seafileのログイン後の画面


0 件のコメント:

コメントを投稿