2018年4月23日月曜日

VagrantでPerkeep(Camlistore)をインストールした仮想マシン(Debian Stretch9.3)を構築する

Perkeep(Camlistore)は様々なデータを保存できるシステムです。

〇Perkeepの画面


〇構築方法
以下のVagrantfileを使用して、Camlistoreをインストールした仮想マシンを構築できます。
仮想マシン構築後、ブラウザからhttp://192.168.55.103:3179でWeb UIにアクセスできます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.3"
  config.vm.hostname = "db93perkeep"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db93perkeep"
     vbox.cpus = 2
     vbox.memory = 2048
     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
apt-get -y install task-japanese
sed -i -e 's/# ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
update-locale LANG=ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade

# install go
wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
tar xvfz go1.10.1.linux-amd64.tar.gz
mv go /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile

# install perkeep
cd /opt
apt-get -y install git
git clone https://camlistore.googlesource.com/camlistore
cd /opt/camlistore
source /etc/profile
/usr/local/go/bin/go run make.go

useradd cs
chown -R cs:cs /opt/camlistore

cat << EOF > /etc/systemd/system/camlistore.service
[Unit]
Description=Camlistore
After=network.target

[Service]
Type=simple
ExecStart=/bin/bash -c -i 'export HOME=/opt/camlistore && cd /opt/camlistore && /opt/camlistore/bin/camlistored'
WorkingDirectory=/opt/camlistore
Restart=on-failure
User=cs
Group=cs

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

while netstat -lnt | awk '$4 ~ /:3179$/ {exit 1}'; do sleep 10; done
sleep 10

sed -i -e 's/"auth": "localhost"/"auth":"userpass:admin:admin"/' /opt/camlistore/.config/camlistore/server-config.json
chown -R cs:cs /opt/camlistore
systemctl restart camlistore.service

echo 'access http://192.168.55.103:3179'
SHELL
end

0 件のコメント:

コメントを投稿