66 lines
1.5 KiB
Bash
66 lines
1.5 KiB
Bash
echo "### Entering abra.sh ..."
|
|
|
|
export ENTRYPOINT_CONF_VERSION=v1
|
|
export DB_PASSWORD=$(cat /run/secrets/db_password)
|
|
|
|
### Helpers
|
|
# these commands can be run via:
|
|
# abra app cmd open-inventory.example.net app $commandName
|
|
# where $commandName = {clear_cache, initial_setup, ...}
|
|
|
|
initial_setup() {
|
|
cd /app/
|
|
|
|
# clear config cache, where a previous invalid APP_KEY might still be present
|
|
clear_cache
|
|
|
|
echo "DB migrations status:"
|
|
php artisan migrate:status
|
|
echo "Starting DB migrations..."
|
|
php artisan migrate
|
|
|
|
create_first_admin_user
|
|
}
|
|
|
|
clear_cache() {
|
|
php artisan cache:clear
|
|
php artisan route:clear
|
|
php artisan config:clear
|
|
php artisan view:clear
|
|
}
|
|
|
|
create_first_admin_user() {
|
|
echo "Creating the first admin user..."
|
|
read -rp "Enter admin name: " ADMIN_NAME
|
|
read -rp "Enter admin email: " ADMIN_EMAIL
|
|
|
|
while true; do
|
|
read -rsp "Enter admin password: " ADMIN_PASSWORD
|
|
echo
|
|
read -rsp "Confirm admin password: " ADMIN_PASSWORD_CONFIRM
|
|
echo
|
|
if [ "$ADMIN_PASSWORD" = "$ADMIN_PASSWORD_CONFIRM" ]; then
|
|
break
|
|
else
|
|
echo "Passwords do not match. Please try again."
|
|
fi
|
|
done
|
|
|
|
php artisan user:first "${ADMIN_NAME}" "${ADMIN_EMAIL}" "${ADMIN_PASSWORD}"
|
|
}
|
|
|
|
export_dot_env() {
|
|
env_file_path=$1
|
|
|
|
if [ ! -f "$env_file_path" ]; then
|
|
echo "Error: .env file not found at $env_file_path"
|
|
exit 1
|
|
fi
|
|
|
|
while IFS='=' read -r env_key env_value
|
|
do
|
|
export "$env_key=$env_value"
|
|
echo "Exported: $env_key"
|
|
done < "$env_file_path"
|
|
}
|