-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·124 lines (102 loc) · 3.26 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·124 lines (102 loc) · 3.26 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
#!/usr/bin/env bash
set -euo pipefail
HOME_PATH="${HOME}"
GHOST_INSTALL="${HOME_PATH}/.ghost"
GHOST_PORT="${GHOST_PORT:-2373}"
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
ABSOLUTE_PATH="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$ABSOLUTE_PATH/$SOURCE"
done
ABSOLUTE_PATH="$(cd -P "$(dirname "$SOURCE")" && pwd)"
# shellcheck source=includes/lib/common.sh
source "${ABSOLUTE_PATH}/includes/lib/common.sh"
SKIP_DEPLOY=0
usage() {
echo "Usage: install.sh [--skip-deploy]"
echo ""
echo " Sets up Ghost on your computer and prepares publishing to GitHub Pages."
}
while [ $# -gt 0 ]; do
case "$1" in
--skip-deploy)
SKIP_DEPLOY=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
die "Unknown option: $1"
;;
esac
done
info "Ghost on GitHub Pages v${SCRIPT_VERSION}"
info "This may take several minutes. Please keep this window open."
require_command node
require_command npm
require_command wget
if [ -d "$GHOST_INSTALL" ] && [ ! -d "${GHOST_PATH}" ]; then
die "A partial install was found at ${GHOST_INSTALL}. Run ./migrate.sh if upgrading from v2, or remove that folder and try again."
fi
local_setup() {
if [ -d "${GHOST_PATH}" ]; then
info "Your blog folder already exists at ${GHOST_INSTALL}"
return 0
fi
info "Creating your blog folder at ${GHOST_INSTALL}..."
mkdir -p "$GHOST_INSTALL"
cd "$GHOST_INSTALL" || die "Could not create your blog folder."
info "Installing Ghost (the blogging software)..."
npm install -g ghost-cli@latest
info "Setting up Ghost on your computer..."
if ! ghost install local --no-start --enable --port "$GHOST_PORT"; then
die "Ghost could not be installed. See docs/TROUBLESHOOTING.md"
fi
if ! ghost_current_ready; then
die "Ghost install did not finish correctly. See docs/TROUBLESHOOTING.md"
fi
}
move_includes() {
if ! ghost_current_ready; then
die "Ghost is not ready yet. Install cannot continue."
fi
cp "${ABSOLUTE_PATH}/includes/deploy.sh" "${GHOST_INSTALL}/"
cp "${ABSOLUTE_PATH}/includes/uninstall.sh" "${GHOST_INSTALL}/"
cp -R "${ABSOLUTE_PATH}/includes/lib" "${GHOST_INSTALL}/lib"
mkdir -p "${GHOST_INSTALL}/scripts"
cp "${ABSOLUTE_PATH}/scripts/validate-static.sh" "${GHOST_INSTALL}/scripts/"
chmod +x "${GHOST_INSTALL}/scripts/validate-static.sh"
cp "${ABSOLUTE_PATH}/includes/index.html" "${GHOST_PATH}/"
cp "${ABSOLUTE_PATH}/includes/gitignore.base" "${GHOST_PATH}/"
cp "${ABSOLUTE_PATH}/includes/gitignore.base" "${GHOST_PATH}/.gitignore"
chmod +x "${GHOST_INSTALL}/deploy.sh"
chmod +x "${GHOST_INSTALL}/uninstall.sh"
}
local_run() {
cd "$GHOST_INSTALL" || die "Could not open your blog folder."
info "Starting your local blog..."
ghost start --enable || die "Could not start Ghost. Try: cd ~/.ghost && ghost start"
configure_ghost_url
}
ensure_gssg
local_setup
move_includes
local_run
info "Install finished!"
info "Open your blog editor at: http://localhost:${GHOST_PORT}/ghost"
info "When you are ready to go live, run: cd ~/.ghost && ./deploy.sh"
if [ "$SKIP_DEPLOY" -eq 0 ]; then
echo ""
read -r -p "Publish your blog to GitHub Pages now? [y/N] " answer
case "$answer" in
[yY]|[yY][eE][sS])
(cd "$GHOST_INSTALL" && ./deploy.sh)
;;
*)
info "Skipped first publish. Run ./deploy.sh anytime from ~/.ghost"
;;
esac
fi