forked from theme-next/theme-next.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhexo-theme-next-autoinstall.sh
More file actions
89 lines (77 loc) · 3.13 KB
/
hexo-theme-next-autoinstall.sh
File metadata and controls
89 lines (77 loc) · 3.13 KB
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
#!/bin/sh
# ================================================================== #
# Shell script to autoinstall Hexo & NexT & NexT website source.
# ================================================================== #
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
red='\033[00;31m'
green='\033[00;32m'
yellow='\033[00;33m'
blue='\033[01;34m'
norm='\033[00m'
bold='\033[1m'
column=50
alignment="\\033[${column}G"
# Status variables.
C_OK="$alignment [ ${green} OK ${norm} ]\n"
C_OK_BOLD="$alignment ${green}[ ${bold} OK ${green} ]${norm}\n"
C_NO="$alignment [ ${red} NO ${norm} ]\n"
C_NO_BOLD="$alignment ${red}[ ${bold} NO ${red} ]${norm}\n"
# Arguments.
EXPECTED_ARGS=1
if [ $# -ne $EXPECTED_ARGS ]; then
read -p "Enter root directory name for your blog (press enter to default \"theme-next.org\"): " DIR_NAME
DIR_NAME=${DIR_NAME:-theme-next.org}
echo
echo -e "${yellow}For command line usage:${norm} $0 ${blue}blogname ${norm}"
else
DIR_NAME="$1"
fi
echo
echo "=============================================================="
echo " Installing Hexo & NPM modules..."
echo "=============================================================="
mkdir $DIR_NAME
cd $DIR_NAME
curl -L https://api.github.com/repos/hexojs/hexo-starter/tarball | tar -zxv -C ./ --strip-components=1
npm install
echo
echo "=============================================================="
echo " Checking Hexo version..."
echo "=============================================================="
hexo -v
echo
echo "=============================================================="
echo " Removing unneeded Hexo files..."
echo "=============================================================="
rm -vf _config.yml
rm -vf .gitmodules
rm -vfr source
rm -vfr themes/landscape
echo
echo "=============================================================="
echo " Cloning NexT theme & Adding needed modules..."
echo "=============================================================="
git clone https://github.com/theme-next/hexo-theme-next themes/next
git clone https://github.com/theme-next/theme-next-jquery-lazyload themes/next/source/lib/jquery_lazyload
echo
echo "=============================================================="
echo " Replacing default renderer & Installing needed plugins..."
echo "=============================================================="
npm un hexo-renderer-marked --save
npm i hexo-renderer-kramed --save
npm i hexo-deployer-git --save
npm i hexo-symbols-count-time --save
echo
echo "=============================================================="
echo " Cloning NexT website \"source\" branch & Creating symlinks..."
echo "=============================================================="
git clone -b source --single-branch https://github.com/theme-next/theme-next.org.git next-source
ln -s next-source/source source
ln -s source/../_config.yml _config.yml
echo
echo "=============================================================="
echo " Strarting Hexo server on \"http://localhost:4000\"..."
echo "=============================================================="
hexo s
echo