From 5293a3cdf21aefbb48de5381ae8d608c719160a4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 23 Sep 2017 12:24:23 +0100 Subject: [PATCH] Avoid duplicate bashrc entries --- src/freedombone-utils-web | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/freedombone-utils-web b/src/freedombone-utils-web index 98ce2055..a63dda38 100755 --- a/src/freedombone-utils-web +++ b/src/freedombone-utils-web @@ -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