forked from WeiYUN13/hexo_in_docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_hexo_server.sh
executable file
·31 lines (27 loc) · 985 Bytes
/
start_hexo_server.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
GIT_USERNAME=$1
GIT_EMAIL=$2
GIT_SSH_KEY=$3
HEXO_SERVER_PORT=$4
# check if there is already a mount volume
if [[ "$(ls -A /blog)" ]]; then
echo "Blog already exists, continuing"
else
echo "Start initialize blog"
hexo init
git clone https://github.com/fluid-dev/hexo-theme-fluid.git ./themes/fluid
rm -rf ./themes/fluid/.git
fi
npm install
npm install hexo-deployer-git --save
# set up ssh key for deployment to github page
echo "**Setting GIT_SSH_KEY as github ssh key**"
echo "**Please make sure the ssh public key has already be set in github**"
git config --global user.name "${GIT_USERNAME}"
git config --global user.email "${GIT_EMAIL}}"
mkdir -p ~/.ssh && echo "${GIT_SSH_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com > ~/.ssh/known_hosts 2>/dev/null
# start hexo server
echo "**Start hexo server on port ${HEXO_SERVER_PORT}**"
echo "**Please check the blog at localhost:${HEXO_SERVER_PORT}**"
hexo server -d -p ${HEXO_SERVER_PORT}