From 9b721b30cb9de2b0e23d91628552db2415491846 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Fri, 26 Jan 2024 18:38:16 +0000 Subject: [PATCH 1/7] Use CreateProfile instead of timed exec --- .gitpod/installation.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitpod/installation.sh b/.gitpod/installation.sh index dbcf43c..be2411d 100755 --- a/.gitpod/installation.sh +++ b/.gitpod/installation.sh @@ -24,10 +24,10 @@ sudo tar -xjf /opt/firefox-developer.tar.bz2 -C /opt sudo mv /opt/firefox /opt/firefox-developer sudo ln -sf /opt/firefox-developer/firefox /usr/local/bin/firefox-developer -timeout 5 firefox -timeout 5 firefox-esr -timeout 5 firefox-nightly -timeout 5 firefox-developer +firefox -CreateProfile default-release +firefox-esr -CreateProfile default-esr +firefox-nightly -CreateProfile default-nightly +firefox-developer -CreateProfile dev-edition-default MM_FFDIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name '*.default-release')" MM_FFNDIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name '*.default-nightly')" From 69e022bea97f5735861ebf4a524ef6e51d5867f9 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Fri, 26 Jan 2024 20:59:30 +0000 Subject: [PATCH 2/7] Looped gitpod install --- .gitpod/firefox-aurora.desktop | 12 ----- .gitpod/firefox-nightly.desktop | 12 ----- .gitpod/installation.sh | 89 ++++++++++++++++++--------------- 3 files changed, 50 insertions(+), 63 deletions(-) delete mode 100644 .gitpod/firefox-aurora.desktop delete mode 100644 .gitpod/firefox-nightly.desktop diff --git a/.gitpod/firefox-aurora.desktop b/.gitpod/firefox-aurora.desktop deleted file mode 100644 index b84c69b..0000000 --- a/.gitpod/firefox-aurora.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Version=1.0 -Name=Firefox Developer -GenericName=Web Browser -Exec=/usr/local/bin/firefox-developer %u -Icon=/opt/firefox-developer/browser/chrome/icons/default/default128.png -Terminal=false -Type=Application -MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https; -StartupNotify=true -Categories=Network;WebBrowser; -Keywords=web;browser;internet; diff --git a/.gitpod/firefox-nightly.desktop b/.gitpod/firefox-nightly.desktop deleted file mode 100644 index 2851fb0..0000000 --- a/.gitpod/firefox-nightly.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Version=1.0 -Name=Firefox Nightly -GenericName=Web Browser -Exec=/usr/local/bin/firefox-nightly %u -Icon=/opt/firefox-nightly/browser/chrome/icons/default/default128.png -Terminal=false -Type=Application -MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https; -StartupNotify=true -Categories=Network;WebBrowser; -Keywords=web;browser;internet; diff --git a/.gitpod/installation.sh b/.gitpod/installation.sh index be2411d..a8f65a9 100755 --- a/.gitpod/installation.sh +++ b/.gitpod/installation.sh @@ -1,44 +1,55 @@ #! /bin/bash -sudo apt-get remove firefox - -# Prioritise Deb Firefox over Snap. -echo ' -Package: * -Pin: release o=LP-PPA-mozillateam -Pin-Priority: 1001 -' | sudo tee /etc/apt/preferences.d/mozilla-firefox - -sudo add-apt-repository ppa:mozillateam/ppa -y -sudo apt-get update -sudo apt-get install -y firefox firefox-esr -sudo sed -i 's/Name=Firefox Web Browser/Name=Firefox Web Browser (ESR)/' /usr/share/applications/firefox-esr.desktop - -sudo wget -O /opt/firefox-nightly.tar.bz2 "https://download.mozilla.org/?product=firefox-nightly-latest&os=linux64&lang=en-US" -sudo tar -xjf /opt/firefox-nightly.tar.bz2 -C /opt -sudo mv /opt/firefox /opt/firefox-nightly -sudo ln -sf /opt/firefox-nightly/firefox /usr/local/bin/firefox-nightly - -sudo wget -O /opt/firefox-developer.tar.bz2 "https://download.mozilla.org/?product=firefox-devedition-latest&os=linux64&lang=en-US" -sudo tar -xjf /opt/firefox-developer.tar.bz2 -C /opt -sudo mv /opt/firefox /opt/firefox-developer -sudo ln -sf /opt/firefox-developer/firefox /usr/local/bin/firefox-developer - -firefox -CreateProfile default-release -firefox-esr -CreateProfile default-esr -firefox-nightly -CreateProfile default-nightly -firefox-developer -CreateProfile dev-edition-default - -MM_FFDIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name '*.default-release')" -MM_FFNDIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name '*.default-nightly')" -MM_FFADIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name '*.dev-edition-default')" -MM_FFEDIR="$(find ~/.mozilla/firefox-esr -maxdepth 1 -type d -name '*.default-esr*')" - -for DIR in "${MM_FFDIR}" "${MM_FFNDIR}" "${MM_FFADIR}" "${MM_FFEDIR}"; do +sudo apt-get remove -y firefox + +declare -A firefox_versions=( + ["firefox-regular"]="firefox-latest" + ["firefox-esr"]="firefox-esr-latest" + ["firefox-nightly"]="firefox-nightly-latest" + ["firefox-developer"]="firefox-devedition-latest" +) + +for version in "${!firefox_versions[@]}"; do + product=${firefox_versions[$version]} + + echo "> wget -q -O \"/opt/${version}.tar.bz2\" \"https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US\"" + sudo wget -q -O "/opt/${version}.tar.bz2" "https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US" + + echo "> sudo tar -xjf \"/opt/${version}.tar.bz2\" -C /opt" + sudo tar -xjf "/opt/${version}.tar.bz2" -C /opt + + echo "> sudo mv /opt/firefox \"/opt/${version}\"" + sudo mv /opt/firefox "/opt/${version}" + + echo "> ln -sf \"/opt/${version}/firefox\" \"/usr/local/bin/${version}\"" + sudo ln -sf "/opt/${version}/firefox" "/usr/local/bin/${version}" + + + echo "> /opt/${version}/firefox -CreateProfile $version" + /opt/${version}/firefox -CreateProfile $version + + DIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")" + + echo "> cp .gitpod/user.js \"${DIR}\"" cp .gitpod/user.js "${DIR}" + + echo "> ln -sf \"${GITPOD_REPO_ROOTS}/IE6/chrome\" \"${DIR}/chrome\"" ln -sf "${GITPOD_REPO_ROOTS}/IE6/chrome" "${DIR}/chrome" -done -mkdir -p ~/.local/share/applications -cp .gitpod/firefox-nightly.desktop ~/.local/share/applications/firefox-nightly.desktop -cp .gitpod/firefox-aurora.desktop ~/.local/share/applications/firefox-aurora.desktop + cat << EOF > ~/Desktop/${version}.desktop +[Desktop Entry] +Version=1.0 +Name=${version} +GenericName=Web Browser +Exec=/opt/${version}/firefox -P ${version} %u +Icon=/opt/${version}/browser/chrome/icons/default/default128.png +Terminal=false +Type=Application +MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https; +StartupNotify=true +Categories=Network;WebBrowser; +Keywords=web;browser;internet; +EOF + + cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop +done From 001d2a0dd79caab55e2c6317c7191a6fcdfb46e2 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Fri, 26 Jan 2024 21:08:21 +0000 Subject: [PATCH 3/7] Make appdir --- .gitpod/installation.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitpod/installation.sh b/.gitpod/installation.sh index a8f65a9..5200524 100755 --- a/.gitpod/installation.sh +++ b/.gitpod/installation.sh @@ -2,6 +2,8 @@ sudo apt-get remove -y firefox +mkdir -p ~/.local/share/applications + declare -A firefox_versions=( ["firefox-regular"]="firefox-latest" ["firefox-esr"]="firefox-esr-latest" @@ -12,6 +14,10 @@ declare -A firefox_versions=( for version in "${!firefox_versions[@]}"; do product=${firefox_versions[$version]} + echo "" + echo "Installing: ${version}" + echo "---------------------------------------" + echo "> wget -q -O \"/opt/${version}.tar.bz2\" \"https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US\"" sudo wget -q -O "/opt/${version}.tar.bz2" "https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US" From 7a5025eb8002d5adc3b1aca8720f1ba5001bd51b Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Fri, 26 Jan 2024 21:16:38 +0000 Subject: [PATCH 4/7] Detect if the profile installed succeeded. --- .gitpod/installation.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitpod/installation.sh b/.gitpod/installation.sh index 5200524..7bdd19c 100755 --- a/.gitpod/installation.sh +++ b/.gitpod/installation.sh @@ -33,16 +33,18 @@ for version in "${!firefox_versions[@]}"; do echo "> /opt/${version}/firefox -CreateProfile $version" /opt/${version}/firefox -CreateProfile $version + exit_status=$? - DIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")" + if [ $exit_status -eq 0 ]; then + DIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")" - echo "> cp .gitpod/user.js \"${DIR}\"" - cp .gitpod/user.js "${DIR}" + echo "> cp .gitpod/user.js \"${DIR}\"" + cp .gitpod/user.js "${DIR}" - echo "> ln -sf \"${GITPOD_REPO_ROOTS}/IE6/chrome\" \"${DIR}/chrome\"" - ln -sf "${GITPOD_REPO_ROOTS}/IE6/chrome" "${DIR}/chrome" + echo "> ln -sf \"${GITPOD_REPO_ROOTS}/IE6/chrome\" \"${DIR}/chrome\"" + ln -sf "${GITPOD_REPO_ROOTS}/IE6/chrome" "${DIR}/chrome" - cat << EOF > ~/Desktop/${version}.desktop + cat << EOF > ~/Desktop/${version}.desktop [Desktop Entry] Version=1.0 Name=${version} @@ -57,5 +59,11 @@ Categories=Network;WebBrowser; Keywords=web;browser;internet; EOF - cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop + sudo chmod +x ~/Desktop/${version}.desktop + cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop + else + echo "A problem occurred during profile creation. Skipping ${version}..." done + +echo "" +echo "Script has concluded - Firefox (of various variants) installed!" From f4070c0202d7f3e9e1ea96a29f7caf340744d887 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Fri, 26 Jan 2024 21:19:08 +0000 Subject: [PATCH 5/7] Grumble grumble... --- .gitpod/installation.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitpod/installation.sh b/.gitpod/installation.sh index 7bdd19c..12db44b 100755 --- a/.gitpod/installation.sh +++ b/.gitpod/installation.sh @@ -63,6 +63,7 @@ EOF cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop else echo "A problem occurred during profile creation. Skipping ${version}..." + fi done echo "" From 283a50d7584ec62b827a10561aaf502c24ec66e0 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Fri, 26 Jan 2024 21:38:11 +0000 Subject: [PATCH 6/7] Don't redownload/setup if existing. --- .gitpod/installation.sh | 55 +++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/.gitpod/installation.sh b/.gitpod/installation.sh index 12db44b..1624420 100755 --- a/.gitpod/installation.sh +++ b/.gitpod/installation.sh @@ -4,6 +4,9 @@ sudo apt-get remove -y firefox mkdir -p ~/.local/share/applications +# In case a prior installation has failed. +sudo rm -rf /opt/firefox + declare -A firefox_versions=( ["firefox-regular"]="firefox-latest" ["firefox-esr"]="firefox-esr-latest" @@ -13,13 +16,25 @@ declare -A firefox_versions=( for version in "${!firefox_versions[@]}"; do product=${firefox_versions[$version]} + existed=0 echo "" echo "Installing: ${version}" echo "---------------------------------------" - echo "> wget -q -O \"/opt/${version}.tar.bz2\" \"https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US\"" - sudo wget -q -O "/opt/${version}.tar.bz2" "https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US" + if [ -d "/opt/${version}" ]; then + existed=1 + echo "Detected existing install, reinstalling..." + echo "> sudo rm -r \"/opt/${version}\"" + sudo rm -r "/opt/${version}" + fi + + if [ ! -f "/opt/${version}.tar.bz2" ]; then + echo "> wget -q -O \"/opt/${version}.tar.bz2\" \"https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US\"" + sudo wget -q -O "/opt/${version}.tar.bz2" "https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US" + else + echo "${version} has already been downloaded. Skipping..." + fi echo "> sudo tar -xjf \"/opt/${version}.tar.bz2\" -C /opt" sudo tar -xjf "/opt/${version}.tar.bz2" -C /opt @@ -27,24 +42,25 @@ for version in "${!firefox_versions[@]}"; do echo "> sudo mv /opt/firefox \"/opt/${version}\"" sudo mv /opt/firefox "/opt/${version}" - echo "> ln -sf \"/opt/${version}/firefox\" \"/usr/local/bin/${version}\"" - sudo ln -sf "/opt/${version}/firefox" "/usr/local/bin/${version}" - + if [ $existed -eq 0 ]; then + echo "> ln -sf \"/opt/${version}/firefox\" \"/usr/local/bin/${version}\"" + sudo ln -sf "/opt/${version}/firefox" "/usr/local/bin/${version}" - echo "> /opt/${version}/firefox -CreateProfile $version" - /opt/${version}/firefox -CreateProfile $version - exit_status=$? + + echo "> /opt/${version}/firefox -CreateProfile $version" + /opt/${version}/firefox -CreateProfile $version + exit_status=$? - if [ $exit_status -eq 0 ]; then - DIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")" + if [ $exit_status -eq 0 ]; then + DIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")" - echo "> cp .gitpod/user.js \"${DIR}\"" - cp .gitpod/user.js "${DIR}" + echo "> cp .gitpod/user.js \"${DIR}\"" + cp .gitpod/user.js "${DIR}" - echo "> ln -sf \"${GITPOD_REPO_ROOTS}/IE6/chrome\" \"${DIR}/chrome\"" - ln -sf "${GITPOD_REPO_ROOTS}/IE6/chrome" "${DIR}/chrome" + echo "> ln -sf \"${GITPOD_REPO_ROOTS}/IE6/chrome\" \"${DIR}/chrome\"" + ln -sf "${GITPOD_REPO_ROOTS}/IE6/chrome" "${DIR}/chrome" - cat << EOF > ~/Desktop/${version}.desktop + cat << EOF > ~/Desktop/${version}.desktop [Desktop Entry] Version=1.0 Name=${version} @@ -59,10 +75,13 @@ Categories=Network;WebBrowser; Keywords=web;browser;internet; EOF - sudo chmod +x ~/Desktop/${version}.desktop - cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop + sudo chmod +x ~/Desktop/${version}.desktop + cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop + else + echo "A problem occurred during profile creation. Skipping ${version}..." + fi else - echo "A problem occurred during profile creation. Skipping ${version}..." + echo "Since ${version} was already installed, let's skip the gubbins." fi done From bf269350a81804c8b0a103163e71987e8eef9828 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Fri, 26 Jan 2024 21:43:09 +0000 Subject: [PATCH 7/7] Tarted up the info outputs. --- .gitpod/installation.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitpod/installation.sh b/.gitpod/installation.sh index 1624420..4a03ce1 100755 --- a/.gitpod/installation.sh +++ b/.gitpod/installation.sh @@ -19,12 +19,12 @@ for version in "${!firefox_versions[@]}"; do existed=0 echo "" - echo "Installing: ${version}" + echo "🦊 Installing: ${version}" echo "---------------------------------------" if [ -d "/opt/${version}" ]; then existed=1 - echo "Detected existing install, reinstalling..." + echo "ℹ️ Detected existing install, reinstalling..." echo "> sudo rm -r \"/opt/${version}\"" sudo rm -r "/opt/${version}" fi @@ -33,7 +33,7 @@ for version in "${!firefox_versions[@]}"; do echo "> wget -q -O \"/opt/${version}.tar.bz2\" \"https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US\"" sudo wget -q -O "/opt/${version}.tar.bz2" "https://download.mozilla.org/?product=${product}&os=linux64&lang=en-US" else - echo "${version} has already been downloaded. Skipping..." + echo "ℹ️ ${version} has already been downloaded. Skipping..." fi echo "> sudo tar -xjf \"/opt/${version}.tar.bz2\" -C /opt" @@ -78,12 +78,12 @@ EOF sudo chmod +x ~/Desktop/${version}.desktop cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop else - echo "A problem occurred during profile creation. Skipping ${version}..." + echo "❌ A problem occurred during profile creation. Skipping ${version}..." fi else - echo "Since ${version} was already installed, let's skip the gubbins." + echo "ℹ️ Since ${version} was already installed, let's skip the gubbins." fi done echo "" -echo "Script has concluded - Firefox (of various variants) installed!" +echo "🚀 Script has concluded - Firefox (of various variants) installed!"