# = execute as root
$ = execute as normal user (user zeipis)
> = execute SQL command in mysql


= OS =

1. Make sure that the user account running zeipis has rw access to
/dev/dvb/adapter? , e.g. by adding it to group 'video' or similar in /etc/group . 
2. Create a directory for your TV recordings, and make the user account
running zeipis own that directory, e.g.
$ chown zeipis /media/disk2/zeipis/
You may use several directories, they will fill up in succession.

= DB init =

# mysql < .../source/zeipis/org/bucksch/zeipis/core/create-database.sql
# pwgen (to generate a random password)
# mysql
> SET PASSWORD FOR zeipis@localhost = PASSWORD('yourchosenpassword');
(of course replace yourchosenpassword)
> GRANT ALL ON zeipis.* TO zeipis@'192.168.1.%' IDENTIFIED BY "yourchosenpassword";
(only if you want to use the EPG or zeipis parts on other
computers on your local network.
Replace 192.168.1.% with your network IP address block.
You can check this with # ifconfig .)

$ (create and) edit ~/.zeipis/start.conf (or /etc/zeipis/start.conf )

CoreServerHostname=yourhostname
DBHostname=localhost (or yourhostname)
DBName=zeipis
DBUsername=zeipis
DBPassword=yourchosenpassword


= Devices setup =

$ knoda (or similar SQL tool)
Devices:
In table 'device', add a row for each DVB card you have, e.g.:
deviceid = 1
devicetype = 'DVB'
devicesubtype = 'DVB-S2'
host = 'yourhostname' -- This must be the same as configured in your Linux system,
-- e.g. /etc/hostname on Ubuntu.
-- This is sometimes with domain, but usually without.
dvb_num = 0  -- this is the ? number in /dev/dvb/adapter?/, e.g. 0 for the first DVB card
dvb_fullts = 0 -- always 0 for now
dvb_encrypt_systems -- If you have pay-TV, and a CAM for the encrypted channels,
-- enter the CA system IDs that the CAM supports
-- (as comma-separated list, no spaces).
-- gnutv --cammenu -adapter <dvb_num> will tell you (wait a few seconds).
-- If you don't have pay-TV / encrypted cable TV / CAM, leave empty.
analog_* -- leave empty

Stores:
In table 'store', add a row for each directory where to store the recordings
(as created above):
storename = 'hostname-1' -- or whatever you choose
host = 'yourhostname' -- the machine where the storage is and the relevant Zeipis server runs
directory = '/media/disk2/zeipis/' -- the directory at |host| where zeipis should store the recordings
-- make sure to have a trailing slash

Prefs:
In table 'prefs', add a row:
prefkey = 'languages'
value_str = 'en,de' -- add all languages that you want to see TV stations for
-- comma-separated list, no spaces. 2-letter ISO language code, e.g.
-- "de,en" for German and English.
-- en = English, de = German, fr = French, es = Spanish
-- If you have DVB-S, keep the list small (1-2 langs), otherwise you'll be spammed
-- with hundreds of channels you won't use.


= Channel scan =

$ LD_LIBRARY_PATH="JNI/dvbtune/:JNI/dvbca/" java -cp zeipis.zip:/usr/share/java/mysql-connector-java.jar org.bucksch.zeipis.importer.Importer --format init --channels-conf /usr/share/dvb/dvb-s/Astra-19.2E
(Adapt the paths of mysql-java-connector and initial tuning file as necessary.
The initial tuning files may be in /usr/share/dvb/ (upstream) or
/usr/share/doc/dvb-utils/examples/scan/ (ubuntu).
Adapt the file path at the end to your DVB system type and your region.)

$ LD_LIBRARY_PATH="JNI/dvbtune/:JNI/dvbca/" java -cp zeipis.zip:/usr/share/java/mysql-connector-java.jar org.bucksch.zeipis.importer.Importer --channel-scan --card 1 --channel all
(Adapt the paths as necessary.
card is the deviceid that you gave above.

For DVB-S, "all" makes a full scan of the satellite, which can take 1 hour.
"all-db" is much faster (2 minutes), because it only re-scans the
already known transponders, it does not search for new transponders/frequencies,
but of course the first scan should be a full scan ("all").


= Stations =

Either (Germany only for now)
$ LD_LIBRARY_PATH="JNI/dvbtune/:JNI/dvbca/" java -cp zeipis.zip:/usr/share/java/mysql-connector-java.jar
org.bucksch.zeipis.importer.LineupImporter
or:
$ knoda (or similar SQL tool)
Station:
Open table 'station' and edit:
long_name, short_name -- as you wish
preset -- when in livetv mode (not implemented, because no frontend yet), this will be the channel number you enter on the remote control
disabled -- if you don't like a channel and don't want to see it, mark this TRUE. Do not delete stations, as this will mess up internal consistency, and they'll come back with the next scan anyways.
commercial_free -- you can check this to mark advertising-free channels, by whatever definition you like. Currently not used, but may be used as quality factor
xmltvid -- here, enter the channel id that your XMLTV source uses. This *should* be something looking like a domain name. You'll find it in the beginning of the XMLTV file.
Note that there's a table 'channel', but that's not very interesting for you. See docs.txt for more info.

XMLTV (program schedule import):
(You must have set the xmltvid of your important stations, in the last step)
$ tv_grab_eu_epgdata --output all.xmltv (or whatever grabber you use)
$ java -Xmx500m -cp zeipis.zip:/usr/share/java/mysql-connector-java.jar org.bucksch.zeipis.importer.Importer --xmltv all.xmltv


= Plan recordings = 

$ cd epg-qt
$ sh make.sh (read and adapt first)
$ ./zeipisDesktopEPG

= Start Zeipis =

$ LD_LIBRARY_PATH="JNI/dvbtune/:JNI/dvbca/" java -Xmx200m -cp zeipis.zip:/usr/share/java/mysql-connector-java.jar org.bucksch.zeipis.core.CoreServer
(Wait a some seconds, depending on amount of schedule data you have,
then it should print a lot of debug output from the scheduler,
and finally the list of programs it wants to record when.)


= Write a frontend =

See API.txt
$ wget/curl http://yourhostname:4962/recorded/list/
(only reports something when some recordings are already done)
$ mplayer -fs (whatever URL is in <location url=""> above)
