Skip to content

Commit eddb8e5

Browse files
committed
✏️ Code styling tweaks
1 parent fce253c commit eddb8e5

File tree

3 files changed

+62
-58
lines changed

3 files changed

+62
-58
lines changed

bookstack/rootfs/etc/cont-init.d/bookstack.sh

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,86 @@
33
# Home Assistant Community Add-on: Bookstack
44
# This file validates config, creates the database and configures the app key
55
# ==============================================================================
6-
6+
declare host
77
declare key
8+
declare password
9+
declare port
10+
declare username
11+
12+
if bashio::config.has_value 'remote_mysql_host'; then
13+
if ! bashio::config.has_value 'remote_mysql_database'; then
14+
bashio::exit.nok \
15+
"Remote database has been specified but no database is configured"
16+
fi
17+
18+
if ! bashio::config.has_value 'remote_mysql_username'; then
19+
bashio::exit.nok \
20+
"Remote database has been specified but no username is configured"
21+
fi
822

9-
if bashio::config.has_value 'remote_mysql_host';then
10-
if ! bashio::config.has_value 'remote_mysql_database';then
11-
bashio::log.fatal \
12-
"Remote database has been specified but no database is configured"
13-
bashio::exit.nok
14-
fi
15-
if ! bashio::config.has_value 'remote_mysql_username';then
16-
bashio::log.fatal \
17-
"Remote database has been specified but no username is configured"
18-
bashio::exit.nok
19-
fi
20-
if ! bashio::config.has_value 'remote_mysql_password';then
21-
bashio::log.fatal \
22-
"Remote database has been specified but no password is configured"
23-
bashio::exit.nok
24-
fi
25-
if ! bashio::config.exists 'remote_mysql_port';then
26-
bashio::log.fatal \
27-
"Remote database has been specified but no port is configured"
28-
bashio::exit.nok
29-
fi
23+
if ! bashio::config.has_value 'remote_mysql_password'; then
24+
bashio::log.fatal \
25+
"Remote database has been specified but no password is configured"
26+
fi
27+
28+
if ! bashio::config.exists 'remote_mysql_port'; then
29+
bashio::exit.nok \
30+
"Remote database has been specified but no port is configured"
31+
fi
3032
else
31-
if ! bashio::services.available 'mysql';then
32-
bashio::log.fatal \
33-
"Local database access should be provided by the MariaDB addon"
34-
bashio::log.fatal \
35-
"Please ensure it is installed and started"
36-
bashio::exit.nok
37-
fi
38-
host=$(bashio::services "mysql" "host")
39-
password=$(bashio::services "mysql" "password")
40-
port=$(bashio::services "mysql" "port")
41-
username=$(bashio::services "mysql" "username")
33+
if ! bashio::services.available 'mysql'; then
34+
bashio::log.fatal \
35+
"Local database access should be provided by the MariaDB addon"
36+
bashio::exit.nok \
37+
"Please ensure it is installed and started"
38+
fi
39+
40+
host=$(bashio::services "mysql" "host")
41+
password=$(bashio::services "mysql" "password")
42+
port=$(bashio::services "mysql" "port")
43+
username=$(bashio::services "mysql" "username")
44+
45+
bashio::log.warning "Bookstack is using the Maria DB addon"
46+
bashio::log.warning "Please ensure this is included in your backups"
47+
bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
4248

43-
bashio::log.warning "Bookstack is using the Maria DB addon"
44-
bashio::log.warning "Please ensure this is included in your backups"
45-
bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
46-
bashio::log.info "Creating database for Bookstack if required"
47-
mysql \
48-
-u "${username}" -p"${password}" \
49-
-h "${host}" -P "${port}" \
50-
-e "CREATE DATABASE IF NOT EXISTS \`bookstack\` ;"
51-
49+
bashio::log.info "Creating database for Bookstack if required"
50+
mysql \
51+
-u "${username}" -p"${password}" \
52+
-h "${host}" -P "${port}" \
53+
-e "CREATE DATABASE IF NOT EXISTS \`bookstack\` ;"
5254
fi
55+
5356
if ! bashio::fs.directory_exists "/data/bookstack/uploads"; then
5457
bashio::log "Creating uploads directory"
5558
mkdir -p /data/bookstack/uploads
5659
chown nginx:nginx /data/bookstack/uploads
5760
fi
61+
5862
if ! bashio::fs.directory_exists "/data/bookstack/files"; then
5963
bashio::log "Creating files directory"
6064
mkdir -p /data/bookstack/files
6165
chown nginx:nginx /data/bookstack/files
6266
fi
67+
6368
if ! bashio::fs.directory_exists "/data/bookstack/images"; then
6469
bashio::log "Creating images directory"
6570
mkdir -p /data/bookstack/images
6671
chown nginx:nginx /data/bookstack/images
6772
fi
73+
6874
rm -r /var/www/bookstack/storage/uploads/files
6975
rm -r /var/www/bookstack/storage/uploads/images
7076
rm -r /var/www/bookstack/public/uploads
7177
ln -s /data/bookstack/files /var/www/bookstack/storage/uploads/files
7278
ln -s /data/bookstack/images /var/www/bookstack/storage/uploads/images
7379
ln -s /data/bookstack/uploads /var/www/bookstack/public/uploads
80+
ln -sf /dev/stderr /var/www/bookstack/storage/logs/laravel.log
7481

7582
# Create API key if needed
7683
if ! bashio::fs.file_exists "/data/bookstack/appkey.txt"; then
77-
bashio::log.info "Generating app key"
78-
key=$(php /var/www/bookstack/artisan key:generate --show)
79-
echo "${key}" > /data/bookstack/appkey.txt
80-
bashio::log.info "App Key generated: ${key}"
84+
bashio::log.info "Generating app key"
85+
key=$(php /var/www/bookstack/artisan key:generate --show)
86+
echo "${key}" > /data/bookstack/appkey.txt
87+
bashio::log.info "App Key generated: ${key}"
8188
fi
82-
ln -sf /dev/stderr /var/www/bookstack/storage/logs/laravel.log

bookstack/rootfs/etc/cont-init.d/nginx.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ if bashio::var.has_value "${admin_port}"; then
1919
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
2020
sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/servers/direct.conf
2121
sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct.conf
22-
2322
else
2423
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
2524
fi
26-
2725
sed -i "s/%%port%%/80/g" /etc/nginx/servers/direct.conf
2826
fi
2927

bookstack/rootfs/etc/services.d/php-fpm/run

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
# Home Assistant Community Add-on: Bookstack
44
# Runs the PHP-FPM daemon
55
# ==============================================================================
6-
declare key
7-
key=$(cat /data/bookstack/appkey.txt)
8-
export APP_KEY=${key}
6+
export APP_KEY
7+
export DB_DATABASE
8+
export DB_HOST
9+
export DB_PASSWORD
10+
export DB_PORT
11+
export DB_USERNAME
12+
13+
APP_KEY=$(cat /data/bookstack/appkey.txt)
14+
915
if bashio::config.has_value 'remote_mysql_host';then
1016
DB_HOST=$(bashio::config "remote_mysql_host")
1117
DB_DATABASE=$(bashio::config "remote_mysql_database")
@@ -20,12 +26,6 @@ else
2026
DB_PORT=$(bashio::services "mysql" "port")
2127
fi
2228

23-
export DB_HOST
24-
export DB_DATABASE
25-
export DB_USERNAME
26-
export DB_PASSWORD
27-
export DB_PORT
28-
2929
bashio::log.info "Installing/updating Database"
3030
php /var/www/bookstack/artisan migrate --force
3131

0 commit comments

Comments
 (0)