Files
nicotine-less/entrypoint.sh
Claude 2742058a32 Disable Gitea workflows and stabilize VNC startup
Pause automated builds while updating the image, and improve VNC startup/logging with a one-way clipboard bridge for reliable browser sync.
2026-03-01 12:21:22 +01:00

68 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
set -e
# Update PUID and PGID if needed
if [ ! -z "$PUID" ] && [ "$PUID" != "1000" ]; then
usermod -u $PUID nicotine
fi
if [ ! -z "$PGID" ] && [ "$PGID" != "1000" ]; then
groupmod -g $PGID nicotine
fi
# Fix permissions on volumes
chown -R nicotine:nicotine /config /downloads /incomplete 2>/dev/null || true
# Create necessary directories
mkdir -p /home/nicotine/.local/share/nicotine
chown -R nicotine:nicotine /home/nicotine/.local
# Create symlink from Nicotine+ config to persistent volume
if [ ! -L "/home/nicotine/.config/nicotine" ]; then
rm -rf /home/nicotine/.config/nicotine
ln -s /config /home/nicotine/.config/nicotine
fi
# Configure VNC password if specified
if [ ! -z "$VNC_PASSWORD" ]; then
mkdir -p /home/nicotine/.vnc
echo "$VNC_PASSWORD" | vncpasswd -f > /home/nicotine/.vnc/passwd
chmod 600 /home/nicotine/.vnc/passwd
chown nicotine:nicotine /home/nicotine/.vnc/passwd
fi
# Export environment variables for supervisord
export DISPLAY=${DISPLAY:-:0}
export VNC_PORT
export NOVNC_PORT
export VNC_RESOLUTION
export VNC_DEPTH
export USER
# Ensure X11 socket directory exists with the correct permissions (needed by Xvnc)
mkdir -p /tmp/.X11-unix
chmod 1777 /tmp/.X11-unix
chown root:root /tmp/.X11-unix
# Remove stale X lock files for the configured DISPLAY to avoid "Server is already active" errors
DISPLAY_NUM=${DISPLAY#:}
LOCK_FILE="/tmp/.X${DISPLAY_NUM}-lock"
SOCKET_FILE="/tmp/.X11-unix/X${DISPLAY_NUM}"
if [ -f "$LOCK_FILE" ]; then
LOCK_PID=$(cat "$LOCK_FILE" 2>/dev/null || true)
if pgrep -f "Xvnc :${DISPLAY_NUM}" >/dev/null 2>&1; then
echo "Existing Xvnc server detected for display :${DISPLAY_NUM}; leaving lock file intact"
elif [ -n "$LOCK_PID" ] && kill -0 "$LOCK_PID" 2>/dev/null; then
echo "Lock file $LOCK_FILE points to PID $LOCK_PID, but no Xvnc found; removing stale lock"
rm -f "$LOCK_FILE"
rm -f "$SOCKET_FILE"
else
echo "Removing stale X lock file $LOCK_FILE"
rm -f "$LOCK_FILE"
rm -f "$SOCKET_FILE"
fi
fi
# Start supervisord as root (which will start processes as nicotine user)
exec "$@"