I don't know why but I get different results when I run a script directly compared with when I run it with fabric. (http://docs.fabfile.org)
I'm trying to run automatically vncserver and xfce4 on ubuntu 13.04 on an amazon ec2 vm.
This is my shell script:
echo $USER
vncserver -kill :1
pkill Xtightvnc|true; sleep 1; pkill -9 Xtightvnc|true
rm -fr $HOME/.vnc
mkdir $HOME/.vnc
chmod 700 $HOME/.vnc
echo 123457 | vncpasswd -f > $HOME/.vnc/passwd
chmod 600 $HOME/.vnc/passwd
cp /tmp/setuptmplts/home/_vnc/xstartup $HOME/.vnc/
chmod 755 $HOME/.vnc/xstartup
mkdir -p $HOME/.config
cp -a /tmp/setuptmplts/home/_config/xfce4 $HOME/.config/
vncserver -geometry 1366x768 -depth 24 :1
When I run this script directly on ec2 machine, it works correctly and I can connect to it and see the xfce desktop.
But when I run it with fabric it runs without error and even I can connect to vnc but I just see a grey screen with a cross cursor. It means that I have vncserver process but not the xfce.
This is my fabfile:
from fabric.api import run, env, task
env.use_ssh_config=True
@task
def vnc():
run('/home/ubuntu/b')
I run my fabfile like this (I have a .ssh/config file):
fab -H ec2 vnc
It will done without error but I have not xfce process.
But if I run it via ssh I will have xfce process.
ssh ec2 /home/ubuntu/b
Or if I connecto to the vm via ssh and then run it directly, it works and xfce is live.
I have added these two lines to the end of bash script (/home/ubuntu/b):
sleep 3
echo `pgrep xfce`
And I see that xfce is live in both cases! It means that I have xfce when I try with fabric! but I see that when fabric finished its work xfce processes dies! while vncserver is live.
My xstartup file is like this (/tmp/setuptmplts/home/_vnc/xstartup):
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
I try to uncomment x-window-manager but nothing different. xfce processes dies after fabric finished but live when I try with ssh or directly.