-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_dev_server.sh
executable file
·95 lines (85 loc) · 1.66 KB
/
run_dev_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
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
#!/bin/bash
## Colors
##-------
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
LIME_YELLOW=$(tput setaf 190)
POWDER_BLUE=$(tput setaf 153)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
BRIGHT=$(tput bold)
NORMAL=$(tput sgr0)
BLINK=$(tput blink)
REVERSE=$(tput smso)
UNDERLINE=$(tput smul)
## Size
##-----
LINES=$(tput lines)
COLUMNS=$(tput cols)
## Log file
##---------
LOG=gen_doc.log
# Helper functions
#-----------------
function echoerr()
{
echo $@ 1>&2
}
function echolog()
{
echo $@
#echo $@ > $LOG
}
function title_helper()
{
CHAR=$1
shift
CONTENT="$CHAR $* $CHAR"
BORDER=$(echo "$CONTENT" | sed "s/./$CHAR/g")
echolog ""
echolog "$BORDER"
echolog "$CONTENT"
echolog "$BORDER"
}
function title()
{
title_helper "-" "$@"
}
## Task function
##--------------
function task
{
INFO_STRING=$1
TEXT_LENGTH=${#INFO_STRING}
MAX_SPACING=$(($COLUMNS<80?$COLUMNS:80))
SPACES=`expr $MAX_SPACING - $TEXT_LENGTH`
printf "$INFO_STRING"
STDERR_FILE=$(mktemp)
$2 >> $LOG 2>$STDERR_FILE
STATUS=$?
if [ $STATUS -eq 0 ]; then
printf "%${SPACES}s\n" "${GREEN}[OK]${NORMAL}"
cat $STDERR_FILE
else
printf "%${SPACES}s\n" "${RED}[FAIL]${NORMAL}"
cat $STDERR_FILE
exit 1
fi
}
# Clean up
echo "" >> $LOG
echo "" >> $LOG
echo "" >> $LOG
date >> $LOG
echo "-----------------------------" >> $LOG
title "Deploy a development server at 0.0.0.0:8000"
function start_server
{
cd docs/output/html/
python -m http.server
}
task "Serving docs on development server (0.0.0.0:8000)..." start_server