Skip to content

Commit

Permalink
Devcontainer support.
Browse files Browse the repository at this point in the history
  • Loading branch information
soup-bowl committed Nov 5, 2024
1 parent 9b34b5d commit e65154f
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 37 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Firefoxes",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {
"password": "noPassword"
}
},
"forwardPorts": [6080],
"postCreateCommand": "bash .devcontainer/installation.sh",
"remoteUser": "root"
}
99 changes: 71 additions & 28 deletions .gitpod/installation.sh → .devcontainer/installation.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,66 @@
#! /bin/bash

sudo apt-get remove -y firefox
create_desktop_entry() {
local version="$1"
local path="$2"

mkdir -p ~/.local/share/applications
cat << EOF > "${path}/${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
}

create_user_settings() {
local path="$1"

cat << EOF > "${path}/user.js"
// Used by Gitpod or a dev env to setup Firefox for UserStyle debugging.
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
user_pref("browser.compactmode.show", true);
user_pref("browser.toolbars.bookmarks.visibility", "always");
user_pref("devtools.debugger.remote-enabled", true);
user_pref("devtools.chrome.enabled", true);
user_pref("browser.uidensity", 1);
user_pref("browser.tabs.inTitlebar", 0);
EOF
}

OP_PATH="${1:-$PWD}"

mkdir -p $HOME/.local/share/applications
mkdir -p $HOME/Desktop

# For Fluxbox
FLUXBOX_MENU="$HOME/.fluxbox/menu"
if [[ -f "$FLUXBOX_MENU" ]]; then
echo "Fluxbox detected - prepping menu edits."
TMPFLUXMENU="/tmp/ff_fluxmenu"
> "$TMPFLUXMENU"
echo " [submenu] (Firefox Variants) {}" >> "$TMPFLUXMENU"
fi

# 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"
["firefox-nightly"]="firefox-nightly-latest"
["firefox-developer"]="firefox-devedition-latest"
["firefox-nightly"]="firefox-nightly-latest"
["firefox-developer"]="firefox-devedition-latest"
)

for version in "${!firefox_versions[@]}"; do
product=${firefox_versions[$version]}
product=${firefox_versions[$version]}
existed=0

echo ""
Expand All @@ -37,10 +82,10 @@ for version in "${!firefox_versions[@]}"; do
fi

echo "> sudo tar -xjf \"/opt/${version}.tar.bz2\" -C /opt"
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}"
sudo mv /opt/firefox "/opt/${version}"

if [ $existed -eq 0 ]; then
echo "> ln -sf \"/opt/${version}/firefox\" \"/usr/local/bin/${version}\""
Expand All @@ -52,31 +97,21 @@ for version in "${!firefox_versions[@]}"; do
exit_status=$?

if [ $exit_status -eq 0 ]; then
DIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")"
DIR="$(find $HOME/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")"

echo "> cp .gitpod/user.js \"${DIR}\""
cp .gitpod/user.js "${DIR}"
create_user_settings $DIR

echo "> ln -sf \"${GITPOD_REPO_ROOTS}/IE6/chrome\" \"${DIR}/chrome\""
ln -sf "${GITPOD_REPO_ROOTS}/IE6/chrome" "${DIR}/chrome"
echo "> ln -sf \"${OP_PATH}/IE6/chrome\" \"${DIR}/chrome\""
ln -sf "${OP_PATH}/IE6/chrome" "${DIR}/chrome"

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
# For Fluxbox
if [[ -f "$FLUXBOX_MENU" ]]; then
echo " [exec] ($version) {/opt/${version}/firefox -P ${version}}" >> "$TMPFLUXMENU"
fi

sudo chmod +x ~/Desktop/${version}.desktop
cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop
create_desktop_entry $version $HOME/Desktop
sudo chmod +x $HOME/Desktop/${version}.desktop
cp $HOME/Desktop/${version}.desktop $HOME/.local/share/applications/${version}.desktop
else
echo "❌ A problem occurred during profile creation. Skipping ${version}..."
fi
Expand All @@ -85,5 +120,13 @@ EOF
fi
done

if [[ -f "$FLUXBOX_MENU" ]]; then
echo "Editing fluxbox menu."
echo " [end]" >> "$TMPFLUXMENU"
sed -i "/^\[begin\] (\s*Application Menu\s*)/r $TMPFLUXMENU" "$FLUXBOX_MENU"
rm "$TMPFLUXMENU"
fi

echo ""
echo "🚀 Script has concluded - Firefox (of various variants) installed!"

4 changes: 3 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
image: gitpod/workspace-full-vnc

tasks:
- command: bash .gitpod/installation.sh
- command: |
sudo apt-get remove -y firefox
bash .devcontainer/installation.sh

ports:
- port: 5900
Expand Down
8 changes: 0 additions & 8 deletions .gitpod/user.js

This file was deleted.

0 comments on commit e65154f

Please sign in to comment.