3 # Configuration script for BPALogin
5 # Creates a new bpalogin.conf file based on the installed template, prompting
8 # Relies heavily on the formatting of the bpalogin.conf file and is sensitive
9 # to whitespace! Be careful when changing bpalogin.conf.
11 # Copyright 2003 William Rose <wdrose@sourceforge.net> and licensed under the
12 # GNU GPL, as per the rest of BPALogin.
15 CONFIG_FILE
="${1:-/etc/bpalogin.conf}"
16 TMP_DIR
="${TMPDIR:-/tmp}"
17 NEW_CONFIG
="`mktemp $TMP_DIR/bpalogin.conf-XXXXXX`"
19 if ! [ -r "$CONFIG_FILE" ]
21 echo "Usage: bpalogin.conf.sh config-file-name"
25 eval `cat "$CONFIG_FILE" | \
41 echo "$name=\"$value\""
42 echo "${name}_disabled=\"yes\""
43 disabled="$disabled $name"
48 # Empty line or specified option
54 echo "$name=\"$value\""
55 echo "${name}_disabled=\"no\""
56 variables="$variables $name"
61 echo "variables=\"${variables# }\""
62 echo "disabled=\"${disabled# }\""
66 # Prompt for new values for already configured variables.
68 if [ -n "$variables" ]
73 BPALogin Configuration
74 ----------------------
76 You will now be prompted for some basic details about your connection.
78 When prompted, the current information is displayed in square brackets.
79 Press Enter to accept the current information, or else type the new details
87 echo -n "Enter $var [`eval 'echo $'$var`]: "
88 if read && [ -n "$REPLY" ]
90 eval "$var=\"$REPLY\""
96 # Prompt for additional configuration details if disabled configuration
97 # options were detected.
101 echo -n "Would you like to configure additional options? (y/n): "
108 Additional Configuration
109 ------------------------
111 You will now be prompted for some additional details about your connection.
113 When prompted, the default information is displayed in square brackets.
114 Press Enter to use the default information in your configuration file, or
115 else type the new details. If you do not wish to have any value recorded
116 in your configuration file, type # and press Enter.
122 echo -n "Enter $var [`eval 'echo $'$var`]: "
127 if [ "$REPLY" = "#" ]
129 eval "${var}_disabled=\"yes\""
131 eval "${var}_disabled=\"no\""
132 eval "$var=\"$REPLY\""
135 eval "${var}_disabled=\"no\""
147 # Create the new bpalogin.conf file
148 cat "$CONFIG_FILE" | \
154 echo $REPLY >> "$NEW_CONFIG"
164 if eval "[ \"\$${name}_disabled\" = \"yes\" ]"
166 echo "#$name `eval 'echo $'$name`" >> "$NEW_CONFIG"
168 echo "$name `eval 'echo $'$name`" >> "$NEW_CONFIG"
171 echo $REPLY >> "$NEW_CONFIG"
180 if eval "[ \"\$${name}_disabled\" = \"yes\" ]"
182 echo "#$name `eval 'echo $'$name`" >> "$NEW_CONFIG"
184 echo "$name `eval 'echo $'$name`" >> "$NEW_CONFIG"
187 echo $REPLY >> "$NEW_CONFIG"
194 echo "New configuration successfully saved in $NEW_CONFIG"
195 echo -n "Overwrite $CONFIG_FILE with this file? (y/n) "
200 if mv "$NEW_CONFIG" "$CONFIG_FILE"
202 echo "Your BPALogin configuration file has been updated."
204 echo "Action failed. Please copy $NEW_CONFIG to $CONFIG_FILE manually."
207 if ! chmod 600 "$CONFIG_FILE"
209 echo "Unable to change permissions for your configuration file."
210 echo "Please check your configuration file is not readable by others."
214 echo "Your original BPALogin configuration file was not changed."