Skip to content

Commit 3e26ad9

Browse files
authored
add goaccess browsers.list & modify list with custom user input
#Browsers List - During startup, if a `browsers.list` file already exists in the `/goaccess-config` directory, it is removed and replaced with the original goaccess `browsers.list` file. - If the file doesn't exist, it is copied from the `/goaccess/config` directory to the `/goaccess-config` directory. #Modifying the browsers list - Given the user's definition of the `CUSTOM_BROWSERS` env variable, each browser:browser category combo is appended to the `browsers.list` file (only if the browser isn't already defined in the `browsers.list`).
1 parent e7be410 commit 3e26ad9

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

resources/scripts/start.sh

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,39 @@ fi
2828
tini -s -- nginx
2929
### NGINX
3030

31+
### COPY ORIGINAL BROWSERS LIST
32+
original_browsers_list=/goaccess/config/browsers.list
33+
browsers_list="/goaccess-config/browsers.list"
34+
if [[ -f ${browsers_list} ]]; then
35+
rm ${browsers_list}
36+
cp ${original_browsers_list} ${browsers_list}
37+
else
38+
cp ${original_browsers_list} ${browsers_list}
39+
fi
40+
### END COPYING BROWSERS LIST
41+
42+
### MODIFY BROWSERS LIST WITH USER'S CUSTOM BROWSERS
43+
if [ ! -z "${CUSTOM_BROWSERS}" ]; then
44+
IFS=','
45+
read -ra BROWSER_CATEGORY <<< "$CUSTOM_BROWSERS"
46+
unset IFS
47+
for b_c in "${BROWSER_CATEGORY[@]}"; do
48+
IFS=':'
49+
read -ra BROWSER <<< "$b_c"
50+
if grep -Fwq "${BROWSER[0]}" ${browsers_list}
51+
then
52+
echo -e "\n\t${BROWSER[0]} ALREADY IN BROWSERS LIST"
53+
else
54+
echo -e "${BROWSER[0]}\t${BROWSER[1]}" >> ${browsers_list}
55+
echo -e "\n\t${BROWSER[0]} ADDED TO BROWSERS LIST"
56+
fi
57+
done
58+
unset IFS
59+
else
60+
echo -e "\n\tCUSTOM_BROWSERS VARIABLE IS EMPTY"
61+
fi
62+
### END MODIFYING BROWSERS LIST
63+
3164
# BEGIN PROXY LOGS
3265
if [[ -z "${LOG_TYPE}" || "${LOG_TYPE}" == "NPM" || "${LOG_TYPE}" == "NPM+R" || "${LOG_TYPE}" == "NPM+ALL" ]]; then
3366
echo -e "\n\nNPM INSTANCE SETTING UP..."
@@ -51,4 +84,4 @@ fi
5184
# END PROXY LOGS
5285

5386
#Leave container running
54-
wait -n
87+
wait -n

0 commit comments

Comments
 (0)