-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·137 lines (97 loc) · 2.87 KB
/
init.sh
File metadata and controls
executable file
·137 lines (97 loc) · 2.87 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
#
# Initialize a taginfo server.
#
# Must be run once as user "root" on the server when it is first created.
#
set -euo pipefail
set -x
DIR=/srv/taginfo
REPOSITORY=/home/robot/testserver
# -- Install Debian packages --
apt-get update -y
apt-get dist-upgrade -u -y
# Packages needed for taginfo-tools
apt-get install -y \
cmake \
cmake-curses-gui \
g++ \
libbz2-dev \
libexpat1-dev \
libgd-dev \
libicu-dev \
libosmium2-dev \
libprotozero-dev \
libsqlite3-dev \
make \
zlib1g-dev
# Packages needed for taginfo
apt-get install -y \
curl \
jq \
pbzip2 \
ruby \
ruby-dev \
sqlite3 \
sqlite3-pcre \
unzip \
zip
RUBY_VERSION=$(ruby -e "puts RUBY_VERSION.split('.')[0..1].join('.')")
# Packages needed for running in uWSGI application server
apt-get install -y \
uwsgi-core \
"uwsgi-plugin-rack-ruby$RUBY_VERSION"
# Packages needed for running under Apache
apt-get install -y \
apache2 \
libapache2-mod-passenger \
ruby-passenger
# Other useful packages
apt-get install -y \
git \
osmium-tool \
pyosmium \
rsync \
tmux \
zsh
apt-get clean
# -- Stop Apache (because it isn't configured yet) --
systemctl stop apache2
# -- Create robot user --
grep --quiet robot /etc/passwd || \
adduser --gecos "Robot User" --disabled-password robot
mkdir -p /home/robot/.ssh
cp /root/.ssh/authorized_keys /home/robot/.ssh
chown -R robot:robot /home/robot/.ssh
chmod 700 /home/robot/.ssh
chmod 600 /home/robot/.ssh/authorized_keys
# -- Directory setup --
mkdir -p $DIR $DIR/data $DIR/download $DIR/planet $DIR/log $DIR/update
chown -R robot:robot $DIR
# -- Get git repositories --
rm -fr $REPOSITORY
su -c "git clone https://github.com/taginfo/testserver $REPOSITORY" robot
rm -fr $DIR/taginfo
su -c "git clone https://github.com/taginfo/taginfo $DIR/taginfo" robot
# -- Set up configuration --
grep -v '^ *//' $DIR/taginfo/taginfo-config-example.json | \
jq '.logging.directory = "/srv/taginfo/log"' | \
jq '.paths.data_dir = "/srv/taginfo/data"' | \
jq '.paths.download_dir = "/srv/taginfo/download"' | \
jq '.paths.bin_dir = "/srv/taginfo/build/src"' | \
jq '.sources.db.planetfile = "/srv/taginfo/planet/data.osm.pbf"' | \
jq '.sources.chronology.osm_history_file = "/srv/taginfo/planet/history-data.osh.pbf"' | \
jq '.sources.db.bindir = "/srv/taginfo/build/src"' \
>$DIR/taginfo-config.json
chown robot:robot $DIR/taginfo-config.json
# -- Install Ruby gems --
cd /srv/taginfo/taginfo
gem install bundler
bundle install
# -- Apache setup --
cp $REPOSITORY/apache/taginfo.conf /etc/apache2/sites-available/000-default.conf
a2enmod cache
a2enmod cache_disk
a2enmod headers
#systemctl restart apache2.service
echo "init.sh done."