Sunday 15 December 2013

How to install pkgdb2 (Fedora Package Database) from scratch

This cookbook assumes that Fedora 19 is freshly installed, with some design and development tools that the Fedora setup offers.

Install the Required Packages:

$ yum install vim git python-flask \
python-flask-wtf python-wtforms \
python-kitchen python-sqlalchemy \
 postgresql-server postgresql-plpython \
python-psycopg2 mod_wsgi memcached \
 community-mysql-libs community-mysql-devel \
 community-mysqlcommunity-mysql-server \
  python-dogpile-cache python-openid-teams \
  python-openid-cla python-bugzilla python-memcached \
  python-docutils python-dateutil \
 python-urllib3 MySQL-python \
 python-pip


$ git clone https://github.com/fedora-infra/python-fedora.git

$ cd python-fedora

$ python ./setup.py install

$ cd ~

Getting the Data from the sqllite database and installing pkgdb2 libraries:


$ git clone https://github.com/fedora-infra/packagedb2.git

$ cd packagedb2

$ python ./setup.py build

if it works properly then say:

$ python ./setup.py install

you may remove the build if you want.

$ python createdb.py

$ cd /var/tmp

Converting the data dump to and inserting it into MySQL:


$ service mysqld start

$ check: tail /var/log/messages
see if it started successfully "It should say 'Started MYSQL database Server'"

$ mysqladmin -u root password yourpassword


Download this awsome sqllit to mysql script:

www.redmine.org/attachments/download/8273/sqlite3-to-mysql.py

and place it under /var/tmp

go to /var/tmp : $ cd /var/tmp

$ sqlite3 pkgdb2_dev.sqlite .dump > mydump

unfortunately, we will have to modify the dump a little bit before we can start converting:

$ vi mydump












Change this line, and two more lines



$ mysql -u root -p

mysql> create database pkgdb2;
mysql> exit

$ cat mydump | python sqlite3-to-mysql.py | mysql -u root -p pkgdb2 --default-character-set=utf8

if it executes without saying anything, that means it was successful.

Configuring pkgdb2:


Now lets get back to configuring our pkgdb2.

$ cd ~/packagedb2/

$ mv ./utility/pkgdb2.cfg.sample ./utility/pkgdb2.cfg

$ vi ./utility/pkgdb2.cfg

comment the postgres line and un-comment the mysql line. Change the admin groups to Fedora Groups you are part of, or whatever groups you want to be included in the package admin groups. Also change the FAS username and Password line to reflect your FAS credentials, it can be set to none if you do not want FAS integration. Refer to the screen-shot:


Single quotes around the values are important.




Once that is done, we will have to modify our wsgi script.
$ vi pkgdb2.wsgi

Un-comment and adjust the values as shown:


 Then we will have to edit the default-config.py script to reflect our new database:

$ vi /lib/python2.7/site-packages/pkgdb2-0.1.0-py2.7.egg/pkgdb2/default_config.py


DB_URL = 'mysql://root:mypassword@localhost/pkgdb2'

then copy the pkgdb2.conf file to http configuration directory.

$ cp pkgdb2.conf /etc/httpd/conf.d

$ vi /etc/httpd/conf.d/pkgdb2.conf

make the following changes:



























Restart Apache and Mysql.
$ service httpd restart
$ service mysqld restart

Security Issues:


Open the http port:

$ iptables -I INPUT -p tcp --dport 80 -j ACCEPT

You may try to access the server, but it will give you a 403 forbidden most probably because of SELINUX or permissions missing on some of the folders. You may chose to disable SELINUX(not recommended) or make exceptions. You can make exceptions like this:

Try to access the website, get the 403 error and then come back to terminal and type

Do a tail /var/log/messages

look for this command, copy it and run on your terminal:
sealert -l a66201ea-062a-4a4b-8d2f-eaf29d3cd855

it will give you some things that are being blocked by SELINUX, and it will give you the boolean, just take the boolean and make exceptions:

setsebool -P httpd_read_user_content 1

Finishing Touch:


make sure you have execute(x) permission for everybody in the whole path to pkgdb2.cfg and pkgdb2.wsgi

also do: pip uninstall flask

and install/check if flask is installed with yum: yum install python-flask.

Now restart the services again

$ service httpd restart
$ service mysqld restart

Go to your favourite browser and type: localhost/pkgdb2
and you will see the deployement.

Any issues regarding this installation you can either ask me on the comments or directly talk to the package authors on github
they are really helpful people.



3 comments:

  1. The whole section about "Converting the data dump to and inserting it into MySQL:" is not necessary. You need to fill the configuration file first and then run the createdb.py file, which is pretty much what is said at http://pkgdb2.readthedocs.org/en/latest/deployment.html

    ReplyDelete
    Replies
    1. Yes, I will edit that section to be on the last, if they want to use mysql they can convert it like this and use it.

      Delete
    2. There is no need to convert anything, if they want to use mysql, they just set the right sqlalchemy URL in the configuration file and run the createdb.py with the configuration file and it will create the database directly in the MySQL server.

      Delete

How to add "Discord" in Steam's Big Picture Mode

 With the release of Steam deck a lot of people are turning into Steam Deck Big Picture Mode(BPM) to enjoy an exclusive gaming experience, t...