如何创建系统范围的自动启动文件?这将在运行 Maverick 桌面版本的云服务器上。
我以 root 身份登录并使用创建了一个自动启动文件,System/Preferences/StartupApplications但它最终进入/root/.config/autostart并且在重新启动时没有执行(据我所知)。autostart 文件是调用一个调用VNC 服务器的bash 脚本。
我将 .desktop 自动启动文件从/root/.config/autostartto复制/etc/xdg/autostart并重新启动。这似乎没有什么区别。
编辑正如评论中提到的,目标是运行我的 bash 脚本,该脚本在启动时启动 VNC 服务器;不是在登录时。
man*_*k13 19
首先,安装 TightVNC 服务器 sudo apt-get install tightvncserver。
为您希望登录的用户设置 VNC 服务器。当您第一次运行“vncserver”时,它会要求您设置密码。只允许 SSH 隧道或 VPN 连接。要在 VNC 会话启动时启动程序或会话,请修改~/.vnc/xstartup. 这是一个例子。
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid black
/opt/azureus/azureus &
k3b &
icewm-session &
Run Code Online (Sandbox Code Playgroud)将以下内容复制到/etc/init.d/vncserver. 最简单的方法是将它复制到剪贴板,sudo -i && cat > /etc/init.d/vncserver && exit在终端中运行,粘贴它,然后键入 CTRL-D。请务必将 USER 变量更改为您希望 VNC 服务器在其下运行的任何用户。
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Default-Start: 3 4 5
# Default-Stop: 0 6
### END INIT INFO
PATH="$PATH:/usr/X11R6/bin/"
# The Username:Group that will run VNC
export USER="mythtv"
#${RUNAS}
# The display that VNC will use
DISPLAY="1"
# Color depth (between 8 and 32)
DEPTH="16"
# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"
# The name that the VNC Desktop will have.
NAME="my-vnc-server"
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
Run Code Online (Sandbox Code Playgroud)使脚本可执行sudo chmod +x /etc/init.d/vncserver。