Fix config directory handling in install script
- Ensure CONFIG_DIR exists during installation - Create proper symlink from INSTALL_DIR/config.json to CONFIG_DIR/config.json - Use CONFIG_DIR instead of INSTALL_DIR for configuration files - Add code to move existing config file to CONFIG_DIR if needed This fixes the issue where the config.json file was not being created in /etc/transmission-rss-manager, even though the directory was created.
This commit is contained in:
parent
1d99962024
commit
306049abdd
@ -104,6 +104,26 @@ function finalize_setup() {
|
|||||||
mkdir -p "$INSTALL_DIR/logs"
|
mkdir -p "$INSTALL_DIR/logs"
|
||||||
log "INFO" "Created logs directory: $INSTALL_DIR/logs"
|
log "INFO" "Created logs directory: $INSTALL_DIR/logs"
|
||||||
|
|
||||||
|
# Ensure CONFIG_DIR exists
|
||||||
|
if [ ! -d "$CONFIG_DIR" ]; then
|
||||||
|
mkdir -p "$CONFIG_DIR"
|
||||||
|
log "INFO" "Created configuration directory: $CONFIG_DIR"
|
||||||
|
chown -R "$USER:$USER" "$CONFIG_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the config symlink exists, create it if not
|
||||||
|
if [ ! -L "$INSTALL_DIR/config.json" ] || [ ! -e "$INSTALL_DIR/config.json" ]; then
|
||||||
|
# If there's a real file at INSTALL_DIR/config.json (not a symlink), move it to CONFIG_DIR
|
||||||
|
if [ -f "$INSTALL_DIR/config.json" ] && [ ! -L "$INSTALL_DIR/config.json" ]; then
|
||||||
|
log "INFO" "Moving existing config.json to $CONFIG_DIR"
|
||||||
|
mv "$INSTALL_DIR/config.json" "$CONFIG_DIR/config.json"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the symlink
|
||||||
|
ln -sf "$CONFIG_DIR/config.json" "$INSTALL_DIR/config.json"
|
||||||
|
log "INFO" "Created symlink from $INSTALL_DIR/config.json to $CONFIG_DIR/config.json"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set proper ownership for the installation directory
|
# Set proper ownership for the installation directory
|
||||||
chown -R $USER:$USER $INSTALL_DIR
|
chown -R $USER:$USER $INSTALL_DIR
|
||||||
|
|
||||||
@ -124,7 +144,7 @@ function finalize_setup() {
|
|||||||
cd $INSTALL_DIR && npm install
|
cd $INSTALL_DIR && npm install
|
||||||
|
|
||||||
# Handle configuration file
|
# Handle configuration file
|
||||||
if ! update_config_file "$INSTALL_DIR/config.json" "$IS_UPDATE"; then
|
if ! update_config_file "$CONFIG_DIR/config.json" "$IS_UPDATE"; then
|
||||||
log "INFO" "Creating default configuration file..."
|
log "INFO" "Creating default configuration file..."
|
||||||
|
|
||||||
# Create the users array content for JSON
|
# Create the users array content for JSON
|
||||||
@ -133,7 +153,10 @@ function finalize_setup() {
|
|||||||
USER_JSON="{ \"username\": \"${ADMIN_USERNAME}\", \"password\": \"${ADMIN_PASSWORD}\", \"role\": \"admin\" }"
|
USER_JSON="{ \"username\": \"${ADMIN_USERNAME}\", \"password\": \"${ADMIN_PASSWORD}\", \"role\": \"admin\" }"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat > $INSTALL_DIR/config.json << EOF
|
# Make sure CONFIG_DIR exists
|
||||||
|
mkdir -p "$CONFIG_DIR"
|
||||||
|
|
||||||
|
cat > $CONFIG_DIR/config.json << EOF
|
||||||
{
|
{
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"transmissionConfig": {
|
"transmissionConfig": {
|
||||||
@ -188,7 +211,12 @@ function finalize_setup() {
|
|||||||
"logLevel": "info"
|
"logLevel": "info"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
chown $USER:$USER $INSTALL_DIR/config.json
|
# Set ownership for the config file
|
||||||
|
chown $USER:$USER $CONFIG_DIR/config.json
|
||||||
|
|
||||||
|
# Ensure symlink exists from INSTALL_DIR to CONFIG_DIR
|
||||||
|
ln -sf "$CONFIG_DIR/config.json" "$INSTALL_DIR/config.json"
|
||||||
|
log "INFO" "Created symlink from $INSTALL_DIR/config.json to $CONFIG_DIR/config.json"
|
||||||
log "INFO" "Default configuration created successfully"
|
log "INFO" "Default configuration created successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user