forked from Tokyo-Metro-Gov/covid19
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vagrant_provision.sh
executable file
·50 lines (40 loc) · 1.12 KB
/
vagrant_provision.sh
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
#!/bin/bash
sudo apt-get update -y
# g++ build-essentialのインストール
sudo apt-get install -y g++ build-essential
# nodejsのインストール
# https://github.com/nodesource/distributions/blob/master/README.md
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs
# yarnのインストール
sudo npm install -g yarn
# ソースのコピー
cp -pr /vagrant/ ./covid19
# /vagrantがホストと共有できない場合は、githubからクローンする
#git clone https://github.com/tokyo-metropolitan-gov/covid19.git
cd covid19
# インストール
sudo chown vagrant:vagrant ../.config
yarn install
# 起動スクリプト
cat << EOF > /home/vagrant/covid19.sh
#!/bin/bash
cd /home/vagrant/covid19
HOST=0.0.0.0 /usr/bin/yarn dev
EOF
# systemd定義
sudo tee /etc/systemd/system/covid19.service << EOF
[Unit]
Description = covid19 daemon
[Service]
ExecStart = /bin/bash /home/vagrant/covid19.sh
Restart = always
Type = simple
User = vagrant
Group = vagrant
[Install]
WantedBy = multi-user.target
EOF
# サービス設定
sudo systemctl enable covid19
sudo systemctl start covid19