-
-
Save stefanfoulis/8692335 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# devpi install for a dedicated ubuntu server with upstart | |
# based on http://tim.freunds.net/blog/devpi.html | |
# execute as root (sudo) | |
set -ex # exit on error, print executed commands | |
DEVPI_VENV=/opt/devpi | |
DEVPI_USER=devpi | |
args=( | |
--system | |
--shell $(which nologin) | |
--home ${DEVPI_VENV} | |
--no-create-home | |
--user-group | |
--comment "DevPI server" | |
) | |
useradd ${DEVPI_USER} "${args[@]}" | |
passwd --lock ${DEVPI_USER} | |
mkdir ${DEVPI_VENV} | |
chown ${DEVPI_USER}:${DEVPI_USER} ${DEVPI_VENV} | |
apt-get update | |
apt-get install -y python-virtualenv python-dev | |
sudo -u ${DEVPI_USER} bash -exc " | |
cd ${DEVPI_VENV} | |
virtualenv ${DEVPI_VENV} | |
source ${DEVPI_VENV}/bin/activate | |
pip install devpi-server eventlet | |
" | |
apt-get purge -y python-dev | |
apt-get autoremove -y --purge | |
cat > /etc/init/devpi.conf <<-EOF | |
# /etc/init/devpi.conf | |
description "devpi" | |
setuid ${DEVPI_USER} | |
setgid ${DEVPI_USER} | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
respawn | |
# when remapping to port 80 with nginx, it is enough to run on localhost: | |
# exec ${DEVPI_VENV}/bin/devpi-server --port 3141 --bottleserver eventlet --refresh 3600 --serverdir ${DEVPI_VENV}/data --secretfile ${DEVPI_VENV}/.secret | |
# public access on port 3141, potentially no nginx | |
exec ${DEVPI_VENV}/bin/devpi-server --host 0.0.0.0 --port 3141 --bottleserver eventlet --refresh 3600 --serverdir ${DEVPI_VENV}/data --secretfile ${DEVPI_VENV}/.secret | |
EOF | |
initctl start devpi | |
read -p 'Will install nginx, when enter pressed (control-c to abort)' install | |
# nginx install to serve on port 80 instead of 3141 | |
apt-get install -y nginx-light | |
service nginx stop | |
rm -f /etc/nginx/sites-enabled/default | |
cat > /etc/nginx/sites-available/devpi.conf <<-EOF | |
server { | |
listen 80 default_server; | |
location / { | |
proxy_pass http://localhost:3141; | |
} | |
} | |
EOF | |
ln -s /etc/nginx/sites-{available,enabled}/devpi.conf | |
service nginx start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
initctl stop devpi | |
rm -f /etc/init/devpi.conf | |
rm -rf /opt/devpi | |
userdel devpi | |
groupdel devpi | |
apt-get purge -y python-dev | |
apt-get purge -y python-virtualenv | |
rm -f /etc/nginx/sites-{enabled,available}/devpi.conf | |
apt-get purge -y nginx-light | |
apt-get autoremove -y --purge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment