Add robust environment sharing for install script
- Create .env.install file to store configuration choices - Modify main-installer.sh to load environment variables - Use direct sourcing to ensure environment variables are properly passed - Add explicit logging of environment variable values - Implement safer method of handling environment across script execution 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a1773d0bae
commit
aa3978903b
@ -1182,5 +1182,20 @@ else
|
||||
echo -e "${GREEN}Local Transmission selected.${NC}"
|
||||
fi
|
||||
|
||||
# Make sure the variable is available to the main installer
|
||||
env TRANSMISSION_REMOTE="$TRANSMISSION_REMOTE" "${SCRIPT_DIR}/main-installer.sh"
|
||||
# Create a direct environment file for the main installer
|
||||
echo "export TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE" > "${SCRIPT_DIR}/.env.install"
|
||||
chmod +x "${SCRIPT_DIR}/.env.install"
|
||||
|
||||
# Force inclusion in the main installer - modify the main installer temporarily if needed
|
||||
if ! grep -q "source.*\.env\.install" "${SCRIPT_DIR}/main-installer.sh"; then
|
||||
# Backup the main installer
|
||||
cp "${SCRIPT_DIR}/main-installer.sh" "${SCRIPT_DIR}/main-installer.sh.bak"
|
||||
|
||||
# Insert the source command after the shebang line
|
||||
awk 'NR==1{print; print "# Load installation environment variables"; print "if [ -f \"$(dirname \"$0\")/.env.install\" ]; then"; print " source \"$(dirname \"$0\")/.env.install\""; print " echo \"Loaded TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE from environment file\""; print "fi"} NR!=1{print}' "${SCRIPT_DIR}/main-installer.sh.bak" > "${SCRIPT_DIR}/main-installer.sh"
|
||||
chmod +x "${SCRIPT_DIR}/main-installer.sh"
|
||||
fi
|
||||
|
||||
# Now execute the main installer with the environment variables set
|
||||
echo "Running main installer with TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE"
|
||||
bash -c "source ${SCRIPT_DIR}/.env.install && ${SCRIPT_DIR}/main-installer.sh"
|
Loading…
x
Reference in New Issue
Block a user