Skip to content

Commit 8e50573

Browse files
authored
Ghost CMS and mySQL module (#627)
* MySQL container module with interactive setup and metadata * Add and join Ghost CMS We rather use predefine settings for sql database to simplify installation
1 parent 35947ca commit 8e50573

File tree

10 files changed

+336
-0
lines changed

10 files changed

+336
-0
lines changed

tools/include/images/GHOST1.png

22.7 KB
Loading

tools/include/images/MYSQL1.png

4.31 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== "Configuration"
2+
3+
Initial setup includes:
4+
- automatic database schema setup on first run
5+
- admin account created via web interface
6+
- Default port: `9190`
7+
- Admin URL: `http://<your.IP>:9190/ghost` (or behind reverse proxy like SWAG)
8+
- Site: `http://<your.IP>:9190`
9+
10+
=== "Directories"
11+
12+
- Install directory: `/armbian/ghost`
13+
- Content volume mounted to: `/armbian/ghost/content`
14+
15+
=== "View logs"
16+
17+
```sh
18+
docker logs -f ghost
19+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ghost is a powerful open-source publishing platform designed for professional publishing, newsletters, and modern blogs. It’s built on Node.js and provides a clean, fast, and customizable CMS experience.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
=== "Configuration"
2+
3+
Database access configuration is done at first install:
4+
- create root password
5+
- create database
6+
- create normal user
7+
- create password for normal user
8+
9+
- Database host: `<your.IP>`
10+
11+
=== "Directories"
12+
13+
- Install directory: `/armbian/mysql`
14+
- Data volume mounted to: `/armbian/mysql/data`
15+
16+
=== "View logs"
17+
18+
```sh
19+
docker logs -f mysql
20+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MySQL is one of the world’s most widely used open-source database servers. Trusted for decades in web, cloud, and enterprise applications.

tools/json/config.software.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,38 @@
330330
"id": "Database",
331331
"description": "SQL database servers and web interface managers",
332332
"sub": [
333+
{
334+
"id": "MYSQL1",
335+
"description": "MySQL SQL database server",
336+
"short": "MySQL",
337+
"module": "module_mysql",
338+
"command": [
339+
"module_mysql install"
340+
],
341+
"status": "Stable",
342+
"author": "@armbian",
343+
"condition": "! module_mysql status"
344+
},
345+
{
346+
"id": "MYSQL2",
347+
"description": "MySQL remove",
348+
"command": [
349+
"module_mysql remove"
350+
],
351+
"status": "Stable",
352+
"author": "@armbian",
353+
"condition": "module_mysql status"
354+
},
355+
{
356+
"id": "MYSQL3",
357+
"description": "MySQL purge with data folder",
358+
"command": [
359+
"module_mysql purge"
360+
],
361+
"status": "Stable",
362+
"author": "@armbian",
363+
"condition": "module_mysql status"
364+
},
333365
{
334366
"id": "DAT001",
335367
"description": "Mariadb SQL database server",
@@ -2293,6 +2325,38 @@
22932325
"status": "Stable",
22942326
"author": "@igorpecovnik",
22952327
"condition": "module_swag status"
2328+
},
2329+
{
2330+
"id": "GHOST1",
2331+
"description": "Ghost CMS install",
2332+
"short": "Ghost",
2333+
"module": "module_ghost",
2334+
"command": [
2335+
"module_ghost install"
2336+
],
2337+
"status": "Stable",
2338+
"author": "@armbian",
2339+
"condition": "! module_ghost status"
2340+
},
2341+
{
2342+
"id": "GHOST2",
2343+
"description": "Ghost CMS remove",
2344+
"command": [
2345+
"module_ghost remove"
2346+
],
2347+
"status": "Stable",
2348+
"author": "@armbian",
2349+
"condition": "module_ghost status"
2350+
},
2351+
{
2352+
"id": "GHOST3",
2353+
"description": "Ghost CMS purge with data folder",
2354+
"command": [
2355+
"module_ghost purge"
2356+
],
2357+
"status": "Stable",
2358+
"author": "@igorpecovnik",
2359+
"condition": "module_ghost status"
22962360
}
22972361
]
22982362
}

tools/modules/runtime/config.runtime.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,5 @@ update_sub_submenu_data "Software" "Downloaders" "RDR002" "http://$LOCALIPADD:${
168168
update_sub_submenu_data "Software" "Downloaders" "DOW026" "http://$LOCALIPADD:${module_options["module_prowlarr,port"]}"
169169
update_sub_submenu_data "Software" "Downloaders" "JEL002" "http://$LOCALIPADD:${module_options["module_jellyseerr,port"]}"
170170

171+
# web
172+
update_sub_submenu_data "Software" "WebHosting" "GHOST2" "http://$LOCALIPADD:${module_options["module_ghost,port"]}/ghost"
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
module_options+=(
2+
["module_ghost,author"]="@igorpecovnik"
3+
["module_ghost,maintainer"]="@igorpecovnik"
4+
["module_ghost,feature"]="module_ghost"
5+
["module_ghost,example"]="install remove purge status help"
6+
["module_ghost,desc"]="Install Ghost CMS container"
7+
["module_ghost,status"]="Active"
8+
["module_ghost,doc_link"]="https://ghost.org/docs/"
9+
["module_ghost,group"]="WebHosting"
10+
["module_ghost,port"]="9190"
11+
["module_ghost,arch"]="x86-64 arm64"
12+
)
13+
14+
#
15+
# Module ghost
16+
#
17+
function module_ghost () {
18+
local title="ghost"
19+
local condition=$(which "$title" 2>/dev/null)
20+
21+
if pkg_installed docker-ce; then
22+
local container=$(docker container ls -a | mawk '/(^|[[:space:]])ghost([[:space:]]|$)/{print $1}')
23+
local image=$(docker image ls -a | mawk '/(^|[[:space:]])ghost([[:space:]]|$)/{print $1":"$2}')
24+
fi
25+
26+
GHOST_BASE="${SOFTWARE_FOLDER}/ghost"
27+
28+
local commands
29+
IFS=' ' read -r -a commands <<< "${module_options["module_ghost,example"]}"
30+
31+
case $1 in
32+
"${commands[0]}")
33+
34+
# instatall mysql if not installed
35+
if ! module_mysql status; then
36+
module_mysql install
37+
fi
38+
39+
# exit if ghost is already running
40+
if module_ghost status; then
41+
exit 0
42+
fi
43+
44+
MYSQL_USER="${2:-armbian}"
45+
MYSQL_PASSWORD="${3:-armbian}"
46+
47+
[[ -d "$GHOST_BASE" ]] || mkdir -p "$GHOST_BASE" || { echo "Couldn't create storage directory: $GHOST_BASE"; exit 1; }
48+
docker pull ghost:5-alpine
49+
docker run -d \
50+
--name ghost \
51+
--net=lsio \
52+
--restart unless-stopped \
53+
-e database__client=mysql \
54+
-e database__connection__host="mysql" \
55+
-e database__connection__user="${MYSQL_USER}" \
56+
-e database__connection__password="${MYSQL_PASSWORD}" \
57+
-e database__connection__database="ghost" \
58+
-p ${module_options["module_ghost,port"]}:2368 \
59+
-e url=http://$LOCALIPADD:${module_options["module_ghost,port"]} \
60+
-v "$GHOST_BASE:/var/lib/ghost/content" \
61+
ghost:5-alpine
62+
;;
63+
"${commands[1]}")
64+
if pkg_installed docker-ce; then
65+
local container=$(docker container ls -a | mawk '/(^|[[:space:]])ghost([[:space:]]|$)/{print $1}')
66+
local image=$(docker image ls -a | mawk '/(^|[[:space:]])ghost([[:space:]]|$)/{print $1":"$2}')
67+
fi
68+
if [[ "${container}" ]]; then
69+
docker container rm -f "$container" >/dev/null
70+
fi
71+
if [[ "${image}" ]]; then
72+
docker image rm "$image" >/dev/null
73+
fi
74+
;;
75+
"${commands[2]}")
76+
${module_options["module_ghost,feature"]} ${commands[1]}
77+
if [[ -n "${GHOST_BASE}" && "${GHOST_BASE}" != "/" ]]; then
78+
rm -rf "${GHOST_BASE}"
79+
fi
80+
;;
81+
"${commands[3]}")
82+
if pkg_installed docker-ce; then
83+
local container=$(docker container ls -a | mawk '/(^|[[:space:]])ghost([[:space:]]|$)/{print $1}')
84+
local image=$(docker image ls -a | mawk '/(^|[[:space:]])ghost([[:space:]]|$)/{print $1":"$2}')
85+
fi
86+
if [[ "${container}" && "${image}" ]]; then
87+
return 0
88+
else
89+
return 1
90+
fi
91+
;;
92+
"${commands[4]}")
93+
echo -e "\nUsage: ${module_options["module_ghost,feature"]} <command>"
94+
echo -e "Commands: ${module_options["module_ghost,example"]}"
95+
echo "Available commands:"
96+
echo -e "\tinstall\t- Install $title."
97+
echo -e "\t Optionally accepts arguments:"
98+
echo -e "\t db_host db_user db_pass db_name url"
99+
echo -e "\tremove\t- Remove $title."
100+
echo -e "\tpurge\t- Purge $title image and data."
101+
echo -e "\tstatus\t- Show container status."
102+
echo
103+
;;
104+
*)
105+
module_ghost "${commands[4]}"
106+
;;
107+
esac
108+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
module_options+=(
2+
["module_mysql,author"]="@igorpecovnik"
3+
["module_mysql,maintainer"]="@igorpecovnik"
4+
["module_mysql,feature"]="module_mysql"
5+
["module_mysql,example"]="install remove purge status help"
6+
["module_mysql,desc"]="Install mysql container"
7+
["module_mysql,status"]="Active"
8+
["module_mysql,doc_link"]="https://hub.docker.com/_/mysql"
9+
["module_mysql,group"]="Database"
10+
["module_mysql,port"]="3306"
11+
["module_mysql,arch"]="x86-64 arm64"
12+
)
13+
#
14+
# Module mysql
15+
#
16+
function module_mysql () {
17+
local title="mysql"
18+
local condition=$(which "$title" 2>/dev/null)
19+
20+
if pkg_installed docker-ce; then
21+
local container=$(docker container ls -a | mawk '/mysql?( |$)/{print $1}')
22+
local image=$(docker image ls -a | mawk '/mysql?( |$)/{print $1":"$2}')
23+
fi
24+
25+
local commands
26+
IFS=' ' read -r -a commands <<< "${module_options["module_mysql,example"]}"
27+
28+
MYSQL_BASE="${SOFTWARE_FOLDER}/mysql"
29+
30+
case $1 in
31+
"${commands[0]}")
32+
33+
if module_mysql status; then
34+
echo "deb"
35+
exit 0
36+
fi
37+
38+
pkg_installed docker-ce || module_docker install
39+
# get parameters or fallback to dialog
40+
MYSQL_ROOT_PASSWORD="${2:-armbian}"
41+
MYSQL_DATABASE="${3:-armbian}"
42+
MYSQL_USER="${4:-armbian}"
43+
MYSQL_PASSWORD="${5:-armbian}"
44+
45+
[[ -d "$MYSQL_BASE" ]] || mkdir -p "$MYSQL_BASE" || { echo "Couldn't create storage directory: $MYSQL_BASE"; exit 1; }
46+
47+
docker pull mysql:lts
48+
docker run -d \
49+
--name mysql \
50+
--net=lsio \
51+
-e MYSQL_ROOT_PASSWORD="${MYSQL_ROOT_PASSWORD:-armbian}" \
52+
-e MYSQL_DATABASE="${MYSQL_DATABASE:-armbian}" \
53+
-e MYSQL_USER="${MYSQL_USER:-armbian}" \
54+
-e MYSQL_PASSWORD="${MYSQL_PASSWORD:-armbian}" \
55+
-v "${MYSQL_BASE}:/var/lib/mysql" \
56+
-p 3306:3306 \
57+
--restart unless-stopped \
58+
mysql:lts
59+
60+
until docker exec mysql \
61+
env MYSQL_PWD="$MYSQL_ROOT_PASSWORD" \
62+
mysql -uroot -e "SELECT 1;" &>/dev/null; do
63+
echo "⏳ Waiting for MySQL to accept connections..."
64+
sleep 2
65+
done
66+
67+
MYSQL_DATABASES=("ghost") # Add any additional databases you want to create here
68+
for MYSQL_DATABASE in "${MYSQL_DATABASES[@]}"; do
69+
echo "⏳ Creating database: $MYSQL_DATABASE and granting privileges..."
70+
71+
docker exec -i mysql \
72+
env MYSQL_PWD="$MYSQL_ROOT_PASSWORD" \
73+
mysql -uroot <<-EOF
74+
CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\`;
75+
GRANT ALL PRIVILEGES ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%';
76+
FLUSH PRIVILEGES;
77+
EOF
78+
done
79+
;;
80+
"${commands[1]}")
81+
if [[ "${container}" ]]; then
82+
docker container rm -f "$container" >/dev/null
83+
fi
84+
if [[ "${image}" ]]; then
85+
docker image rm "$image" >/dev/null
86+
fi
87+
;;
88+
"${commands[2]}")
89+
${module_options["module_mysql,feature"]} ${commands[1]}
90+
if [[ -n "${MYSQL_BASE}" && "${MYSQL_BASE}" != "/" ]]; then
91+
rm -rf "${MYSQL_BASE}"
92+
fi
93+
;;
94+
"${commands[3]}")
95+
if pkg_installed docker-ce; then
96+
local container=$(docker container ls -a | mawk '/mysql?( |$)/{print $1}')
97+
local image=$(docker image ls -a | mawk '/mysql?( |$)/{print $1":"$2}')
98+
fi
99+
if [[ "${container}" && "${image}" ]]; then
100+
return 0
101+
else
102+
return 1
103+
fi
104+
;;
105+
"${commands[4]}")
106+
echo -e "\nUsage: ${module_options["module_mysql,feature"]} <command>"
107+
echo -e "Commands: ${module_options["module_mysql,example"]}"
108+
echo "Available commands:"
109+
echo -e "\tinstall\t- Install $title."
110+
echo -e "\t Optionally accepts arguments:"
111+
echo -e "\t root_password database user user_password"
112+
echo -e "\tremove\t- Remove $title."
113+
echo -e "\tpurge\t- Purge $title data folder."
114+
echo -e "\tstatus\t- Installation status $title."
115+
echo
116+
;;
117+
*)
118+
${module_options["module_mysql,feature"]} ${commands[4]}
119+
;;
120+
esac
121+
}

0 commit comments

Comments
 (0)