Download 005-electronics-engineer/workspace/t1/croc/scripts/start_vnc.sh from Continual-Learning-Exam/CLE-Lite-Workspaces: direct link, hf CLI and curl.
- Browser
- Download file 5.08 kB
-
https://huggingface.co/datasets/Continual-Learning-Exam/CLE-Lite-Workspaces/resolve/main/005-electronics-engineer/workspace/t1/croc/scripts/start_vnc.sh
- Command line
-
hf download hf://datasets/Continual-Learning-Exam/CLE-Lite-Workspaces/005-electronics-engineer/workspace/t1/croc/scripts/start_vnc.sh
-
curl -L -o start_vnc.sh https://huggingface.co/datasets/Continual-Learning-Exam/CLE-Lite-Workspaces/resolve/main/005-electronics-engineer/workspace/t1/croc/scripts/start_vnc.sh
5.08 kB
| # ======================================================================== | |
| # Start script for IIC docker images (VNC) | |
| # | |
| # SPDX-FileCopyrightText: 2022-2023 Harald Pretl and Georg Zachl | |
| # Johannes Kepler University, Institute for Integrated Circuits | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # ======================================================================== | |
| if [ -n "${DRY_RUN}" ]; then | |
| echo "[INFO] This is a dry run, all commands will be printed to the shell (Commands printed but not executed are marked with $)!" | |
| ECHO_IF_DRY_RUN="echo $" | |
| fi | |
| # SET YOUR DESIGN PATH RIGHT! | |
| DESIGNS="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")" | |
| if [ -z ${DESIGNS+z} ]; then | |
| DESIGNS=$HOME/eda/designs | |
| if [ ! -d "$DESIGNS" ]; then | |
| ${ECHO_IF_DRY_RUN} mkdir -p "$DESIGNS" | |
| fi | |
| echo "[INFO] Design directory auto-set to $DESIGNS." | |
| fi | |
| # Set the host ports, and disable them with 0. Only used if not set as shell variables! | |
| if [ -z ${WEBSERVER_PORT+z} ]; then | |
| WEBSERVER_PORT=80 | |
| fi | |
| if [ -z ${VNC_PORT+z} ]; then | |
| VNC_PORT=5901 | |
| fi | |
| if [ -z ${DOCKER_USER+z} ]; then | |
| DOCKER_USER="hpretl" | |
| fi | |
| if [ -z ${DOCKER_IMAGE+z} ]; then | |
| DOCKER_IMAGE="iic-osic-tools" | |
| fi | |
| if [ -z ${DOCKER_TAG+z} ]; then | |
| DOCKER_TAG="2025.12" | |
| fi | |
| if [ -z ${CONTAINER_NAME+z} ]; then | |
| CONTAINER_NAME="iic-osic-tools_xvnc_uid_"$(id -u) | |
| fi | |
| if [[ "$OSTYPE" == "linux"* ]]; then | |
| if [ -z ${CONTAINER_USER+z} ]; then | |
| CONTAINER_USER=$(id -u) | |
| fi | |
| if [ -z ${CONTAINER_GROUP+z} ]; then | |
| CONTAINER_GROUP=$(id -g) | |
| fi | |
| else | |
| if [ -z ${CONTAINER_USER+z} ]; then | |
| CONTAINER_USER=1000 | |
| fi | |
| if [ -z ${CONTAINER_GROUP+z} ]; then | |
| CONTAINER_GROUP=1000 | |
| fi | |
| fi | |
| # Check for UIDs and GIDs below 1000, except 0 (root) | |
| if [[ ${CONTAINER_USER} -ne 0 ]] && [[ ${CONTAINER_USER} -lt 1000 ]]; then | |
| prt_str="# [WARNING] Selected User ID ${CONTAINER_USER} is below 1000. This ID might interfere with User-IDs inside the container and cause undefined behavior! #" | |
| printf -- '#%.0s' $(seq 1 ${#prt_str}) | |
| echo | |
| echo "${prt_str}" | |
| printf -- '#%.0s' $(seq 1 ${#prt_str}) | |
| echo | |
| fi | |
| if [[ ${CONTAINER_GROUP} -ne 0 ]] && [[ ${CONTAINER_GROUP} -lt 1000 ]]; then | |
| prt_str="# [WARNING] Selected Group ID ${CONTAINER_GROUP} is below 1000. This ID might interfere with Group-IDs inside the container and cause undefined behavior! #" | |
| printf -- '#%.0s' $(seq 1 ${#prt_str}) | |
| echo | |
| echo "${prt_str}" | |
| printf -- '#%.0s' $(seq 1 ${#prt_str}) | |
| echo | |
| fi | |
| # Processing ports and other parameters | |
| PARAMS="" | |
| if [ "$WEBSERVER_PORT" -gt 0 ]; then | |
| PARAMS="$PARAMS -p $WEBSERVER_PORT:80" | |
| fi | |
| if [ "$VNC_PORT" -gt 0 ]; then | |
| PARAMS="$PARAMS -p $VNC_PORT:5901" | |
| fi | |
| if [ -n "${VNC_PW}" ]; then | |
| PARAMS="${PARAMS} -e VNC_PW=${VNC_PW}" | |
| fi | |
| if [ -n "${DOCKER_EXTRA_PARAMS}" ]; then | |
| PARAMS="${PARAMS} ${DOCKER_EXTRA_PARAMS}" | |
| fi | |
| # Check if the container exists and if it is running. | |
| if [ "$(docker ps -q -f name="${CONTAINER_NAME}")" ]; then | |
| echo "[WARNING] Container is running!" | |
| echo "[HINT] It can also be stopped with \"docker stop ${CONTAINER_NAME}\" and removed with \"docker rm ${CONTAINER_NAME}\" if required." | |
| echo | |
| echo -n "Press \"s\" to stop, and \"r\" to stop & remove: " | |
| read -r -n 1 k <&1 | |
| echo | |
| if [[ $k = s ]] ; then | |
| ${ECHO_IF_DRY_RUN} docker stop "${CONTAINER_NAME}" | |
| elif [[ $k = r ]] ; then | |
| ${ECHO_IF_DRY_RUN} docker stop "${CONTAINER_NAME}" | |
| ${ECHO_IF_DRY_RUN} docker rm "${CONTAINER_NAME}" | |
| fi | |
| # If the container exists but is exited, it is restarted. | |
| elif [ "$(docker ps -aq -f name="${CONTAINER_NAME}")" ]; then | |
| echo "[WARNING] Container ${CONTAINER_NAME} exists." | |
| echo "[HINT] It can also be restarted with \"docker start ${CONTAINER_NAME}\" or removed with \"docker rm ${CONTAINER_NAME}\" if required." | |
| echo | |
| echo -n "Press \"s\" to start, and \"r\" to remove: " | |
| read -r -n 1 k <&1 | |
| echo | |
| if [[ $k = s ]] ; then | |
| ${ECHO_IF_DRY_RUN} docker start "${CONTAINER_NAME}" | |
| elif [[ $k = r ]] ; then | |
| ${ECHO_IF_DRY_RUN} docker rm "${CONTAINER_NAME}" | |
| fi | |
| else | |
| echo "[INFO] Container does not exist, creating ${CONTAINER_NAME} ..." | |
| # Finally, run the container, and sets DISPLAY to the local display number | |
| #${ECHO_IF_DRY_RUN} docker pull "${DOCKER_USER}/${DOCKER_IMAGE}:${DOCKER_TAG}" | |
| # Disable SC2086, $PARAMS must be globbed and splitted. | |
| # shellcheck disable=SC2086 | |
| ${ECHO_IF_DRY_RUN} docker run -d --user "${CONTAINER_USER}:${CONTAINER_GROUP}" $PARAMS -v "$DESIGNS:/foss/designs:rw" --name "${CONTAINER_NAME}" "${DOCKER_USER}/${DOCKER_IMAGE}:${DOCKER_TAG}" | |
| fi |