#!/bin/bash # # openmamba new repository creation script # Copyright (c) 2007-2008 by Silvan Calarco # . /etc/sysconfig/openmamba-central CONFMODE=$1 REPNAME=$2 REPDIR=$local_ftp/$REPNAME DISTROMATICDIR=$local_ftp/distromatic/$REPNAME WEBDAV_DIR=/var/www/davdb [ "$CONFMODE" = "frontend" -o "$CONFMODE" = "backend" -a "$REPNAME" ] || { echo "openmamba new repository creation tool" echo "Copyright (c) 2007-2008 by Silvan Calarco" echo echo "Usage:" echo "$0 {backend|frontend} name [-t type]" echo echo " backend this is the backend server" echo " frontend this is the frontend server" echo " name repository name (e.g. devel-silvan)" echo " type the type of repository, default is 'people', choices are:" echo " people group" echo exit 1 } echo "openmamba new repository creation tool" echo "Copyright (c) 2007-2008 by Silvan Calarco" echo if [ "$CONFMODE" = "backend" ]; then for r in ${local_reps[*]}; do [ "$r" = "$REPNAME" ] && REPTYPE=local done for r in ${remote_reps[*]}; do [ "$r" = "$REPNAME" ] && REPTYPE=remote done [ "$REPTYPE" ] || { echo "Error: please add repository to /etc/sysconfig/openmamba-central first; aborting." exit 1 } [ -e $REPDIR ] && { echo "Error: a file or directory called $REPDIR already exits; aborting." exit 1 } [ -e $DISTROMATICDIR ] && { echo "Error: a file or directory called $DISTROMATICDIR already exits; aborting." exit 1 } mkdir -p $REPDIR/{base,SRPMS.base,home,old} || { echo "Error: cannot create directories in $REPDIR; aborting." exit 1 } mkdir -p $REPDIR/nonflat/RPMS ln -s ../SRPMS.base $REPDIR/nonflat/SRPMS for a in ${archs[*]}; do ln -s ../../RPMS.$a $REPDIR/nonflat/RPMS/$a mkdir -p $REPDIR/RPMS.$a || { echo "Error: cannot create directories in $REPDIR; aborting." exit 1 } done mkdir -p $DISTROMATICDIR || { echo "Error: cannot create directory $DISTROMATICDIR; aborting." exit 1 } if [ "$REPTYPE" = "local" ]; then useradd ftp$REPNAME -d $REPDIR -s /bin/true || { echo "Error: cannot create ftp$REPNAME user; aborting." exit 1 } chown -R ftp$REPNAME.ftp $REPDIR/{SRPMS.base,RPMS.*,nonflat,old} fi cat > $REPDIR/.htaccess << _EOF AuthType Basic AuthUserFile /var/www/davdb/$REPUSER AuthName "Authentication required" _EOF echo "Repository has been created on the backend, now you need to do the following things:" echo "+ configure distromatic for the $REPNAME repository" echo "+ launch 'openmamba-newrep frontend' on the frontend server" echo "+ add HTML code for the repository publication of the website" echo elif [ "$CONFMODE" = "frontend" ]; then REPUSER="${REPNAME/*-/}" TEMPLATEDIR=$local_ftp/template [ "`getent passwd $REPUSER`" ] && { echo "Error: user $REPUSER already exits; aborting." exit 1 } [ -e $REPDIR ] && { echo "Error: a file or directory called $REPDIR already exits; aborting." exit 1 } useradd $REPUSER -d $REPDIR -s /bin/true || { echo "Error: cannot create ftp$REPNAME user; aborting." exit 1 } REPUSER_PASSWD=`mkpasswd -s 0 -l 9` echo "$REPUSER_PASSWD" | passwd $REPUSER --stdin mkdir -p $REPDIR/{base,SRPMS.base,home,old} || { echo "Error: cannot create directories in $REPDIR; aborting." exit 1 } cp -a $TEMPLATEDIR/home/* $REPDIR/home/ mkdir -p $REPDIR/nonflat/RPMS ln -s ../SRPMS.base $REPDIR/nonflat/SRPMS for a in ${archs[*]}; do ln -s ../../RPMS.$a $REPDIR/nonflat/RPMS/$a mkdir -p $REPDIR/RPMS.$a || { echo "Error: cannot create directories in $REPDIR; aborting." exit 1 } done chown -R $REPUSER.nobody $REPDIR/{SRPMS.base,RPMS.*,nonflat,old} chmod -R 775 $REPDIR/{SRPMS.base,RPMS.*,nonflat,old} ln -s $REPDIR/home/ /var/www/www.openmamba.org/people/$REPUSER htpasswd -nb $REPUSER $REPUSER_PASSWD > $WEBDAV_DIR/$REPUSER echo "Repository has been created on the frontend" echo "* ftp address: ftpaccounts.openmamba.org" echo "+ ftp user: $REPUSER" echo "+ ftp password: $REPUSER_PASSWD" echo echo "You may configure autospec by copying the following lines at the" echo "bottom of file .autospec in your home directory:" echo echo "#==================================================#" echo "# devel-$REPUSER repository #" echo "#==================================================#" echo "ftp_rw_server[x]=\"ftp://ftpaccounts.openmamba.org\"" echo "ftp_rw_port[x]=" echo "ftp_rw_passive_mode[x]=on" echo "ftp_rw_user[x]=$REPUSER" echo "ftp_rw_passwd[x]=\"$REPUSER_PASSWD\"" echo "ftp_rw_rpms_dir[x]=\"/RPMS.@arch@\"" echo "ftp_rw_srpms_dir[x]=\"/SRPMS.base\"" echo "arch_list[x]=\"${archs[*]}\"" echo "arch_noarch_upload[x]=\"${arch_list[8]}\"" echo "ftpdir_rw_old[x]=\"\"" echo "ftpurl_ro_rpms[x]=\"ftp://ftpaccounts.openmamba.org/pub/openmamba/devel-$REPUSER/RPMS.@arch@\"" echo "ftpurl_ro_srpms[x]=\"ftp://ftpaccounts.openmamba.org/pub/openmamba/devel-$REPUSER/SRPMS.base\"" echo "#==================================================#" echo echo "Warning: you have to replace the occurencies of 'x' within brackets '[x]'" echo " with the first free server number in your current autospec configuration." echo fi exit 0