pouet.net/bin/sync
Laurent Raufaste a7a9970a98 Let's put those temp file in a dedicated folder
And start having constants in a centralized file too
2013-05-11 20:33:54 -04:00

91 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
DEBUG=false
SCRIPT_NAME=`basename $0`
LIVE_PATH="/home/hosted/pouet/sites/www.pouet.net"
TEST_PATH="/home/hosted/pouet/sites/test.pouet.net"
RSYNC="rsync --recursive \
--delete \
--progress \
--checksum \
--links\
--keep-dirlinks \
--exclude=avatars \
--exclude=gfx/logos \
--exclude=nfo \
--exclude=othernfo \
--exclude=results \
--exclude=screenshots \
--exclude=include/*.inc \
--exclude=rulez/*.log \
--exclude=cache/* \
--exclude=tmp/* \
--exclude=include/auth.php \
--exclude=.git"
if $DEBUG
then
RSYNC="$RSYNC --dry-run"
fi
function usage()
{
echo "Usage: $SCRIPT_NAME <push|pull> <test|live>"
echo " - $SCRIPT_NAME push test : Push local version to test.pouet.net"
echo " - $SCRIPT_NAME push live : Push local version to pouet.net"
echo " - $SCRIPT_NAME pull test : Pull test.pouet.net locally"
echo " - $SCRIPT_NAME pull live : Pull pouet.net locally"
exit 1
}
copy_cache_from_live_to_test()
{
ssh pouet cp $LIVE_PATH/include/*.inc $TEST_PATH/include/
ssh pouet cp $LIVE_PATH/include/auth.php $TEST_PATH/include/auth.php
}
function push_test()
{
$RSYNC ./ pouet:$TEST_PATH
copy_cache_from_live_to_test
}
function push_live()
{
$RSYNC ./ pouet:$LIVE_PATH
}
function pull_test()
{
$RSYNC pouet:$TEST_PATH/ .
}
function pull_live()
{
$RSYNC pouet:$LIVE_PATH/ .
}
if [ ! -f .git/index ]
then
echo "Error: launch $SCRIPT_NAME at the root of the source folder pls oh pls"
exit 1
fi
case "$1" in
push)
case "$2" in
test) push_test ;;
live) push_live ;;
*) usage ;;
esac
;;
pull)
case "$2" in
test) pull_test ;;
live) pull_live ;;
*) usage ;;
esac
;;
*) usage;;
esac