Last active
August 29, 2015 13:56
-
-
Save e3krisztian/8915425 to your computer and use it in GitHub Desktop.
install pypi server on an ubuntu 12.04 LTS server
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 | |
PYPI_USER=pypi | |
PYPI_HOME=/home/$PYPI_USER | |
PYPI_VENV=/home/pypi/env | |
PYPI_REPO=/data/pypi/repo | |
PYPI_PASSWORD=/data/pypi/repo.htaccess | |
adduser pypi --disabled-password --gecos PYPI --home $PYPI_HOME | |
apt-get update | |
apt-get install apache2-utils | |
# temporary install of dev tools | |
apt-get install -y python-virtualenv python-dev gcc | |
cd / | |
sudo -u $PYPI_USER bash -c "virtualenv $PYPI_VENV; . $PYPI_VENV/bin/activate; pip install pypiserver passlib twisted" | |
# make repo directory | |
mkdir -p $PYPI_REPO | |
chown $PYPI_USER $PYPI_REPO | |
# make password file for uploads | |
touch $PYPI_PASSWORD | |
chmod 700 $PYPI_PASSWORD | |
chown $PYPI_USER $PYPI_PASSWORD | |
# remove dev env | |
apt-get remove --purge python-virtualenv python-dev gcc | |
apt-get autoremove --purge | |
# init script | |
cat > /etc/init/pypi.conf <<-EOF | |
# /etc/init/pypi.conf | |
description "pypi" | |
setuid ${PYPI_USER} | |
setgid ${PYPI_USER} | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
respawn | |
# no reverse proxy - public access on 8080, XXX should be restricted to localhost when proxying | |
exec ${PYPI_VENV}/bin/pypi-server --interface 0.0.0.0 --port 8080 --server twisted --disable-fallback --passwords $PYPI_PASSWORD ${PYPI_REPO} | |
EOF | |
initctl start pypi |
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 | |
initctl stop pypi | |
rm -f /etc/init/pypi.conf | |
deluser pypi --remove-home | |
apt-get remove --purge python-virtualenv python-dev gcc apache2-utils | |
apt-get autoremove --purge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment