Skip to content

Commit 2dec0c5

Browse files
committed
safe replacement for ubuntu 14.0.4
1 parent 133a245 commit 2dec0c5

File tree

2 files changed

+35
-53
lines changed

2 files changed

+35
-53
lines changed

func/domain.sh

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -224,31 +224,31 @@ sort_dns_records() {
224224
# Add web config
225225
add_web_config() {
226226
cat $tpl_file | \
227-
sed -e "s/%ip%/$ip/g" \
228-
-e "s/%web_system%/$WEB_SYSTEM/g" \
229-
-e "s/%web_port%/$WEB_PORT/g" \
230-
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
231-
-e "s/%rgroups%/$WEB_RGROUPS/g" \
232-
-e "s/%proxy_system%/$PROXY_SYSTEM/g" \
233-
-e "s/%proxy_port%/$PROXY_PORT/g" \
234-
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
227+
sed -e "s|%ip%|$ip|g" \
228+
-e "s|%web_system%|$WEB_SYSTEM|g" \
229+
-e "s|%web_port%|$WEB_PORT|g" \
230+
-e "s|%web_ssl_port%|$WEB_SSL_PORT|g" \
231+
-e "s|%rgroups%|$WEB_RGROUPS|g" \
232+
-e "s|%proxy_system%|$PROXY_SYSTEM|g" \
233+
-e "s|%proxy_port%|$PROXY_PORT|g" \
234+
-e "s|%proxy_ssl_port%|$PROXY_SSL_PORT|g" \
235235
-e "s/%proxy_extentions%/${PROXY_EXT//,/|}/g" \
236-
-e "s/%domain_idn%/$domain_idn/g" \
237-
-e "s/%domain%/$domain/g" \
238-
-e "s/%user%/$user/g" \
239-
-e "s/%group%/$group/g" \
240-
-e "s/%home%/${HOMEDIR////\/}/g" \
241-
-e "s/%docroot%/${docroot////\/}/g" \
242-
-e "s/%sdocroot%/${sdocroot////\/}/g" \
243-
-e "s/%email%/$email/g" \
244-
-e "s/%alias_string%/$alias_string/g" \
245-
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
246-
-e "s/%alias%/${aliases//,/ }/g" \
247-
-e "s/%ssl_crt%/${ssl_crt////\/}/g" \
248-
-e "s/%ssl_key%/${ssl_key////\/}/g" \
249-
-e "s/%ssl_pem%/${ssl_pem////\/}/g" \
250-
-e "s/%ssl_ca_str%/${ssl_ca_str////\/}/g" \
251-
-e "s/%ssl_ca%/${ssl_ca////\/}/g" \
236+
-e "s|%domain_idn%|$domain_idn|g" \
237+
-e "s|%domain%|$domain|g" \
238+
-e "s|%user%|$user|g" \
239+
-e "s|%group%|$group|g" \
240+
-e "s|%home%|$HOMEDIR|g" \
241+
-e "s|%docroot%|$docroot|g" \
242+
-e "s|%sdocroot%|$sdocroot|g" \
243+
-e "s|%email%|$email|g" \
244+
-e "s|%alias_string%|$alias_string|g" \
245+
-e "s|%alias_idn%|${aliases_idn//,/ }|g" \
246+
-e "s|%alias%|${aliases//,/ }|g" \
247+
-e "s|%ssl_crt%|$ssl_crt|g" \
248+
-e "s|%ssl_key%|$ssl_key|g" \
249+
-e "s|%ssl_pem%|$ssl_pem|g" \
250+
-e "s|%ssl_ca_str%|$ssl_ca_str|g" \
251+
-e "s|%ssl_ca%|$ssl_ca|g" \
252252
>> $conf
253253
}
254254

@@ -275,24 +275,6 @@ get_web_config_brds() {
275275

276276
}
277277

278-
# Change web config
279-
change_web_config() {
280-
get_web_config_brds || exit $?
281-
vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf)
282-
str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
283-
str_numb=$(echo "$str" | sed "s/-/=/" | cut -f 1 -d '=')
284-
str_cont=$(echo "$str" | sed "s/-/=/" | cut -f 2 -d '=')
285-
286-
str_repl=$(echo "$str_repl" | sed \
287-
-e 's/\\/\\\\/g' \
288-
-e 's/&/\\&/g' \
289-
-e 's/\//\\\//g')
290-
291-
if [ ! -z "$str" ]; then
292-
sed -i "$str_numb s/.*/$str_repl/" $conf
293-
fi
294-
}
295-
296278
# Replace web config
297279
replace_web_config() {
298280
get_web_config_brds || exit $?

func/rebuild.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,17 @@ rebuild_web_domain_conf() {
216216
# Checking stats
217217
if [ ! -z "$STATS" ]; then
218218
cat $WEBTPL/$STATS/$STATS.tpl |\
219-
sed -e "s/%ip%/$ip/g" \
220-
-e "s/%web_port%/$WEB_PORT/g" \
221-
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
222-
-e "s/%proxy_port%/$PROXY_PORT/g" \
223-
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
224-
-e "s/%domain_idn%/$domain_idn/g" \
225-
-e "s/%domain%/$domain/g" \
226-
-e "s/%user%/$user/g" \
227-
-e "s/%home%/${HOMEDIR////\/}/g" \
228-
-e "s/%alias%/${aliases//,/ }/g" \
229-
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
219+
sed -e "s|%ip%|$ip|g" \
220+
-e "s|%web_port%|$WEB_PORT|g" \
221+
-e "s|%web_ssl_port%|$WEB_SSL_PORT|g" \
222+
-e "s|%proxy_port%|$PROXY_PORT|g" \
223+
-e "s|%proxy_ssl_port%|$PROXY_SSL_PORT|g" \
224+
-e "s|%domain_idn%|$domain_idn|g" \
225+
-e "s|%domain%|$domain|g" \
226+
-e "s|%user%|$user|g" \
227+
-e "s|%home%|$HOMEDIR|g" \
228+
-e "s|%alias%|${aliases//,/ }|g" \
229+
-e "s|%alias_idn%|${aliases_idn//,/ }|g" \
230230
> $HOMEDIR/$user/conf/web/$STATS.$domain.conf
231231

232232
if [ "$STATS" == 'awstats' ]; then

0 commit comments

Comments
 (0)