Merge pull request #69 from investbrainapp/save-app-key-to-file
refactor: storage scaffolding and save generated app key to file
This commit is contained in:
+1
-1
@@ -100,7 +100,7 @@ return [
|
|||||||
|
|
||||||
'cipher' => 'AES-256-CBC',
|
'cipher' => 'AES-256-CBC',
|
||||||
|
|
||||||
'key' => env('APP_KEY'),
|
'key' => env('APP_KEY') ?: when(file_exists('storage/app/.key'), fn () => trim(file_get_contents('storage/app/.key'))),
|
||||||
|
|
||||||
'previous_keys' => [
|
'previous_keys' => [
|
||||||
...array_filter(
|
...array_filter(
|
||||||
|
|||||||
+14
-5
@@ -8,7 +8,11 @@ echo "CiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi
|
|||||||
echo -e "\n====================== Validating environment... ====================== "
|
echo -e "\n====================== Validating environment... ====================== "
|
||||||
|
|
||||||
# Ensure app storage directory is scaffolded
|
# 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
|
# Ensure storage directory is permissioned for www-data
|
||||||
chmod -R 775 storage
|
chmod -R 775 storage
|
||||||
@@ -16,9 +20,9 @@ chown -R www-data:www-data storage
|
|||||||
|
|
||||||
echo -e "\n > Storage directory scaffolding is OK... "
|
echo -e "\n > Storage directory scaffolding is OK... "
|
||||||
|
|
||||||
# Ensure app key is generated
|
# Ensure app key exists / generate if required
|
||||||
if [[ -z "$APP_KEY" ]]; then
|
KEY_FILE="storage/app/.key"
|
||||||
echo -e "\n > Oops! The required APP_KEY configuration is missing in your environment! "
|
if [ -z "$APP_KEY" ] && [ ! -s "$KEY_FILE" ]; then
|
||||||
|
|
||||||
draw_box() {
|
draw_box() {
|
||||||
local text="$1"
|
local text="$1"
|
||||||
@@ -30,7 +34,12 @@ if [[ -z "$APP_KEY" ]]; then
|
|||||||
echo "$border"
|
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
|
draw_box $APP_KEY
|
||||||
else
|
else
|
||||||
echo -e "\n > APP_KEY is OK... "
|
echo -e "\n > APP_KEY is OK... "
|
||||||
|
|||||||
Reference in New Issue
Block a user