提交 07abda77 编写于 作者: A Andrew Brookins

Remove Vagrant files

上级 c8dc6a6b
PATH=$PATH:/var/lib/redis/bin
#!/usr/bin/env bash
# need make to build redis
sudo apt-get install make
#!/usr/bin/env bash
source /home/vagrant/redis-py/build_tools/redis_vars.sh
pushd /home/vagrant
uninstall_all_sentinel_instances
uninstall_all_redis_instances
# create a clean directory for redis
rm -rf $REDIS_DIR
mkdir -p $REDIS_BIN_DIR
mkdir -p $REDIS_CONF_DIR
mkdir -p $REDIS_SAVE_DIR
# download, unpack and build redis
mkdir -p $REDIS_DOWNLOAD_DIR
cd $REDIS_DOWNLOAD_DIR
rm -f $REDIS_PACKAGE
rm -rf $REDIS_BUILD_DIR
wget http://download.redis.io/releases/$REDIS_PACKAGE
tar zxvf $REDIS_PACKAGE
cd $REDIS_BUILD_DIR
make
cp src/redis-server $REDIS_DIR/bin
cp src/redis-cli $REDIS_DIR/bin
cp src/redis-sentinel $REDIS_DIR/bin
popd
#!/usr/bin/env bash
source /home/vagrant/redis-py/build_tools/redis_vars.sh
for filename in `ls $VAGRANT_REDIS_CONF_DIR`; do
# cuts the order prefix off of the filename, e.g. 001-master -> master
PROCESS_NAME=redis-`echo $filename | cut -f 2- -d -`
echo "======================================"
echo "INSTALLING REDIS SERVER: $PROCESS_NAME"
echo "======================================"
# make sure the instance is uninstalled (it should be already)
uninstall_instance $PROCESS_NAME
# base config
mkdir -p $REDIS_CONF_DIR
cp $REDIS_BUILD_DIR/redis.conf $REDIS_CONF_DIR/$PROCESS_NAME.conf
# override config values from file
cat $VAGRANT_REDIS_CONF_DIR/$filename >> $REDIS_CONF_DIR/$PROCESS_NAME.conf
# replace placeholder variables in init.d script
cp $VAGRANT_DIR/redis_init_script /etc/init.d/$PROCESS_NAME
sed -i "s/{{ PROCESS_NAME }}/$PROCESS_NAME/g" /etc/init.d/$PROCESS_NAME
# need to read the config file to find out what port this instance will run on
port=`grep port $VAGRANT_REDIS_CONF_DIR/$filename | cut -f 2 -d " "`
sed -i "s/{{ PORT }}/$port/g" /etc/init.d/$PROCESS_NAME
chmod 755 /etc/init.d/$PROCESS_NAME
# and tell update-rc.d about it
update-rc.d $PROCESS_NAME defaults 98
# save the $PROCESS_NAME into installed instances file
echo $PROCESS_NAME >> $REDIS_INSTALLED_INSTANCES_FILE
# start redis
/etc/init.d/$PROCESS_NAME start
done
#!/usr/bin/env bash
source /home/vagrant/redis-py/build_tools/redis_vars.sh
for filename in `ls $VAGRANT_SENTINEL_CONF_DIR`; do
# cuts the order prefix off of the filename, e.g. 001-master -> master
PROCESS_NAME=sentinel-`echo $filename | cut -f 2- -d -`
echo "========================================="
echo "INSTALLING SENTINEL SERVER: $PROCESS_NAME"
echo "========================================="
# make sure the instance is uninstalled (it should be already)
uninstall_instance $PROCESS_NAME
# base config
mkdir -p $REDIS_CONF_DIR
cp $REDIS_BUILD_DIR/sentinel.conf $REDIS_CONF_DIR/$PROCESS_NAME.conf
# override config values from file
cat $VAGRANT_SENTINEL_CONF_DIR/$filename >> $REDIS_CONF_DIR/$PROCESS_NAME.conf
# replace placeholder variables in init.d script
cp $VAGRANT_DIR/sentinel_init_script /etc/init.d/$PROCESS_NAME
sed -i "s/{{ PROCESS_NAME }}/$PROCESS_NAME/g" /etc/init.d/$PROCESS_NAME
# need to read the config file to find out what port this instance will run on
port=`grep port $VAGRANT_SENTINEL_CONF_DIR/$filename | cut -f 2 -d " "`
sed -i "s/{{ PORT }}/$port/g" /etc/init.d/$PROCESS_NAME
chmod 755 /etc/init.d/$PROCESS_NAME
# and tell update-rc.d about it
update-rc.d $PROCESS_NAME defaults 99
# save the $PROCESS_NAME into installed instances file
echo $PROCESS_NAME >> $SENTINEL_INSTALLED_INSTANCES_FILE
# start redis
/etc/init.d/$PROCESS_NAME start
done
pidfile /var/run/redis-master.pid
bind *
port 6379
daemonize yes
unixsocket /tmp/redis_master.sock
unixsocketperm 777
dbfilename master.rdb
dir /var/lib/redis/backups
pidfile /var/run/redis-slave.pid
bind *
port 6380
daemonize yes
unixsocket /tmp/redis-slave.sock
unixsocketperm 777
dbfilename slave.rdb
dir /var/lib/redis/backups
slaveof 127.0.0.1 6379
#!/bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start redis-server at boot time
# Description: Control redis-server.
### END INIT INFO
REDISPORT={{ PORT }}
PIDFILE=/var/run/{{ PROCESS_NAME }}.pid
CONF=/var/lib/redis/conf/{{ PROCESS_NAME }}.conf
EXEC=/var/lib/redis/bin/redis-server
CLIEXEC=/var/lib/redis/bin/redis-cli
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
#!/usr/bin/env bash
VAGRANT_DIR=/home/vagrant/redis-py/build_tools
VAGRANT_REDIS_CONF_DIR=$VAGRANT_DIR/redis-configs
VAGRANT_SENTINEL_CONF_DIR=$VAGRANT_DIR/sentinel-configs
REDIS_VERSION=3.2.0
REDIS_DOWNLOAD_DIR=/home/vagrant/redis-downloads
REDIS_PACKAGE=redis-$REDIS_VERSION.tar.gz
REDIS_BUILD_DIR=$REDIS_DOWNLOAD_DIR/redis-$REDIS_VERSION
REDIS_DIR=/var/lib/redis
REDIS_BIN_DIR=$REDIS_DIR/bin
REDIS_CONF_DIR=$REDIS_DIR/conf
REDIS_SAVE_DIR=$REDIS_DIR/backups
REDIS_INSTALLED_INSTANCES_FILE=$REDIS_DIR/redis-instances
SENTINEL_INSTALLED_INSTANCES_FILE=$REDIS_DIR/sentinel-instances
function uninstall_instance() {
# Expects $1 to be the init.d filename, e.g. redis-nodename or
# sentinel-nodename
if [ -a /etc/init.d/$1 ]; then
echo "======================================"
echo "UNINSTALLING REDIS SERVER: $1"
echo "======================================"
/etc/init.d/$1 stop
update-rc.d -f $1 remove
rm -f /etc/init.d/$1
fi;
rm -f $REDIS_CONF_DIR/$1.conf
}
function uninstall_all_redis_instances() {
if [ -a $REDIS_INSTALLED_INSTANCES_FILE ]; then
cat $REDIS_INSTALLED_INSTANCES_FILE | while read line; do
uninstall_instance $line;
done;
fi
}
function uninstall_all_sentinel_instances() {
if [ -a $SENTINEL_INSTALLED_INSTANCES_FILE ]; then
cat $SENTINEL_INSTALLED_INSTANCES_FILE | while read line; do
uninstall_instance $line;
done;
fi
}
pidfile /var/run/sentinel-1.pid
port 26379
daemonize yes
# short timeout for sentinel tests
sentinel down-after-milliseconds mymaster 500
pidfile /var/run/sentinel-2.pid
port 26380
daemonize yes
# short timeout for sentinel tests
sentinel down-after-milliseconds mymaster 500
pidfile /var/run/sentinel-3.pid
port 26381
daemonize yes
# short timeout for sentinel tests
sentinel down-after-milliseconds mymaster 500
#!/bin/sh
### BEGIN INIT INFO
# Provides: redis-sentintel
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start redis-sentinel at boot time
# Description: Control redis-sentinel.
### END INIT INFO
SENTINELPORT={{ PORT }}
PIDFILE=/var/run/{{ PROCESS_NAME }}.pid
CONF=/var/lib/redis/conf/{{ PROCESS_NAME }}.conf
EXEC=/var/lib/redis/bin/redis-sentinel
CLIEXEC=/var/lib/redis/bin/redis-cli
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis Sentinel..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $SENTINELPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Sentinel to shutdown ..."
sleep 1
done
echo "Sentinel stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# ubuntu 64bit image
config.vm.box = "hashicorp/precise64"
# map the root of redis-py to /home/vagrant/redis-py
config.vm.synced_folder "../", "/home/vagrant/redis-py"
# install the redis server
config.vm.provision :shell, :path => "../build_tools/bootstrap.sh"
config.vm.provision :shell, :path => "../build_tools/build_redis.sh"
config.vm.provision :shell, :path => "../build_tools/install_redis.sh"
config.vm.provision :shell, :path => "../build_tools/install_sentinel.sh"
config.vm.provision :file, :source => "../build_tools/.bash_profile", :destination => "/home/vagrant/.bash_profile"
# setup forwarded ports
config.vm.network "forwarded_port", guest: 6379, host: 6379
config.vm.network "forwarded_port", guest: 6380, host: 6380
config.vm.network "forwarded_port", guest: 26379, host: 26379
config.vm.network "forwarded_port", guest: 26380, host: 26380
config.vm.network "forwarded_port", guest: 26381, host: 26381
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册