-
Notifications
You must be signed in to change notification settings - Fork 24
/
linux-setup.sh
48 lines (39 loc) · 1.57 KB
/
linux-setup.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
#!/bin/sh
# This file should be run on the linux machine that will be running docker
# it is set up as the provisioning file for vagrant images, but can be run
# manually if you are not using vagrant. It should be run as root.
# note that all of the sudo usage in this script is due to the uncertainty
# of the provisioning user by vagrant.
sudo apt-get install -q -y curl
curl https://get.docker.io | sudo sh -x
sudo apt-get install -y -q python-all-dev
sudo apt-get install -y -q python-pip
sudo apt-get install -y -q git
sudo pip install -U pip
sudo mkdir -p /usr/local/etc/jiffylab/
WHO=$(whoami)
if [ $WHO = 'vagrant' -o -d /vagrant/webapp/ ]
then
echo "running via vagrant"
sudo cp -R /vagrant/* /usr/local/etc/jiffylab/
else
echo "not running via vagrant"
sudo cp -r ./* /usr/local/etc/jiffylab/
fi
sudo pip install -r /usr/local/etc/jiffylab/webapp/requirements.txt
# users the docker group can access the docker command and remote API
sudo groupadd docker
sudo useradd -g docker jiffylabweb
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 5000
sudo chown -R jiffylabweb /usr/local/etc/jiffylab/webapp/
docker pull ptone/jiffylab-base
# docker build /usr/local/etc/jiffylab/docker-builds/base
# add a modicum of security - don't run the webapp as root
sudo echo "
start on startup
pre-start script
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 5000
end script
exec sudo -u jiffylabweb /usr/bin/python /usr/local/etc/jiffylab/webapp/server.py
" > /etc/init/jiffylabweb.conf
sudo start jiffylabweb