Closed carribeiro closed 13 years ago
You may be able to run this in the fabfile using the fabric api sudo command: http://docs.fabfile.org/en/1.0.1/api/core/operations.html#fabric.operations.sudo
On 23 April 2011 23:35, carribeiro < reply@reply.github.com>wrote:
The ftpserver did not work at first in a computer that was prepared using the development setup, for two reasons:
1) When called from inside the virtualenv, it does not run as root. 2) When called with sudo it does not respect the current virtualenv.
It's probable that this error was not detected before because there is already a pyftpdlib module installed on the system's Python site-packages library. However, when tested on a clean development machine, the only copy of pyftpdlib is under the virtualenv and the script does not run.
In order to run the ftserver I had to issue the following command:
sudo ../../.env/bin/python ftpserver.py start
This is not correct and has to be fixed. There are a few ways to fix it:
1) run the ftpserver out of the virtualenv (not recommended, but can be done for lack of other options). In this case the deploy script needs to install the pyftpdlib at the system level.
2) find another way to run a script using the virtualenv parameters, but under sudo.
3) create a bash script with the command above, effectively hiding it from the user.
Reply to this email directly or view it on GitHub: https://github.com/carribeiro/vdeli/issues/8
i pushed solution to repo. bash script "ftpserver" in cdnmanager/ftpserver/, the instructions below: copy or create a symbol link: sudo ln -s xyz/abc/ftpserver /etc/init.d/ftpserver startup ftpserver on boot (ubuntu or debian distro) sudo update-rc.d /etc/init.d/ftpserver defaults remove ftpserver on boot sudo update-rc.d -f ftpserver remove
I fixed fabfile.py but this need it be revised.
1) Trivial bug to fix - two slashes in the path:
cribeiro@ubuntu:~/work/vdeli/cdnmanager/ftpserver$ bash ftpserver
ftpserver: line 3: /home/chacara/work/vdeli//.env/bin/activate: No such file or directory
ftpserver [start|stop|restart|status|debug]
2) Also, this line needs to be substitute with the virtualenv path that is installed. This can be done either at fabfile time, or in the script itself (harder, but can be done).
I decided to go with the simples method (the fabfile sets the correct VDELIHOME location during deployment). As such we need to:
commit ec2c1ef286f6a10ad20b0a2d0e31b64ca4c04017 Author: Carlos Ribeiro carribeiro@gmail.com Date: Sun Apr 24 07:50:49 2011 -0300
Fixed several issues with the deployment of localized scripts, specially ftpserver.
- created the local_scripts folder
- created the local_scripts/README documentation file
- moved local_settings.py and ftpserver to the local_scripts folder
- changed the fabfile.py script to do substitution of the VDELIHOME path in the ftpserver script
- instead of a symlink, now it copies the ftpserver script to the /etc/init.d location. symlinks don't work with updaterc.d
commit 54c8e26bbdf2b76ff48c30686d654ca6413a3ba8 Author: Carlos Ribeiro carribeiro@gmail.com Date: Sun Apr 24 08:50:22 2011 -0300
Second part of the changes to implement the local_scripts directory. The previous commit was missing some files. Also, the ftpserver bash script had abug because I forgot to substitute all ocurrences of $ENV by $VDELIHOME.
The ftpserver did not work at first in a computer that was prepared using the development setup, for two reasons:
1) When called from inside the virtualenv, it does not run as root. 2) When called with sudo it does not respect the current virtualenv.
It's probable that this error was not detected before because there is already a pyftpdlib module installed on the system's Python site-packages library. However, when tested on a clean development machine, the only copy of pyftpdlib is under the virtualenv and the script does not run.
In order to run the ftserver I had to issue the following command:
sudo ../../.env/bin/python ftpserver.py start
This is not correct and has to be fixed. There are a few ways to fix it:
1) run the ftpserver out of the virtualenv (not recommended, but can be done for lack of other options). In this case the deploy script needs to install the pyftpdlib at the system level.
2) find another way to run a script using the virtualenv parameters, but under sudo.
3) create a bash script with the command above, effectively hiding it from the user.