2019年3月11日月曜日

VagrantでMiniflux2がインストールされた仮想マシン(Ubuntu18.04)を構築する

Miniflux2はGo製のfeed readerです。

○Miniflux2の画面


〇構築方法
以下のVagrantfileを使用して、Miniflux2とPostgreSQL11がインストールされた仮想マシン(Ubuntu18.04)を構築する事ができます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-18.04"
  config.vm.hostname = "ub1804miniflux2014"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1804miniflux2014"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.109", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.109", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get -y install language-pack-ja
sed -i.bak -e "s#http://archive.ubuntu.com/ubuntu/#http://ftp.riken.jp/pub/Linux/ubuntu/#g" /etc/apt/sources.list
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
timedatectl set-timezone Asia/Tokyo

# install postgresql
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
apt-get -y install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get upgrade
apt-get -y install postgresql-11

echo "listen_addresses='*'" >> /etc/postgresql/11/main/postgresql.conf

#sed -i 's/host.*all.*all.*127.0.0.1/#host    all             all             127.0.0.1/g' /etc/postgresql/11/main/pg_hba.conf

echo "host    all         all         127.0.0.1/32          password" >> /etc/postgresql/11/main/pg_hba.conf
echo "host    all         all         192.168.1.0/24          password" >> /etc/postgresql/11/main/pg_hba.conf
echo "host    all         all         192.168.55.0/24          password" >> /etc/postgresql/11/main/pg_hba.conf

systemctl restart postgresql.service
su - postgres << EOF
createdb -T template0 --locale=ja_JP.UTF-8 --encoding=UTF8 miniflux2
psql -c "
alter user postgres with password 'postgres';
create user miniflux with password 'miniflux';
grant all privileges on database miniflux2 to miniflux;
"
EOF
echo "postgres:postgres" | chpasswd
systemctl restart postgresql.service

wget https://github.com/miniflux/miniflux/releases/download/2.0.14/miniflux_2.0.14_amd64.deb
dpkg -i miniflux_2.0.14_amd64.deb

echo "DATABSE_URL=postgres://miniflux:miniflux@localhost/miniflux2?sslmode=disable" >> /etc/miniflux.conf

miniflux -migrate

apt-get -y install expect
/usr/bin/expect << EOF
spawn miniflux -create-admin
expect "Enter Username:"
send "admin\\r"
expect "Enter Password:"
send "admin123\\r"
expect eof
exit
EOF
systemctl enable miniflux
systemctl start miniflux

echo 'access http://192.168.55.109:8080/'
echo 'user: admin  password: admin123'
echo 'sample feed: http://serverarekore.blogspot.com/feeds/posts/default'

SHELL
end

0 件のコメント:

コメントを投稿