View Single Post
Old 01-14-2012, 06:14 PM   #1
squigish
Junior Member
squigish began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Jan 2012
Device: Kindle 3, Kindle Touch
Script to update to latest version

I've written a script to upgrade calibre to the latest version, and then restart it. I scheduled it to run every Saturday morning using crontab on a Linux server. The script works fine when I run it manually, but fails when crontab runs it.

Note: I do not have root or sudoer privileges on this server. I am installing calibre inside my home directory. I also don't have physical access to the server, I just log in using VNC or SSH. My VNC display is :2.0

the script:
Code:
#/bin/sh

killall calibre
rm /u1/myusername/opt/* -rf
python -c "import sys; py3 = sys.version_info[0] > 2; u = __import__('urllib.request' if py3 else 'urllib', fromlist=1); exec(u.urlopen('http://status.calibre-ebook.com/linux_installer').read()); main(install_dir='/u1/myusername/opt')"

env DISPLAY=:2.0 XAUTHORITY=/u1/myusername/.Xauthority /u1/myusername/opt/calibre/calibre &
When I run the script from the command line over an SSH session, I get the following output:

Code:
Automatically installing to: /u1/myusername/opt
Will download and install calibre-0.8.35-i686.tar.bz2
                    Downloading calibre-0.8.35-i686.tar.bz2
100% [======================================================================]
                                                                                Downloaded 49210770 bytes
Checking downloaded file integrity...
tar: Record size = 8 blocks
Extracting files to /u1/myusername/opt/calibre ...
Extracting application files...
Creating symlinks...
        Symlinking /u1/myusername/opt/calibre/fetch-ebook-metadata to /usr/bin/fetch-ebook-metadata
Traceback (most recent call last):
  File "site.py", line 58, in main
  File "site-packages/calibre/linux.py", line 559, in main
  File "site-packages/calibre/linux.py", line 129, in __init__
OSError: [Errno 13] Permission denied
Run "calibre" to start calibre
And when I log in to VNC, calibre is running.

Every Saturday, I get the following email from crontab
Code:
Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File "<string>", line 270, in main
 File "<string>", line 182, in prints
TypeError: encode() argument 1 must be string, not None
env: /u1/myusername/opt/calibre/calibre: No such file or directory
and calibre is not running, and doesn't download the news or email it to me.

I suspect that the problem may have to do the permission denied error I get when running the script manually, because I don't have root privileges. Is there an option to install calibre without symlinking or doing anything else that requires root? I admit I don't really understand all of the python code in the script, I just copied it from the calibre website.

Thanks a bunch!
squigish is offline   Reply With Quote