#!/bin/sh

set -e

sed -e 's|/\* *#define EXEC_LINKS *\*/|#define EXEC_LINKS|' \
    -e 's|/\* #define EXEC_SCRIPTS *\*/|#define EXEC_SCRIPTS|' \
    -e 's|/\* #define LYNXCGI_LINKS *\*/|#define LYNXCGI_LINKS|' \
    -e 's|/\* #define GLOBAL_EXTENSION_MAP "/usr/local/lib/mosaic/mime.types|#define GLOBAL_EXTENSION_MAP "/etc/mime.types"' \
    -e 's|/\* #define GLOBAL_MAILCAP "/usr/local/lib/mosaic/mailcap"|#define GLOBAL_MAILCAP "/etc/mailcap"|' \
    userdefs.h >userdefs.h.new && mv userdefs.h.new userdefs.h

sed -e 's|STARTFILE:http://lynx.browser.org/|STARTFILE:Not-Configured-Yet|' \
    -e 's|^HELPFILE:http|#HELPFILE:http|' \
    -e 's|#HELPFILE:file://localhost/PATH_TO/lynx_help/lynx_help_main.html|HELPFILE:file://localhost/usr/doc/lynx/lynx_help/lynx_help_main.html|' \
    -e 's|#NO_DOT_FILES:TRUE|NO_DOT_FILES:FALSE|' \
    -e 's|#GLOBAL_EXTENSION_MAP:/usr/local/lib/mosaic/mime.types|GLOBAL_EXTENSION_MAP:/etc/mime.types|' \
    -e 's|#PERSONAL_EXTENSION_MAP:.mime.types|PERSONAL_EXTENSION_MAP:.mime.types|' \
    -e 's|#GLOBAL_MAILCAP:/usr/local/lib/mosaic/mailcap|GLOBAL_MAILCAP:/etc/mailcap|' \
    -e 's|#PERSONAL_MAILCAP:.mailcap|PERSONAL_MAILCAP:.mailcap|' \
    -e 's|#XLOADIMAGE_COMMAND:xli %s &|XLOADIMAGE_COMMAND:|' \
    -e 's|#COLOR:0:black:white|COLOR:0:lightgray:black|' \
    -e 's|#COLOR:1:blue:white|COLOR:1:blue:black|' \
    -e 's|#COLOR:2:yellow:blue|COLOR:2:yellow:blue|' \
    -e 's|#COLOR:3:green:white|COLOR:3:green:black|' \
    -e 's|#COLOR:4:magenta:white|COLOR:4:magenta:black|' \
    -e 's|#COLOR:5:blue:white|COLOR:5:blue:black|' \
    -e 's|#COLOR:6:red:white|COLOR:6:red:black|' \
    -e 's|#COLOR:7:magenta:cyan|COLOR:7:magenta:cyan|' \
    -e 's|#LOCAL_EXECUTION_LINKS_ALWAYS_ON:FALSE|LOCAL_EXECUTION_LINKS_ALWAYS_ON:FALSE|' \
    -e 's|#LOCAL_EXECUTION_LINKS_ON_BUT_NOT_REMOTE:FALSE|LOCAL_EXECUTION_LINKS_ON_BUT_NOT_REMOTE:FALSE|' \
    -e 's|#TRUSTED_EXEC:none|TRUSTED_EXEC:none|' \
    -e 's|#ALWAYS_TRUSTED_EXEC:none|ALWAYS_TRUSTED_EXEC:none|' \
    -e 's|#TRUSTED_LYNXCGI:none|TRUSTED_LYNXCGI:none|' \
    lynx.cfg >lynx.cfg.new && mv lynx.cfg.new lynx.cfg
    
