Conary:Standalone Repository
From rPath Wiki
While the recommended method for establishing a local Conary repository for production use is to use mod_python as detailed in Conary Repository, you may also configure a single-threaded, standalone Conary repository server for debugging and testing purposes.
To configure a standalone Conary repository server, follow these steps:
Contents |
Install Prerequisite Packages
You must install the conary-repository package and its dependencies before you can configure and start a standalone repository server. Execute these commands on the designated server machine to install the necessary packages:
[you@localhost ~]$ su - [root@localhost ~]# conary update --resolve conary-repository
After the update concludes, you may exit the root shell; the majority of remaining commands may all be executed with normal user privileges.
Create Repository Server Configuration File
The standalone server requires some configuration directives be specified in a file. The exact name and location of the file is not critical, however for the purpose of this guide, you might consider using a filename such as conary.cnr, and locating the file in a dedicated subdirectory of your home directory, such as cnr, for example.
With this in mind, make the subdirectory, and with your preferred text editor, create a new configuration file within:
>$ mkdir cnr >$ vim cnr/conary.cnr
Use the following example contents for the configuration file, which provide an initial idea of the configuration directives. You may feel free to modify the values, but be sure to note your changes for the remaining steps.
Example conary.cnr:
serverName conary.example.com repositoryDB sqlite /tmp/testrepo/sqldb contentsDir /tmp/testrepo/contents logFile /tmp/testrepo/contents.log tmpDir /tmp/testrepo/tmp
When finished entering the content, or making changes, save the file, and exit the editor.
Create the directories specified in the conary.cnr:
>$ mkdir -p /tmp/testrepo/contents >$ mkdir -p /tmp/testrepo/tmp
Create Initial Database Schema and Add Users
Now, you'll need to use server.py to create the initial database schema, and add users requiring access to the repository to the database. First create the database schema:
>$ /usr/lib/python2.4/site-packages/conary/server/server.py --config-file ~/cnr/conary.cnr --migrate
Now create user accounts for accessing the repository. For this guide, you will create an admin user and an anonymous user:
>$ /usr/lib/python2.4/site-packages/conary/server/server.py --config-file ~/cnr/conary.cnr --add-user admin --admin --mirror
Type and confirm a password. After this, the admin user is created. Next, add an anonymous user, and set the anonymous user's password to anonymous so users are allowed anonymous access to the repository:
>$ /usr/lib/python2.4/site-packages/conary/server/server.py --config-file ~/cnr/conary.cnr --add-user anonymous
After adding the anonymous user, the next step is to start the repository, and confirm access.
| Additional user and permissions management can be done using the Conary Repository Web Interface. |
Start Repository and Confirm Access
To start the standalone Conary repository server, simply issue the following command:
>$ /usr/lib/python2.4/site-packages/conary/server/server.py --config-file ~/cnr/conary.cnr --port 8000
To confirm access to the repository, you'll need to use a second shell instance, and begin by creating a conaryrc file for testing purposes. A good location to create the file initially would be the ~/cnr subdirectory. Change to this subdirectory, and create the file:
>$ cd cnr >$ vim conaryrc
Use these values as content of your conaryrc file if you did not modify the values in the conary.cnr file earlier. Specify values matching your changes to conary.cnr if you did modify that file.
Example conaryrc:
installLabelPath conary.example.com@rpl:devel repositoryMap conary.example.com http://localhost.localdomain:8000/
Upon saving the conaryrc file, attempt to query your local repository server:
>$ conary rq >$
If all is well, you should see a slight pause, then the prompt should return. At this step, you have successfully configured, started, and queried your own empty repository server.
Automatically Start Standalone Repository Server
To enable your standalone Conary repository server to start when the system is booted, create an init script and system configuration file for running the Conary repository service.
First, create the system configuration file, which is used to set service variables. You must do this text editor of your choice executed with root user privileges:
[you@localhost ~]$ su - [root@localhost ~]# vim /etc/sysconfig/cnr
Insert the following example contents, which you do not need to modify if you've used the default values throughout this guide; otherwise, you'll need to use values which match your changes.
Example /etc/sysconfig/cnr:
#/etc/sysconfig/cnr CONARY_CFG=/home/you/cnr/conary.cnr CONARY_PATH=/usr/share/conary CONARY_SERVER=/usr/lib/python2.4/site-packages/conary/server CONARY_REPOSITORY=/tmp/testrepo CONARY_HOST=localhost CONARY_PORT=8000
Save and close the file, and create a new file without exiting your editor instance currently running with root privileges. Use the following contents for the file:
#/bin/bash # chkconfig: 345 99 99 # description: Starts the Conary repository # config: /etc/sysconfig/conary # Source function library. . /etc/init.d/functions . /etc/sysconfig/cnr export CONARY_PATH start() { echo -n $"Starting Conary Repository: " SERVER_OPTS="--config-file $CONARY_CFG --port $CONARY_PORT" daemon $CONARY_SERVER/server.py $SERVER_OPTS 2> /var/log/conary & RETVAL=$? [ $RETVAL = 0 ] && touch /var/lock/subsys/conary echo return $RETVAL } stop() { echo -n $"Shutting down Conary Repository: " killproc server.py RETVAL=$? [ $RETVAL = 0 ] && rm -f /var/lock/subsys/conary echo return $RETVAL } restart() { stop start } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status server.py ;; restart|reload) restart ;; **) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac exit $?
Save the file as /etc/init.d/cnr and exit the editor.
The initscript file will need to have executable bits set to execute properly:
># chmod +x /etc/init.d/cnr
Finally, run "chkconfig cnr on" to enable automatic starting of your repository on reboot. You may also test the functionality of the initscript with the following commands:
># service cnr start Starting Conary Repository: [OK] ># service cnr stop Shutting down Conary Repository: [OK]
