Collect Transmission remote details in install-script.sh
- Move Transmission remote details collection to install-script.sh - Pass all remote details to main-installer.sh via environment file - Avoid duplicate prompting for remote details - Improve non-interactive mode with proper default values - Add check in main-installer.sh to use provided remote details This solves the problem where remote Transmission details were collected in install-script.sh but not properly used in the main installer when updating an existing installation.
This commit is contained in:
parent
a3924912f1
commit
588ba1ea01
@ -1190,8 +1190,69 @@ else
|
|||||||
echo -e "${GREEN}Local Transmission selected.${NC}"
|
echo -e "${GREEN}Local Transmission selected.${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a direct environment file for the main installer
|
# If remote mode is selected, collect remote details here and pass to main installer
|
||||||
echo "export TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE" > "${SCRIPT_DIR}/.env.install"
|
if [ "$TRANSMISSION_REMOTE" = "true" ]; then
|
||||||
|
# Get remote transmission details
|
||||||
|
if [ ! -t 0 ]; then
|
||||||
|
# Non-interactive mode - try to read from stdin with defaults
|
||||||
|
TRANSMISSION_HOST=$(head -n 1 || echo "localhost")
|
||||||
|
TRANSMISSION_PORT=$(head -n 1 || echo "9091")
|
||||||
|
TRANSMISSION_USER=$(head -n 1 || echo "")
|
||||||
|
TRANSMISSION_PASS=$(head -n 1 || echo "")
|
||||||
|
TRANSMISSION_RPC_PATH=$(head -n 1 || echo "/transmission/rpc")
|
||||||
|
REMOTE_DOWNLOAD_DIR=$(head -n 1 || echo "/var/lib/transmission-daemon/downloads")
|
||||||
|
LOCAL_DOWNLOAD_DIR=$(head -n 1 || echo "/mnt/transmission-downloads")
|
||||||
|
echo "DEBUG: Non-interactive mode with remote details:"
|
||||||
|
echo "DEBUG: Host: $TRANSMISSION_HOST, Port: $TRANSMISSION_PORT"
|
||||||
|
echo "DEBUG: Remote dir: $REMOTE_DOWNLOAD_DIR, Local dir: $LOCAL_DOWNLOAD_DIR"
|
||||||
|
else
|
||||||
|
# Interactive mode - ask for details
|
||||||
|
read -p "Remote Transmission host [localhost]: " TRANSMISSION_HOST
|
||||||
|
TRANSMISSION_HOST=${TRANSMISSION_HOST:-"localhost"}
|
||||||
|
|
||||||
|
read -p "Remote Transmission port [9091]: " TRANSMISSION_PORT
|
||||||
|
TRANSMISSION_PORT=${TRANSMISSION_PORT:-"9091"}
|
||||||
|
|
||||||
|
read -p "Remote Transmission username []: " TRANSMISSION_USER
|
||||||
|
TRANSMISSION_USER=${TRANSMISSION_USER:-""}
|
||||||
|
|
||||||
|
read -s -p "Remote Transmission password []: " TRANSMISSION_PASS
|
||||||
|
echo # Add a newline after password input
|
||||||
|
TRANSMISSION_PASS=${TRANSMISSION_PASS:-""}
|
||||||
|
|
||||||
|
read -p "Remote Transmission RPC path [/transmission/rpc]: " TRANSMISSION_RPC_PATH
|
||||||
|
TRANSMISSION_RPC_PATH=${TRANSMISSION_RPC_PATH:-"/transmission/rpc"}
|
||||||
|
|
||||||
|
# Configure directory mapping for remote setup
|
||||||
|
echo
|
||||||
|
echo -e "${YELLOW}Directory Mapping Configuration${NC}"
|
||||||
|
echo -e "When using a remote Transmission server, you need to map paths between servers."
|
||||||
|
echo -e "For each directory on the remote server, specify the corresponding local directory."
|
||||||
|
echo
|
||||||
|
|
||||||
|
read -p "Remote Transmission download directory [/var/lib/transmission-daemon/downloads]: " REMOTE_DOWNLOAD_DIR
|
||||||
|
REMOTE_DOWNLOAD_DIR=${REMOTE_DOWNLOAD_DIR:-"/var/lib/transmission-daemon/downloads"}
|
||||||
|
|
||||||
|
read -p "Local directory that corresponds to the remote download directory [/mnt/transmission-downloads]: " LOCAL_DOWNLOAD_DIR
|
||||||
|
LOCAL_DOWNLOAD_DIR=${LOCAL_DOWNLOAD_DIR:-"/mnt/transmission-downloads"}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the environment file with all remote details
|
||||||
|
cat > "${SCRIPT_DIR}/.env.install" << EOF
|
||||||
|
export TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE
|
||||||
|
export TRANSMISSION_HOST="$TRANSMISSION_HOST"
|
||||||
|
export TRANSMISSION_PORT="$TRANSMISSION_PORT"
|
||||||
|
export TRANSMISSION_USER="$TRANSMISSION_USER"
|
||||||
|
export TRANSMISSION_PASS="$TRANSMISSION_PASS"
|
||||||
|
export TRANSMISSION_RPC_PATH="$TRANSMISSION_RPC_PATH"
|
||||||
|
export REMOTE_DOWNLOAD_DIR="$REMOTE_DOWNLOAD_DIR"
|
||||||
|
export LOCAL_DOWNLOAD_DIR="$LOCAL_DOWNLOAD_DIR"
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
# Local mode - simpler environment file
|
||||||
|
echo "export TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE" > "${SCRIPT_DIR}/.env.install"
|
||||||
|
fi
|
||||||
|
|
||||||
chmod +x "${SCRIPT_DIR}/.env.install"
|
chmod +x "${SCRIPT_DIR}/.env.install"
|
||||||
|
|
||||||
# Ensure the environment file is world-readable to avoid permission issues
|
# Ensure the environment file is world-readable to avoid permission issues
|
||||||
|
@ -143,6 +143,12 @@ if [ "$IS_UPDATE" = true ]; then
|
|||||||
# Update the config file directly to set remote mode
|
# Update the config file directly to set remote mode
|
||||||
if [ -f "$CONFIG_DIR/config.json" ]; then
|
if [ -f "$CONFIG_DIR/config.json" ]; then
|
||||||
log "INFO" "Updating configuration file for remote Transmission..."
|
log "INFO" "Updating configuration file for remote Transmission..."
|
||||||
|
|
||||||
|
# Check if we already have the remote configuration details from the environment
|
||||||
|
if [ -n "$TRANSMISSION_HOST" ] && [ -n "$TRANSMISSION_PORT" ] && [ -n "$REMOTE_DOWNLOAD_DIR" ] && [ -n "$LOCAL_DOWNLOAD_DIR" ]; then
|
||||||
|
log "INFO" "Using remote Transmission configuration from environment"
|
||||||
|
# Values are already set from the environment, no need to ask again
|
||||||
|
else
|
||||||
# Get and validate hostname
|
# Get and validate hostname
|
||||||
read -p "Remote Transmission host [localhost]: " input_trans_host
|
read -p "Remote Transmission host [localhost]: " input_trans_host
|
||||||
TRANSMISSION_HOST=${input_trans_host:-"localhost"}
|
TRANSMISSION_HOST=${input_trans_host:-"localhost"}
|
||||||
@ -177,6 +183,7 @@ if [ "$IS_UPDATE" = true ]; then
|
|||||||
# Get local directory that corresponds to remote download directory
|
# Get local directory that corresponds to remote download directory
|
||||||
read -p "Local directory that corresponds to the remote download directory [/mnt/transmission-downloads]: " LOCAL_DOWNLOAD_DIR
|
read -p "Local directory that corresponds to the remote download directory [/mnt/transmission-downloads]: " LOCAL_DOWNLOAD_DIR
|
||||||
LOCAL_DOWNLOAD_DIR=${LOCAL_DOWNLOAD_DIR:-"/mnt/transmission-downloads"}
|
LOCAL_DOWNLOAD_DIR=${LOCAL_DOWNLOAD_DIR:-"/mnt/transmission-downloads"}
|
||||||
|
fi
|
||||||
|
|
||||||
# Create mapping JSON
|
# Create mapping JSON
|
||||||
TRANSMISSION_DIR_MAPPING=$(cat <<EOF
|
TRANSMISSION_DIR_MAPPING=$(cat <<EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user