Skip to content

Commit cae06d8

Browse files
committed
Fix shellcheck issues
1 parent 2818e27 commit cae06d8

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

scripts/migrate.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ readonly GHOST_UID=1000
77
readonly GHOST_GID=1000
88
readonly MYSQL_TIMEOUT=120
99
readonly DISK_SPACE_SAFETY_FACTOR=1.5
10-
readonly SCRIPT_NAME=$(basename "$0")
1110
readonly TEMP_SQL_FILE="${PWD}/data/ghost_import.sql"
1211
readonly RECOVERY_SCRIPT="${PWD}/recovery_instructions.sh"
1312

@@ -191,8 +190,10 @@ migrate_content() {
191190

192191
# Export and import database
193192
migrate_database() {
194-
local mysql_host=$(jq -r < "${current_location}/config.production.json" '.database.connection.host')
195-
local mysql_database=$(jq -r < "${current_location}/config.production.json" '.database.connection.database')
193+
local mysql_host
194+
local mysql_database
195+
mysql_host=$(jq -r < "${current_location}/config.production.json" '.database.connection.host')
196+
mysql_database=$(jq -r < "${current_location}/config.production.json" '.database.connection.database')
196197

197198
echo "Exporting database from $mysql_host..."
198199

@@ -202,7 +203,8 @@ migrate_database() {
202203
exit 1
203204
fi
204205

205-
local dump_size=$(human_readable $(stat -c%s "$TEMP_SQL_FILE"))
206+
local dump_size
207+
dump_size=$(human_readable "$(stat -c%s "$TEMP_SQL_FILE")")
206208
echo "✓ Database exported successfully ($dump_size)"
207209

208210
# Start MySQL container
@@ -282,19 +284,28 @@ main() {
282284
ghost_service_name="ghost_$(jq -r < "${current_location}/.ghost-cli" '.name')"
283285

284286
# Get database configuration
285-
local mysql_host=$(jq -r < "${current_location}/config.production.json" '.database.connection.host')
286-
local mysql_database=$(jq -r < "${current_location}/config.production.json" '.database.connection.database')
287+
local mysql_host
288+
local mysql_database
289+
mysql_host=$(jq -r < "${current_location}/config.production.json" '.database.connection.host')
290+
mysql_database=$(jq -r < "${current_location}/config.production.json" '.database.connection.database')
287291

288292
# Check disk space
289293
echo ""
290294
echo "Checking disk space requirements..."
291295

292-
local content_size=$(get_size_bytes "${current_location}/content")
293-
local content_size_human=$(human_readable "$content_size")
294-
local required_space=$(echo "$content_size * $DISK_SPACE_SAFETY_FACTOR" | bc | cut -d'.' -f1)
295-
local required_space_human=$(human_readable "$required_space")
296-
local available_space=$(df -B1 "${PWD}" | tail -1 | awk '{print $4}')
297-
local available_space_human=$(human_readable "$available_space")
296+
local content_size
297+
local content_size_human
298+
local required_space
299+
local required_space_human
300+
local available_space
301+
local available_space_human
302+
303+
content_size=$(get_size_bytes "${current_location}/content")
304+
content_size_human=$(human_readable "$content_size")
305+
required_space=$(echo "$content_size * $DISK_SPACE_SAFETY_FACTOR" | bc | cut -d'.' -f1)
306+
required_space_human=$(human_readable "$required_space")
307+
available_space=$(df -B1 "${PWD}" | tail -1 | awk '{print $4}')
308+
available_space_human=$(human_readable "$available_space")
298309

299310
echo " Content size: ${content_size_human}"
300311
echo " Required space: ${required_space_human}"
@@ -398,7 +409,8 @@ main() {
398409
echo "Starting Caddy..."
399410
docker compose up caddy -d
400411

401-
local domain=$(grep 'DOMAIN' "${PWD}/.env" | cut -d '=' -f 2)
412+
local domain
413+
domain=$(grep 'DOMAIN' "${PWD}/.env" | cut -d '=' -f 2)
402414
echo ""
403415
echo "✓ Caddy is running!"
404416
echo "✓ Your site is available at: https://${domain}"

0 commit comments

Comments
 (0)