Repository navigation
Expand file tree
/
Copy pathhexo-theme-next-autodeploy.sh
More file actions
213 lines (180 loc) · 7.92 KB
/
Copy pathhexo-theme-next-autodeploy.sh
File metadata and controls
213 lines (180 loc) · 7.92 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/sh
# ============================================================== #
# Shell script to autodeploy Hexo & NexT & NexT website source.
# ============================================================== #
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH
export PATH
# https://en.wikipedia.org/wiki/ANSI_escape_code
#red='\033[0;31m'
#green='\033[0;32m'
#brown='\033[0;33m'
#blue='\033[0;34m'
#purple='\033[0;35m'
cyan='\033[0;36m'
#lgray='\033[0;37m'
#dgray='\033[1;30m'
lred='\033[1;31m'
lgreen='\033[1;32m'
yellow='\033[1;33m'
lblue='\033[1;34m'
lpurple='\033[1;35m'
lcyan='\033[1;36m'
white='\033[1;37m'
norm='\033[0m'
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
# NexT website repo directory
DIR_NAME="next-source"
echo
echo "=============================================================="
echo " ${yellow}Checking starting directory structure...${norm}"
echo "=============================================================="
echo "${lcyan}`pwd`${norm}"
du -sh
du -sh *
echo
echo "=============================================================="
echo " ${lgreen}Installing 'hexo-cli'...${norm}"
echo "=============================================================="
echo "${yellow}Node version:${norm} ${lcyan}`node -v`${norm}"
echo "${yellow}NPM version:${norm} ${lcyan}`npm -v`${norm}"
npm install hexo-cli -g --silent
echo
echo "=============================================================="
echo " ${lgreen}Installing Hexo & NPM modules...${norm}"
echo "=============================================================="
mkdir -vp $DIR_NAME
cd $DIR_NAME
curl --silent -L https://api.github.com/repos/hexojs/hexo-starter/tarball | tar -zxv -C ./ --strip-components=1
npm install --silent
echo
echo "=============================================================="
echo " ${yellow}Checking Hexo version...${norm}"
echo "=============================================================="
hexo -v
echo
echo "=============================================================="
echo " ${lred}Removing unneeded Hexo files...${norm}"
echo "=============================================================="
rm -vf _config.yml
rm -vf .gitmodules
rm -vfr source
rm -vfr themes/landscape
echo
echo "=============================================================="
echo " ${lgreen}Updating or Installing NexT theme & Needed modules...${norm}"
echo "=============================================================="
echo "${yellow}NexT:${norm} ${lcyan}`git -C themes/next pull || git clone https://github.com/theme-next/hexo-theme-next themes/next`${norm}"
echo "${yellow}jquery-lazyload:${norm} ${lcyan}`git -C themes/next/source/lib/jquery_lazyload pull || git clone https://github.com/theme-next/theme-next-jquery-lazyload themes/next/source/lib/jquery_lazyload`${norm}"
echo "${yellow}fancybox:${norm} ${lcyan}`git -C themes/next/source/lib/fancybox pull || git clone https://github.com/theme-next/theme-next-fancybox3 themes/next/source/lib/fancybox`${norm}"
echo
echo "=============================================================="
echo " ${lgreen}Replacing default renderer & Installing needed plugins...${norm}"
echo "=============================================================="
npm un hexo-renderer-marked --save --silent
npm i hexo-renderer-kramed --save --silent
npm i hexo-symbols-count-time --save --silent
npm i hexo-generator-searchdb --save --silent
npm i hexo-generator-feed --save --silent
echo
echo "=============================================================="
echo " ${lpurple}Creating symlinks & Schemes directory...${norm}"
echo "=============================================================="
ln -sv ../source source
ln -sv ../_config.yml _config.yml
mkdir -v schemes
echo
echo "=============================================================="
echo " ${lpurple}Generating content for 'muse.theme-next.org' subdomain...${norm}"
echo "=============================================================="
hexo config url https://muse.theme-next.org
echo "${yellow}Setted url:${norm} ${lcyan}`hexo config url`${norm}"
hexo config theme_config.scheme Muse
echo "${yellow}Setted scheme:${norm} ${lcyan}`hexo config theme_config.scheme`${norm}"
hexo clean && hexo g --silent
echo "${lred}`mv -v public schemes/muse`${norm}"
echo
echo "=============================================================="
echo " ${lpurple}Generating content for 'mist.theme-next.org' subdomain...${norm}"
echo "=============================================================="
hexo config url https://mist.theme-next.org
echo "${yellow}Setted url:${norm} ${lcyan}`hexo config url`${norm}"
hexo config theme_config.scheme Mist
echo "${yellow}Setted scheme:${norm} ${lcyan}`hexo config theme_config.scheme`${norm}"
hexo clean && hexo g --silent
echo "${lred}`mv -v public schemes/mist`${norm}"
echo
echo "=============================================================="
echo " ${lpurple}Generating content for 'pisces.theme-next.org' subdomain...${norm}"
echo "=============================================================="
hexo config url https://pisces.theme-next.org
echo "${yellow}Setted url:${norm} ${lcyan}`hexo config url`${norm}"
hexo config theme_config.scheme Pisces
echo "${yellow}Setted scheme:${norm} ${lcyan}`hexo config theme_config.scheme`${norm}"
hexo clean && hexo g --silent
echo "${lred}`mv -v public schemes/pisces`${norm}"
echo
echo "=============================================================="
echo " ${lpurple}Prepairing content for main 'theme-next.org' domain...${norm}"
echo "=============================================================="
hexo config url https://theme-next.org
echo "${yellow}Setted url:${norm} ${lcyan}`hexo config url`${norm}"
hexo config theme_config.scheme Gemini
echo "${yellow}Setted scheme:${norm} ${lcyan}`hexo config theme_config.scheme`${norm}"
hexo clean && hexo g --silent
echo "${yellow}robots.txt:${norm}"
echo "User-agent: *
Disallow: /page/*/
Disallow: /archives/*
Disallow: /schemes/*
Host: https://theme-next.org" > public/robots.txt
cat public/robots.txt
echo
echo "=============================================================="
echo " ${lpurple}Moving all schemes to public directory...${norm}"
echo "=============================================================="
echo "${lred}`mv -v schemes public`${norm}"
echo
echo "=============================================================="
echo " ${yellow}Checking 'repo' directory structure...${norm}"
echo "=============================================================="
cd ../
echo "${lcyan}`pwd`${norm}"
du -sh
du -sh *
echo
echo "=============================================================="
echo " ${yellow}Checking '$DIR_NAME' directory structure...${norm}"
echo "=============================================================="
cd $DIR_NAME
echo "${lcyan}`pwd`${norm}"
du -sh
du -sh *
echo
echo "=============================================================="
echo " ${yellow}Checking 'public' directory structure...${norm}"
echo "=============================================================="
cd public
echo "${lcyan}`pwd`${norm}"
du -sh
du -sh *
echo
echo "=============================================================="
echo " ${yellow}Checking 'schemes' directory structure...${norm}"
echo "=============================================================="
cd schemes
echo "${lcyan}`pwd`${norm}"
du -sh
du -sh *
echo
echo "=============================================================="
echo " ${lgreen}Done. Beginning to deploy site...${norm}"
echo "=============================================================="