Avoid duplicate bashrc entries

This commit is contained in:
Bob Mottram 2017-09-23 12:24:23 +01:00
parent d7abf4dc06
commit 5293a3cdf2
1 changed files with 10 additions and 2 deletions

View File

@ -540,9 +540,17 @@ function update_default_search_engine {
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
if ! grep -q "WWW_HOME" /home/$USERNAME/.bashrc; then
if ! grep -q 'controluser' /home/$USERNAME/.bashrc; then
echo "export WWW_HOME=$DEFAULT_SEARCH" >> /home/$USERNAME/.bashrc
if ! grep -q 'export WWW_HOME=' /home/$USERNAME/.bashrc; then
echo "export WWW_HOME=$DEFAULT_SEARCH" >> /home/$USERNAME/.bashrc
else
sed -i "s|export WWW_HOME=.*|export WWW_HOME=$DEFAULT_SEARCH|g" /home/$USERNAME/.bashrc
fi
else
sed -i "/controluser/i export WWW_HOME=$DEFAULT_SEARCH" /home/$USERNAME/.bashrc
if ! grep -q 'export WWW_HOME=' /home/$USERNAME/.bashrc; then
sed -i "/controluser/i export WWW_HOME=$DEFAULT_SEARCH" /home/$USERNAME/.bashrc
else
sed -i "s|export WWW_HOME=.*|export WWW_HOME=$DEFAULT_SEARCH|g" /home/$USERNAME/.bashrc
fi
fi
fi
fi