- Newest
- Most votes
- Most comments
Yes, there are ways to automate the login process and run programs automatically in NICE DCV on Ubuntu, as well as keep the session and program active. Here's how you can approach these requirements:
- Automatic login and program execution: To automatically log in the "ubuntu" user and run a program after NICE DCV setup, you can modify your UserData script to include additional steps:
a) Set up automatic login for the "ubuntu" user by configuring the GNOME Display Manager (GDM). b) Create a startup script that launches your desired program. c) Add the startup script to the user's autostart applications.
- Keeping the session and program active: To prevent the login session from logging out and the program from closing, you can:
a) Disable screen locking and automatic logout in the GNOME desktop settings. b) Use a tool like "caffeine" to prevent the system from going to sleep or activating the screensaver. c) If your program is a command-line application, you can run it within a terminal multiplexer like "screen" or "tmux" to keep it running even if the session disconnects.
Here's an example of how you might modify your UserData script to achieve these goals:
- After setting up NICE DCV, add these lines to your script:
# Set up automatic login for ubuntu user
sudo sed -i 's/^# AutomaticLoginEnable = true/AutomaticLoginEnable = true/' /etc/gdm3/custom.conf
sudo sed -i 's/^# AutomaticLogin = user1/AutomaticLogin = ubuntu/' /etc/gdm3/custom.conf
# Create a startup script
cat << EOF > /home/ubuntu/startup.sh
#!/bin/bash
# Add your program launch command here
your_program_command &
EOF
chmod +x /home/ubuntu/startup.sh
# Add startup script to autostart
mkdir -p /home/ubuntu/.config/autostart
cat << EOF > /home/ubuntu/.config/autostart/custom-startup.desktop
[Desktop Entry]
Type=Application
Exec=/home/ubuntu/startup.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=Custom Startup
Name=Custom Startup
Comment[en_US]=Run custom startup script
Comment=Run custom startup script
EOF
# Disable screen lock and automatic logout
gsettings set org.gnome.desktop.screensaver lock-enabled false
gsettings set org.gnome.desktop.session idle-delay 0
# Install and configure caffeine to prevent sleep
sudo apt-get install -y caffeine
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
- To keep the program running even if the DCV session disconnects, you can use screen:
sudo apt-get install -y screen
echo "screen -dmS my_program /path/to/your/program" >> /home/ubuntu/startup.sh
This will start your program in a detached screen session, which will continue running even if the DCV session is disconnected.
Remember to replace "your_program_command" and "/path/to/your/program" with the actual command or path to launch your specific program.
These modifications should allow the "ubuntu" user to automatically log in to the NICE DCV desktop, run your program, and keep the session and program active even after disconnection. However, please note that automatic login may have security implications, so ensure that appropriate security measures are in place for your EC2 instance.
Sources
Run commands when you launch an EC2 instance with user data input - Amazon Elastic Compute Cloud
How do I install GUI (graphical desktop) on Ubuntu EC2 instance and access it with NICE DCV? | AWS re:Post
How do I install GUI (graphical desktop) on Amazon EC2 instances running Ubuntu Linux? | AWS re:Post
Relevant content
asked a year ago
asked 4 years ago

Thank you very much.