#!/bin/bash
# python package batch deployment
# Create Cache Directory
cd ~
mkdir -p ~/.pip/cache
# Create Config Files
cat > ~/.pip/requirement.txt <<_EOF_
pymongo
pymysql
redis
_EOF_
cat > ~/.pip/pip.conf <<_EOF_
[global]
no-index = true
find-links = http://server/.pip/cache
_EOF_
# Download Packages
pip install -d ~/.pip/cache -r ~/requirement.txt
# Start HTTP Server
sudo python -m SimpleHTTPServer 80 &
# Deploy to Clients
for ip in 192.168.3.{150..200}
do
echo "======$ip======"
ssh client@$ip 'curl -O http://server/.pip/pip.conf && sudo PIP_CONFIG_FILE=pip.conf pip install -U -r http://server/.pip/requirement.txt'
done
Note: You should config clients:
- Use the same username and password
- Run sudo without password
- Login via ssh private key (otherwise, use sshpass util)