This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspxd.sh
executable file
·119 lines (106 loc) · 3.28 KB
/
spxd.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# spxd bash script to install sphinx-deployment to your sphinx docs project.
#
############################################################################
# Usage:
# spxd.sh [options]
#
# Options:
# -h Help
# -p <docs_path> Install sphinx_deployment to a specified docs path
############################################################################
# Example to install on <your_project/docs>
# $ cd <your_project>
# $ wget https://raw.github.com/teracy-official/sphinx-deployment/master/scripts/spxd.sh && chmod +x ./spxd.sh && ./spxd.sh -p ./docs
#
function command_exists() {
type "$1" &> /dev/null;
}
function require() {
if ! command_exists git ; then
echo "Error: 'git' is required for installation, please install 'git' first."
echo "Installation aborted!"
exit 1
fi
}
function usage() {
echo "Usage:"
echo " spxd.sh [options]"
echo ""
echo "Options:"
echo " -h Help"
echo " -p <docs_path> Install sphinx_deployment to a specified docs path"
}
function install() {
# assume that the current working directory is the root git repository directory
# to copy travis-ci stuff into this directory
local project_root_path=`pwd`
# relative or absolute <docs_path>?
if [[ $1 =~ ^\/ ]]; then
local docs_path=$1
else
local docs_path="$project_root_path/$1"
fi
echo "installing sphinx_deployment to '$docs_path'..."
cd /tmp
rm -rf sphinx-deployment
git clone https://github.com/teracy-official/sphinx-deployment.git
cd sphinx-deployment
git fetch origin
git checkout origin/master
# test
# git clone https://github.com/hoatle/sphinx-deployment.git
# cd sphinx-deployment
# git fetch origin
# git checkout origin/features/3_installation_bash_script
# copy required stuff
echo "copying required files..."
mkdir -p $docs_path
mkdir -p $docs_path/.deploy_heroku
cp -r docs/* $docs_path
cp docs/.gitignore $docs_path
cp -r docs/.deploy_heroku/* $docs_path/.deploy_heroku
cp .travis.yml $project_root_path
mkdir -p $project_root_path/.travis
cp -r .travis/* $project_root_path/.travis
# copy meta stuff
echo "copying meta files..."
cp CHANGELOG.md $docs_path/CHANGELOG_sphinx_deployment.md
cp LICENSE $docs_path/LICENSE_sphinx_deployment
cp README.md $docs_path/README_sphinx_deployment.md
# clean up
cd ..
rm -rf sphinx-deployment
# add sphinx-deployment.mk to Makefile only if not added yet
cd $docs_path
if [ -f Makefile ] && ! grep -q sphinx_deployment.mk Makefile ; then
echo '' >> Makefile
echo 'include sphinx_deployment.mk' >> Makefile
fi
echo ''
echo "installation completed, please read $docs_path/README_sphinx_deployment.md for usage."
}
# check requirements
require
while getopts ":p:h" opt; do
case $opt in
p)
install $OPTARG
exit 0
;;
h)
usage
exit 0
;;
\?)
echo "Invalid options -$OPTARG" >&2
exit 1
;;
:)
if [ $OPTARG == "p" ]; then
echo "Option -$OPTARG requires <docs_path> argument." >&2
fi
exit 1
;;
esac
done