fix: store Authelia credentials in persistent location
- setup-homelab.sh: Store temp files in /opt/stacks/.setup-temp instead of /tmp - deploy-homelab.sh: Read credentials from new persistent location - reset-test-environment.sh: Clean up new temp directory This fixes the issue where credentials were inaccessible when deploy script runs via 'su -' (login shell) from setup script, as /tmp files created by root are not accessible across the su boundary.
This commit is contained in:
@@ -179,9 +179,9 @@ log_info "Configuring Authelia for domain: $DOMAIN..."
|
||||
sed -i "s/your-domain.duckdns.org/${DOMAIN}/g" /opt/stacks/core/authelia/configuration.yml
|
||||
|
||||
# Configure Authelia admin user from setup script
|
||||
if [ -f /tmp/authelia_admin_credentials.tmp ] && [ -f /tmp/authelia_password_hash.tmp ]; then
|
||||
if [ -f /opt/stacks/.setup-temp/authelia_admin_credentials.tmp ] && [ -f /opt/stacks/.setup-temp/authelia_password_hash.tmp ]; then
|
||||
log_info "Loading Authelia admin credentials from setup script..."
|
||||
source /tmp/authelia_admin_credentials.tmp
|
||||
source /opt/stacks/.setup-temp/authelia_admin_credentials.tmp
|
||||
|
||||
if [ -n "$ADMIN_USER" ] && [ -n "$ADMIN_EMAIL" ]; then
|
||||
log_success "Using credentials: $ADMIN_USER ($ADMIN_EMAIL)"
|
||||
@@ -209,7 +209,7 @@ EOF
|
||||
export ADMIN_EMAIL
|
||||
python3 << 'PYTHON_EOF'
|
||||
# Read password hash from file to completely avoid bash variable expansion
|
||||
with open('/tmp/authelia_password_hash.tmp', 'r') as f:
|
||||
with open('/opt/stacks/.setup-temp/authelia_password_hash.tmp', 'r') as f:
|
||||
password_hash = f.read().strip()
|
||||
|
||||
import os
|
||||
@@ -252,8 +252,11 @@ PYTHON_EOF
|
||||
log_info "Password also saved to: /opt/stacks/core/authelia/ADMIN_PASSWORD.txt"
|
||||
echo ""
|
||||
|
||||
# Clean up credentials file
|
||||
rm -f /tmp/authelia_admin_credentials.tmp
|
||||
# Clean up credentials files from setup script
|
||||
rm -f /opt/stacks/.setup-temp/authelia_admin_credentials.tmp
|
||||
rm -f /opt/stacks/.setup-temp/authelia_password_hash.tmp
|
||||
rmdir /opt/stacks/.setup-temp 2>/dev/null || true
|
||||
log_info "Cleaned up temporary setup files"
|
||||
else
|
||||
log_warning "Incomplete credentials from setup script"
|
||||
log_info "Using template users_database.yml - please configure manually"
|
||||
|
||||
@@ -122,6 +122,8 @@ echo ""
|
||||
log_info "Step 4/6: Cleaning temporary files..."
|
||||
|
||||
rm -f /tmp/authelia_admin_credentials.tmp
|
||||
rm -f /tmp/authelia_password_hash.tmp
|
||||
rm -rf /opt/stacks/.setup-temp
|
||||
rm -f /tmp/nvidia*.log
|
||||
log_success "Temporary files cleaned"
|
||||
echo ""
|
||||
|
||||
@@ -351,12 +351,18 @@ log_success "Password hash generated and will be applied during deployment"
|
||||
# Store the admin credentials for the deployment script
|
||||
# Password hash is already in /tmp/authelia_password_hash.tmp (written directly from Docker)
|
||||
# This avoids bash variable expansion issues with $ characters in argon2 hashes
|
||||
# Store in /opt/stacks/ which is accessible across user contexts
|
||||
mkdir -p /opt/stacks/.setup-temp
|
||||
{
|
||||
echo "ADMIN_USER=$ADMIN_USER"
|
||||
echo "ADMIN_EMAIL=$ADMIN_EMAIL"
|
||||
echo "ADMIN_PASSWORD=$ADMIN_PASSWORD"
|
||||
} > /tmp/authelia_admin_credentials.tmp
|
||||
chmod 600 /tmp/authelia_admin_credentials.tmp
|
||||
} > /opt/stacks/.setup-temp/authelia_admin_credentials.tmp
|
||||
chmod 600 /opt/stacks/.setup-temp/authelia_admin_credentials.tmp
|
||||
|
||||
# Copy password hash to persistent location
|
||||
cp /tmp/authelia_password_hash.tmp /opt/stacks/.setup-temp/authelia_password_hash.tmp
|
||||
chmod 600 /opt/stacks/.setup-temp/authelia_password_hash.tmp
|
||||
|
||||
log_info "Credentials saved for deployment script"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user