-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Michal Czyz <[email protected]>
- Loading branch information
1 parent
16a7194
commit dc8e1bf
Showing
6 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"image": "ghcr.io/openroad-codespace/test:latest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
"label": "desktop" | ||
} | ||
} | ||
// "onCreateCommand": "bash /workspaces/openroad-codespace/update-config.sh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Prebuild docker image | ||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
jobs: | ||
build: | ||
name: BUILD | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 600 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: "mczyz/dev" | ||
|
||
# - name: Pre-build dev container image | ||
# uses: devcontainers/[email protected] | ||
# with: | ||
# imageName: ghcr.io/openroad-codespace/test | ||
# cacheFrom: ghcr.io/openroad-codespace/test | ||
# push: always | ||
# configFile: ./.devcontainer/ubuntu-gui/devcontainer.json | ||
|
||
- name: Devcontainer build | ||
run: | | ||
npm install -g @devcontainers/cli | ||
devcontainer build --config .devcontainer/ubuntu-gui/devcontainer.json --workspace-folder . --push false --image-name test:latest | ||
docker image tag test:latest ghcr.io/antmicro/openroad-codespace:test | ||
- name: Login to GitHub Container Registry (GHCR) | ||
if: github.event_name != 'pull_request' && github.repository == 'antmicro/openroad-codespace' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: gha | ||
password: ${{ github.token }} | ||
|
||
- name: Push container image to GitHub Container Registry (GHCR) | ||
if: github.event_name != 'pull_request' && github.repository == 'antmicro/openroad-codespace' | ||
run: docker push ghcr.io/antmicro/openroad-codespace:test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Base file is from devcontainers/features/desktop-lite/install.sh | ||
# Original file is licensed as MIT | ||
# Applied modifications to the script 2024 | ||
|
||
user_name="root" | ||
group_name="root" | ||
LOG=/tmp/container-init.log | ||
|
||
export DBUS_SESSION_BUS_ADDRESS="autolaunch:" | ||
export DISPLAY=":1" | ||
export VNC_RESOLUTION="1920x1080x32" | ||
export LANG="en_US.UTF-8" | ||
export LANGUAGE="en_US.UTF-8" | ||
|
||
# Try to kill pid based on name | ||
kill_pid() | ||
{ | ||
PIDS_TO_KILL=$(ps axjf | grep $1 | awk '{print $2}') | ||
for PID in ${PIDS_TO_KILL[@]}; do | ||
echo "Attempting to kill $PID" | ||
kill -9 $PID | ||
done | ||
} | ||
|
||
# Execute the command it not already running | ||
startInBackgroundIfNotRunning() | ||
{ | ||
log "Starting $1." | ||
echo -e "\n** $(date) **" | sudoIf tee -a /tmp/$1.log > /dev/null | ||
if ! pgrep -x $1 > /dev/null; then | ||
keepRunningInBackground "$@" | ||
while ! pgrep -x $1 > /dev/null; do | ||
sleep 1 | ||
done | ||
log "$1 started." | ||
else | ||
echo "$1 is already running." | sudoIf tee -a /tmp/$1.log > /dev/null | ||
log "$1 is already running." | ||
fi | ||
} | ||
|
||
# Keep command running in background | ||
keepRunningInBackground() | ||
{ | ||
($2 bash -c "while :; do echo [\$(date)] Process started.; $3; echo [\$(date)] Process exited!; sleep 5; done 2>&1" | sudoIf tee -a /tmp/$1.log > /dev/null & echo "$!" | sudoIf tee /tmp/$1.pid > /dev/null) | ||
} | ||
|
||
# Use sudo to run as root when required | ||
sudoIf() | ||
{ | ||
if [ "$(id -u)" -ne 0 ]; then | ||
sudo "$@" | ||
else | ||
"$@" | ||
fi | ||
} | ||
|
||
# Use sudo to run as non-root user if not already running | ||
sudoUserIf() | ||
{ | ||
if [ "$(id -u)" -eq 0 ] && [ "${user_name}" != "root" ]; then | ||
sudo -u ${user_name} "$@" | ||
else | ||
"$@" | ||
fi | ||
} | ||
|
||
# Log messages | ||
log() | ||
{ | ||
echo -e "[$(date)] $@" | sudoIf tee -a $LOG > /dev/null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
. ./common.sh | ||
|
||
log "** SCRIPT START **" | ||
|
||
# Start dbus. | ||
log 'Running "/etc/init.d/dbus start".' | ||
if [ -f "/var/run/dbus/pid" ] && ! pgrep -x dbus-daemon > /dev/null; then | ||
sudoIf rm -f /var/run/dbus/pid | ||
fi | ||
sudoIf /etc/init.d/dbus start 2>&1 | sudoIf tee -a /tmp/dbus-daemon-system.log > /dev/null | ||
while ! pgrep -x dbus-daemon > /dev/null; do | ||
sleep 1 | ||
done | ||
|
||
# Startup tigervnc server and fluxbox | ||
sudoIf rm -rf /tmp/.X11-unix /tmp/.X*-lock | ||
mkdir -p /tmp/.X11-unix | ||
sudoIf chmod 1777 /tmp/.X11-unix | ||
sudoIf chown root:${group_name} /tmp/.X11-unix | ||
if [ "$(echo "${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=${VNC_RESOLUTION}x16; fi | ||
screen_geometry="${VNC_RESOLUTION%*x*}" | ||
screen_depth="${VNC_RESOLUTION##*x}" | ||
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "tigervncserver ${DISPLAY} -geometry ${screen_geometry} -depth ${screen_depth} -rfbport 5901 -dpi ${VNC_DPI:-96} -localhost -desktop fluxbox -fg" -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd | ||
|
||
# Spin up noVNC if installed and not running. | ||
if [ -d "/usr/local/novnc" ] && [ "$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then | ||
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen 6080 --vnc localhost:5901" | ||
log "noVNC started." | ||
else | ||
log "noVNC is already running or not installed." | ||
fi | ||
|
||
# Run whatever was passed in | ||
log "Executing \"$@\"." | ||
exec "$@" | ||
log "** SCRIPT EXIT **" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
. ./common.sh | ||
|
||
# Attempt to change default shell | ||
chsh -s /bin/bash | ||
|
||
# Install Konsole | ||
|
||
apt-get update | ||
sudoIf apt-get -y install konsole | ||
|
||
# Update fluxbox config | ||
|
||
fluxbox_apps="$(cat \ | ||
<< 'EOF' | ||
[transient] (role=GtkFileChooserDialog) | ||
[Dimensions] {100% 100%} | ||
[Position] (CENTER) {0 0} | ||
[end] | ||
EOF | ||
)" | ||
|
||
echo "${fluxbox_apps}" > ~/.fluxbox/apps | ||
|
||
fluxbox_menu="$(cat \ | ||
<< 'EOF' | ||
[begin] ( Application Menu ) | ||
[exec] (File Manager) { nautilus ~ } <> | ||
[exec] (Text Editor) { mousepad } <> | ||
[exec] (Terminal) { konsole -e /bin/bash } <> | ||
[exec] (Web Browser) { x-www-browser --disable-dev-shm-usage } <> | ||
[submenu] (System) {} | ||
[exec] (Set Resolution) { tilix -t "Set Resolution" -e bash /usr/local/bin/set-resolution } <> | ||
[exec] (Edit Application Menu) { mousepad ~/.fluxbox/menu } <> | ||
[exec] (Passwords and Keys) { seahorse } <> | ||
[exec] (Top Processes) { tilix -t "Top" -e htop } <> | ||
[exec] (Disk Utilization) { tilix -t "Disk Utilization" -e ncdu / } <> | ||
[exec] (Editres) {editres} <> | ||
[exec] (Xfontsel) {xfontsel} <> | ||
[exec] (Xkill) {xkill} <> | ||
[exec] (Xrefresh) {xrefresh} <> | ||
[end] | ||
[config] (Configuration) | ||
[workspaces] (Workspaces) | ||
[end] | ||
EOF | ||
)" | ||
|
||
echo "${fluxbox_menu}" > ~/.fluxbox/menu | ||
|
||
kill_pid tigervncserver | ||
kill_pid novnc | ||
|
||
ps axjf | grep tigervncserver | ||
ps axjf | grep novnc | ||
|
||
bash desktop-update.sh | ||
# rm -f /usr/local/etc/vscode-dev-containers/vnc-passwd |