]> git.ipfire.org Git - thirdparty/squid.git/blob - errors/alias-link.sh
Bundle helpers for url_rewrite
[thirdparty/squid.git] / errors / alias-link.sh
1 #!/bin/sh
2 #
3 # Generate Symlinks for a set of aliases.
4 # Our base content is the bundled .po translation output
5 #
6 # This file creates the authoritative ISO aliases.
7 #
8
9 LN="${1}"
10 RM="${2}"
11 DIR="${3}"
12 ALIASFILE="${4}"
13
14 if ! test -f ${ALIASFILE} ; then
15 echo "FATAL: Alias file ${ALIASFILE} does not exist!"
16 exit 1
17 fi
18
19 if ! test -d ${DIR} ; then
20 echo "WARNING: Destination directory does not exist. Nothing to do."
21 exit 0
22 fi
23
24 # Parse the alias file
25 cat ${ALIASFILE} |
26 while read base aliases; do
27 # file may be commented or have empty lines
28 if test "${base}" = "#" || test "${base}" = ""; then
29 continue;
30 fi
31 # ignore destination languages that do not exist. (no dead links)
32 if ! test -x ${DIR}/${base} ; then
33 echo "WARNING: ${base} translations do not exist. Nothing to do for: ${aliases}"
34 continue;
35 fi
36
37 # split aliases based on whitespace and create a symlink for each
38 # Remove and replace any pre-existing content/link
39 for alia in ${aliases}; do
40 ${RM} -f -r ${DIR}/${alia} || exit 1
41 ${LN} -s ${base} ${DIR}/${alia} || exit 1
42 done
43 done