| 1 | #!/usr/bin/python |
|---|
| 2 | # File: unixinst.py |
|---|
| 3 | |
|---|
| 4 | ## This file is part of Kombilo, a go database program. |
|---|
| 5 | ## It serves to install Kombilo systemwide under Unix. |
|---|
| 6 | |
|---|
| 7 | ## Copyright (C) 2001-2 Ulrich Goertz (u@g0ertz.de) |
|---|
| 8 | |
|---|
| 9 | ## This program is free software; you can redistribute it and/or modify |
|---|
| 10 | ## it under the terms of the GNU General Public License as published by |
|---|
| 11 | ## the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | ## (at your option) any later version. |
|---|
| 13 | |
|---|
| 14 | ## This program is distributed in the hope that it will be useful, |
|---|
| 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | ## GNU General Public License for more details. |
|---|
| 18 | |
|---|
| 19 | ## You should have received a copy of the GNU General Public License |
|---|
| 20 | ## along with this program (gpl.txt); if not, write to the Free Software |
|---|
| 21 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 22 | ## The GNU GPL is also currently available at |
|---|
| 23 | ## http://www.gnu.org/copyleft/gpl.html |
|---|
| 24 | |
|---|
| 25 | ## --------------------------------------------- |
|---|
| 26 | |
|---|
| 27 | # Please read the comments below carefully and edit the file where necessary. |
|---|
| 28 | # Probably you will not have to make many changes. |
|---|
| 29 | # If on your system, the Python interpreter is not in /usr/bin (but in |
|---|
| 30 | # /usr/local/bin for example), you will have to change the first line |
|---|
| 31 | # of the file kombilo.py accordingly. |
|---|
| 32 | |
|---|
| 33 | import os |
|---|
| 34 | import sys |
|---|
| 35 | |
|---|
| 36 | # this should be used only on UNIXoid systems: |
|---|
| 37 | |
|---|
| 38 | if os.name != 'posix': |
|---|
| 39 | print 'This should be used only on Unix systems. On other systems,' |
|---|
| 40 | print 'it is not necessary to execute an installation script.' |
|---|
| 41 | sys.exit() |
|---|
| 42 | |
|---|
| 43 | # write global kombilo.def |
|---|
| 44 | |
|---|
| 45 | f = open('kombilo.def','w') |
|---|
| 46 | f.write('kombilo05\n') # Do NOT change this! |
|---|
| 47 | |
|---|
| 48 | f.write('i|%%%s\n' % '/tmp') # 'i'ndividual .def files: |
|---|
| 49 | # Look for .opt, .def files in $HOME/.kombilo, |
|---|
| 50 | # or -if $HOME is not set- in /tmp/.kombilo . |
|---|
| 51 | # You can replace /tmp with another directory that should |
|---|
| 52 | # be used as an alternative if $HOME is not set. |
|---|
| 53 | # It is very unlikely that you have to change this. |
|---|
| 54 | |
|---|
| 55 | # f.write('s|%%%s\n' % '/usr/local/share/sgf') |
|---|
| 56 | # Uncomment (and change) this to set a new |
|---|
| 57 | # default path for sgf files (i.e. files to be loaded |
|---|
| 58 | # to the search board in order to analyze them; these |
|---|
| 59 | # are not the databases) |
|---|
| 60 | # (the directory you use must exist). |
|---|
| 61 | # Leave it to make kombilo's directory the default. |
|---|
| 62 | |
|---|
| 63 | # f.write('p|%%%s\n' % '/usr/local/share/data') |
|---|
| 64 | # Uncomment (and change) this to set a new |
|---|
| 65 | # default path for the directories containing the |
|---|
| 66 | # database SGF files |
|---|
| 67 | # (the directory you use must exist). |
|---|
| 68 | # If you leave it kombilo's directory will be the default. |
|---|
| 69 | |
|---|
| 70 | # create link to kombilo.py |
|---|
| 71 | |
|---|
| 72 | os.symlink('/usr/local/share/kombilo05/kombilo.py', '/usr/local/bin/kombilo.py') |
|---|
| 73 | # This creates a link in /usr/local/bin pointing |
|---|
| 74 | # to kombilo.py . |
|---|
| 75 | # If you put the kombilo05 directory not in |
|---|
| 76 | # /usr/local/share, but somewhere else, |
|---|
| 77 | # you must change the first entry. |
|---|
| 78 | # You can change the second entry to put the link |
|---|
| 79 | # somewhere else, but the link should be in a |
|---|
| 80 | # directory which is in the PATH of the users. |
|---|
| 81 | # The file kombilo.py itself must stay in |
|---|
| 82 | # the kombilo05 subdirectory where you unpacked it, |
|---|
| 83 | # because it needs to find the other files in |
|---|
| 84 | # that subdirectory. |
|---|
| 85 | |
|---|
| 86 | # make kombilo.py executable for everybody |
|---|
| 87 | |
|---|
| 88 | os.chmod('kombilo.py', 0755) |
|---|
| 89 | |
|---|
| 90 | # check if the python interpreter is in the 'right' place |
|---|
| 91 | |
|---|
| 92 | if not os.path.exists('/usr/bin/python'): |
|---|
| 93 | print 'Your python interpreter is not installed in /usr/bin .' |
|---|
| 94 | print 'Please change the first line of kombilo.py and v.py accordingly.' |
|---|
| 95 | print '(You can find the location of the Python interpreter with' |
|---|
| 96 | print '\'which python\' .)' |
|---|
| 97 | |
|---|