forked from akeneo/pim-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
54 lines (48 loc) · 2.23 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash -e
usage(){
echo "Usage: $0 <version> [--uid <uid>] [--gid <gid] [ [--deploy --host <host> --port <port> --username <username>]"
echo " version The version to build (e.g. 1.7 or master)"
echo " --deploy Deploy to the server"
echo " --host <host> Host used for deployment"
echo " --port <port> Port used for deployment"
echo " --username <username> Username used for deployment"
echo " --uid <user_id> User id for documentation generation"
echo " --gid <group_id> Group id for documentation generation"
}
DEPLOY=false
HOST=docs-staging.akeneo.com
PORT=GIMMETHEREALPORT
USERNAME=GIMMETHEREALUSER
CUSTOM_UID=`id -u`
CUSTOM_GID=`id -g`
VERSION=$1; shift; echo "Building version $VERSION..."
while true; do
case "$1" in
-d | --deploy ) echo "Enable deployment..."; DEPLOY=true; shift ;;
-h | --host ) echo "Set host to $2..."; HOST=$2; shift 2 ;;
-p | --port ) echo "Set port to $2..."; PORT=$2; shift 2 ;;
-u | --username ) echo "Set username to $2..."; USERNAME=$2; shift 2 ;;
--uid ) CUSTOM_UID=$2; shift 2 ;;
--gid ) CUSTOM_GID=$2; shift 2 ;;
-- ) shift; break ;;
* ) break ;;
esac
done
if [ "$DEPLOY" == true ]; then
echo "Trying connection to $USERNAME@$HOST:$PORT..."
mkdir ~/.ssh/
touch ~/.ssh/known_hosts
ssh-keyscan -H -p $PORT $HOST >> ~/.ssh/known_hosts
ssh -p $PORT $USERNAME@$HOST exit || exit 0
echo "Connection OK"
fi
wget http://demo.akeneo.com/css/pim.css -P /home/akeneo/pim-docs/pim-community-dev-${VERSION}/web/css
rm -rf /home/akeneo/pim-docs/data/pim-docs-build/web
sed -i -e "s/^version =.*/version = '${VERSION}'/" /home/akeneo/pim-docs/data/conf.py
sphinx-build -b html /home/akeneo/pim-docs/data /home/akeneo/pim-docs/data/pim-docs-build
cp -L -r /home/akeneo/pim-docs/pim-community-dev-${VERSION}/web /home/akeneo/pim-docs/data/pim-docs-build/
cp -r /home/akeneo/pim-docs/data/design_pim/styleguide /home/akeneo/pim-docs/data/pim-docs-build/design_pim/
find /home/akeneo/pim-docs/data/pim-docs-build/ -exec chown $CUSTOM_UID:$CUSTOM_GID {} \;
if [ "$DEPLOY" == true ]; then
rsync -e "ssh -p $PORT" -avz /home/akeneo/pim-docs/data/pim-docs-build/* $USERNAME@$HOST:/var/www/${VERSION}
fi