#!/bin/bash -xe VERSION=$1 GIT_SSH_COMMAND='ssh -i ~/.ssh/git_key -o IdentitiesOnly=yes' git clone git@git.dreamhost.com:dreamhost/dhwp.git rm -rf dhwp/.git dhwp/.gitignore \curl -sSL https://get.rvm.io | bash -s stable source ~/.rvm/scripts/rvm # following line commented out as gem should be already installed, with sudo perms. If you're doing it on some host # without gem - try to install it with `` if you have permissions, or maybe even try to uncomment ^ line #gem install --no-document fpm mkdir -p etc/profile.d echo "alias dhwpenv='source /usr/local/bin/dhwp/env/bin/activate'" > etc/profile.d/dhwp.sh mkdir -p usr/local/bin/ mv dhwp usr/local/bin/ echo -e "#!/usr/bin/env bash\nset -e\ncd /usr/local/bin/dhwp\nvirtualenv -p python3 --prompt '|> dhwp <| ' env >/dev/null 2>&1\nenv/bin/pip install -r requirements.txt >/dev/null 2>&1\nenv/bin/python setup.py develop >/dev/null 2>&1\nln -s /usr/local/bin/dhwp/env/bin/dhwp /usr/bin/dhwp >/dev/null 2>&1\n" > dhwp_postinst.sh echo -e "#!/usr/bin/env bash\nset -e\nif [ -e /usr/local/bin/dhwp ]; then\n\trm -f /usr/bin/dhwp\n\trm -rf /usr/local/bin/dhwp/dhwp.egg-info\n\trm -rf /usr/local/bin/dhwp/env\n\tif which py3clean >/dev/null 2>&1; then\n\t\tpy3clean /usr/local/bin/dhwp\n\tfi\nfi" > dhwp_prerm.sh fpm -t deb -s dir --before-remove dhwp_prerm.sh --after-install dhwp_postinst.sh --depends "virtualenv" --deb-pre-depends "virtualenv" -v "${VERSION}" -n dhwp usr/ etc/