Freeside:1.7:Documentation:MirroringRPMRepoYaST:Long

From Freeside
Revision as of 08:37, 15 April 2009 by Rsiddall (talk | contribs) (Initial Installation of the Self-Service Interface: Factoring out common steps for people installing both self-service and billing server on the same machine)

Jump to: navigation, search

Mirroring the Freeside RPM Repository with YaST2

Introduction

This page explains how to mirror the Freeside RPM repository for SuSE systems, including SLES, using wget; and how to use your mirror using YaST2 and zypper. There's more discussion on the main page on mirroring the RPM repository.

The complete repository tree is currently about 3GB in size and growing. We strongly recommend that you do not mirror the whole repository. Mirror only the branch(es) for the SuSE version you use.

Freeside Repository Structure

The current repository structure is:

	http://freeside.biz/~rsiddall - Base URL containing files used by yum
		repo/ - Base of RPM repositories
			centos/ # other distributions
			sles/
				10/
					freeside-1.7/
						stable/
							i386/
							x86_64/
						prerelease/
							i386/
							x86_64/
						testing/
							i386/
							x86_64/
							self-service/
								i386/
								x86_64/
					freeside-1.9/
						stable/
							i386/
							x86_64/
						prerelease/
							i386/
							x86_64/
						testing/
							i386/
							x86_64/
							self-service/
								i386/
								x86_64/

The "testing" branches contain "daily" CVS builds (build-on-CVS-change) and may lack prerequisite Perl modules that have recently begun to be used.

We currently build only for i386 and x86_64 architectures.

Due to the way SuSE's libzypp treats RPM repositories, the self-service files are kept in a different branch from the billing server RPMs. This is not necessary on CentOS due to yum's better handling of RPMs.

Proxy Servers

The following assumes you are not accessing the internet through a proxy server, or that you are using a transparent proxy server that requires no special configuration for client programs. If this is not the case, you may need to add command line switches to route internet accesses through your proxy server and to authenticate yourself to the server.

Rate Limiting

We would greatly appreciate it if you would include --limit-rate=100k in the wget command line to limit the load on the Freeside repository server.

Instructions

With the exception of a couple of steps to create a folder and make it available via your web server, the steps for initial setup and refreshing the repository are identical. You could put these steps in a shell script.

Initial Setup

The Freeside RPM repository is just a web server containing the RPMs and some metadata files. To mirror this, you download the files into a folder and then make that folder available to your local client machines via a web server.

To set up the mirror initially:

  • Decide which distributions, branches, and architectures you are going to mirror, for example sles/10/freeside-1.7/testing/i386.
  • Create a folder somewhere on the machine that will act as your repository server (under /srv/www, for example):
mkdir /srv/www/freeside-repo
  • Copy down the repository from the Freeside web server:
cd /srv/www/freeside-repo
wget --mirror --no-parent --no-host-directories --cut-dirs=1 http://freeside.biz/~rsiddall/repo/sles/10/freeside-1.7/testing/i386/

The trailing slash after the i386 prevents wget from downloading all repositories at the same level as the i386 folder.

  • Copy down the corresponding self-service server files if you want them:
wget --mirror --no-parent --no-host-directories --cut-dirs=1 http://freeside.biz/~rsiddall/repo/sles/10/freeside-1.7/testing/self-service/i386/
  • The Freeside web server auto-generated index.html files. Remove them from the mirror:
find /srv/www/freeside-repo -name 'index.html*' -print -exec /bin/rm {} \;
  • Make the folder available via the web server. For Apache, put a configuration snippet in a file (freeside-repo.conf) in /etc/apache2/conf.d:
Alias /freeside-repo /srv/www/freeside-repo
<Directory /srv/www/freeside-repo>
Options +Indexes
Allow From All
Order Deny,Allow
</Directory>
  • Restart or reload your web server:
service apache2 reload
  • Test the repository:
    • Try doing an installation or update

Refreshing Your Mirror

To refresh the mirror, just repeat the steps to copy down the files:

cd /srv/www/freeside-repo
wget --mirror --no-parent --no-host-directories --cut-dirs=1 http://freeside.biz/~rsiddall/repo/sles/10/freeside-1.7/testing/i386/
wget --mirror --no-parent --no-host-directories --cut-dirs=1 http://freeside.biz/~rsiddall/repo/sles/10/freeside-1.7/testing/self-service/i386/

Remove the index.html files generated by the web server from the mirror:

find /srv/www/freeside-repo -name 'index.html*' -print -exec /bin/rm {} \;

The above commands can be put in a shell script and executed periodically via cron.

Switching Existing Clients to Your Repository

If you've previously installed Freeside (billing server and/or self-service) on a client machine and want to switch it to use your local repository, change the installation sources via zypper or YaST2:

zypper service-list # Get number of the source using freeside.biz (or wavetail.420.am), say '2'
zypper service-delete 2
zypper service-add http://server.domain.tld/freeside-repo/repo/sles/10/freeside-1.7/testing/i386
zypper service-list # Make sure it's correct

There's no harm to adding the repository for the self-service files as another installation source if it's not already there:

zypper service-add http://server.domain.tld/freeside-repo/repo/sles/10/freeside-1.7/testing/self-service/i386

Using Your Mirror

Follow the instructions for using the Freeside Internet Services RPM repository (SuSE), but substitute the URL of your repository. These instructions are summarized below.

Initial Installation of Freeside

# Add the folder or web server containing SuSE to your installation sources
yast2 inst_source
# Enable SSL and Perl scripting for the HTTP server
yast2 --install apache2-mod_perl
yast2 http-server modules enable=ssl,perl
# Configure apache for SSL
cd /etc/apache2/vhosts.d
cp -p vhost-ssl.template freeside-ssl.conf
perl -pi -e 's/#ServerName www.example.com/ServerName `hostname`/g;' freeside-ssl.conf # Uncomment and correct ServerName
perl -pi -e 's/#ServerAdmin root\@example.com/you\@domain.tld/g' freeside-ssl.conf # Uncomment and correct ServerAdmin, and any SSL file locations
cd
# Copy server cert (csr, crt, and key) to Apache SSL folders
for ext in csr crt key; do cp -p server.${ext} /etc/apache2/ssl.${ext}; done
# Install zypper
yast2 --install zypper
# Update the system
zypper -n update
# Install PostgreSQL (might need a client if database server is not on same box)
zypper -n install postgresql-server
# Add the Freeside repository as an installation source
zypper service-add http://server.domain.tld/freeside-repo/repo/sles/10/freeside-1.7/testing/i386
# Install Freeside itself (specify the Business::OnlinePayment module you use)
zypper -n install freeside-postgresql freeside freeside-mason perl-Business-OnlinePayment-AuthorizeNet

and then finish the installation as normal, starting PostgreSQL and creating a Freeside user and database; then running freeside-setup, freeside-adduser, and restarting the web server.

Initial Installation of the Self-Service Interface

The first steps are almost the same as for the Freeside billing server, except that you don't have to enable mod_perl:

# Add the folder or web server containing SuSE to your installation sources
yast2 inst_source
# Enable SSL for the HTTP server
yast2 http-server modules enable=ssl
# Configure apache for SSL
cd /etc/apache2/vhosts.d
cp -p vhost-ssl.template freeside-ssl.conf
perl -pi -e 's/#ServerName www.example.com/ServerName `hostname`/g;' freeside-ssl.conf # Uncomment and correct ServerName
perl -pi -e 's/#ServerAdmin root\@example.com/you\@domain.tld/g' freeside-ssl.conf # Uncomment and correct ServerAdmin, and any SSL file locations
cd
# Copy server cert (csr, crt, and key) to Apache SSL folders
for ext in csr crt key; do cp -p server.${ext} /etc/apache2/ssl.${ext}; done
# Install zypper
yast2 --install zypper
# Update the system
zypper -n update

To install the self-service interface you use a different repository on your mirror and install the appropriate set of RPMs:

# Add the self-service repository to zypper's installation sources
zypper service-add http://server.domain.tld/freeside-repo/repo/sles/10/freeside-1.7/testing/self-service i386
# Install Freeside Self-Service
zypper -n install freeside-selfservice

and then finish the self-service installation as normal:

  • Set up key-based SSH access and check the freeside user on the billing server can SSH into the self-service machine (even if it's localhost).
  • Add the self-service machine to /etc/defaults/freeside or /etc/sysconfig/freeside on the billing server.
  • Start the freeside service on the billing server and check the logs to make sure it's working.
  • Check you can log in via the self-service interface.

On older SLES/SuSE systems you may need to create a home directory for the freeside user and also create a freeside group:

mkdir /home/freeside
chown freeside.users /home/freeside
groupadd freeside

Updating Your Freeside Installation

zypper -t package update