refactor: storage directory scaffoling and save generated app key to file

This commit is contained in:
hackerESQ
2025-03-06 16:55:54 -06:00
parent 6dea75651b
commit 732cf02317
2 changed files with 15 additions and 6 deletions
+14 -5
View File
@@ -8,7 +8,11 @@ echo "CiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi
echo -e "\n====================== Validating environment... ====================== "
# Ensure app storage directory is scaffolded
mkdir -p storage/{{framework/cache,framework/sessions,framework/views},app,logs}
mkdir -p storage/framework/cache \
storage/framework/sessions \
storage/framework/views \
storage/app \
storage/logs
# Ensure storage directory is permissioned for www-data
chmod -R 775 storage
@@ -16,9 +20,9 @@ chown -R www-data:www-data storage
echo -e "\n > Storage directory scaffolding is OK... "
# Ensure app key is generated
if [[ -z "$APP_KEY" ]]; then
echo -e "\n > Oops! The required APP_KEY configuration is missing in your environment! "
# Ensure app key exists / generate if required
KEY_FILE="storage/app/.key"
if [ -z "$APP_KEY" ] && [ ! -s "$KEY_FILE" ]; then
draw_box() {
local text="$1"
@@ -30,7 +34,12 @@ if [[ -z "$APP_KEY" ]]; then
echo "$border"
}
export APP_KEY=$(php artisan key:generate --show)
export APP_KEY="$(php artisan key:generate --show)"
echo -e "\n > Oops! The required APP_KEY configuration is missing! Generated app key and saved in $KEY_FILE ."
echo "$APP_KEY" > "$KEY_FILE"
draw_box $APP_KEY
else
echo -e "\n > APP_KEY is OK... "