diff --git a/.gitignore b/.gitignore index fb33413d8e9c49907525751db221e78a3076e731..474266c429b4ec389b9f68dfb7616e7ebf05acc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .env homedir .*.sw? +dockerstartup/ diff --git a/docker-compose.yml b/docker-compose.yml index 6529a4c19620b58f7a5ec8e0156e63cefda3b65b..5aad9d8b1b3603d75d32422b77f3d0f6a717ca3b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: - SPYDER=${SPYDER} - ANACONDA=${ANACONDA} - KASM_USER=${VNC_USER} + - VNCOPTIONS=-PreferBandwidth -DynamicQualityMin=4 -DynamicQualityMax=7 -DLP_ClipDelay=0 -select-de manual -UnixRelay printer:/tmp/printer -allowoverride AcceptPointerEvents,BlacklistTimeout,BlacklistThreshold -blacklistthreshold 1000 -blacklisttimeout 1" volumes: diff --git a/docker/change_password.sh b/docker/change_password.sh index cff6ac1aa2af819d693dca273caa9cf066d6e2c5..2ca771d3b78e6f8cde3f0aa3bd193654005cd8cd 100755 --- a/docker/change_password.sh +++ b/docker/change_password.sh @@ -1,14 +1,19 @@ #!/bin/bash title="Changement du mot de passe" -password=$(zenity --title="$title" --question="Veuillez entrer votre mot de passe" --entry) -confirm=$(zenity --title="$title" --question="Veuillez entrer votre mot de passe" --entry) +password=$(zenity --title="$title" --text="Veuillez entrer votre mot de passe" --entry) +confirm=$(zenity --title="$title" --text="Veuillez confirmer votre mot de passe" --entry) icon="error" -if [ "$password" != "$confirm" ]; then - message=$(echo -e "$password\n$password" | vncpasswd -u $KASM_USER $HOME/.vnc/passwd) +ok=0 +if [ "$password" == "$confirm" ]; then + ok=1 + message=$(echo -e "$password\n$password\n" | kasmvncpasswd -u $KASM_USER -wo 2>&1) if [ $? -eq 0 ]; then - message="Mot de passe changé" + cp $HOME/.kasmpasswd $HOME/.kasmpasswd.persist + # Restart the VNC server + kill $(cat .vnc/*.pid) icon="info" + message="Le mot de passe a été changé" fi else message="La confirmation du mot de passe n'est pas identique au mot de passe" diff --git a/docker/custom_startup.sh b/docker/custom_startup.sh index 6225f467900c3ca4b33a5c80d347c21225cb11e1..6ecc32c8e05ce325ef8fb80aa365cbf8c12bf3ca 100755 --- a/docker/custom_startup.sh +++ b/docker/custom_startup.sh @@ -36,3 +36,11 @@ Exec=$(which spyder) eof fi chmod +x $VNC_HOME/Desktop/*.desktop + +if [ -f "$HOME/.kasmpasswd.persist" ]; then + cp $HOME/.kasmpasswd.persist $HOME/.kasmpasswd + chown 600 $HOME/.kasmpasswd +fi + +# We should not exit +sleep infinity diff --git a/kasm b/kasm new file mode 100755 index 0000000000000000000000000000000000000000..6f6197b861d790d20be985fc6fa72c00b5a55a6f --- /dev/null +++ b/kasm @@ -0,0 +1,70 @@ +#!/bin/bash + +is_docker() { + if [ ! -z "$(which docker 2>/dev/null | grep -v 'not found')" ]; + then + echo "1" + else + echo "0" + fi +} + +usage() { + echo -e "Usage $0 <command> [args]\n" + echo -e "COMMANDS\n" + echo "bash" + echo -e "\topens a shell in kasm" + echo "config" + echo -e "\tquery vncconfig [-list|-get|-set|desc] args" + echo "down" + echo -e "\tStops the services" + echo "reset_passwd" + echo -e "\tReinitialize the passowrd" + echo "restart" + echo -e "\trestarts the services" + echo "up" + echo -e "\tStarts the services" +} + +if [ "$(is_docker)" -eq 1 ]; then + if [ ! -z "$(which docker-compose 2>/dev/null)" ]; then + compose="docker-compose" + else + compose="docker compose" + fi + cmd="$compose exec kasm" +fi +action=$1 +shift +# Keep actions sorted +case $action in + "bash") + $cmd bash + ;; + "config") + if [ -z "$1" ]; then + args="-list" + else + args="$@" + fi + $cmd vncconfig $args + ;; + "down") + $compose down $@ + ;; + "reset_passwd") + $cmd rm .kasmpasswd.persist + $compose down + $compose up -d + ;; + "restart") + $compose restart + ;; + "up") + $compose up $@ + ;; + *) + echo "ERROR: No command given" + usage + exit 1 +esac