#!/bin/sh # sandman setup script by Michael Shigorin, 2004 # special thanks to lioka and raorn # use, modify and distribute freely # v0.2: includes "isosetup-generic" fix for exportiso [ "$EUID" = "0" ] && { echo "You don't want this!" echo "Probably you want sandman-root-setup.sh" exit 1 } echo "This script will install sandman user settings as described here:" echo "http://www.linux-os.ru/Members/gvy/sandman-sisyphus-mini-howto/" echo -n "Press to continue, or better yet not to: " read echo "Proceeding." echo SSHC=~/.ssh/config SANDDIR=~/sandman USERS=users.classic WD="`pwd`" # basic user setup echo -n "* checking $SANDDIR... " [ -d "$SANDDIR" ] && { echo "seems you already have it, exiting" exit 1 } || { mkdir -p "$SANDDIR" && echo "created" || exit 1 cd "$SANDDIR" } # need to init ssh config? [ -f "$SSHC" ] || { echo "You'll need to access CVS via ssh;" echo "key-based access is highly recommended, see ssh-keygen(1)" echo "Creating basic $SSHC file..." mkdir -p `dirname "$SSHC"` || exit 1 echo "#IdentityFile ~/.ssh/id_dsa" >> "$SSHC" echo "## put the public key part in ~/.ssh/authorized_keys2" >> "$SSHC" } # localhost entry grep -q '^Host localhost$' "$SSHC" || { echo "Adding 'localhost' section to $SSHC ..." cat >> "$SSHC" << EOF Host localhost Hostname 127.0.0.1 Compression no EOF } # checkout echo "* checking out cvs..." echo "(you may need $USER@localhost password or ssh key passphrase" cvs -d :ext:localhost:/var/cvs co CVSROOT # add user echo "* creating cvs user..." [ -z "$USER" ] && { echo "\$USER is empty, you'll need to fix that first!" exit 1 } cd CVSROOT echo -n "$USER:" >> "$USERS" grep -q ^%packager ~/.rpmmacros && { rpm --eval %packager | sed 's,.*,"&",' >> "$USERS" } || { echo "You should add your '' info to $USERS," echo "or better yet, create proper ~/.rpmmacros file (see docs)" } # gen passwd echo "* setting sandman _user_ password... (can be simple)" htpasswd -c passwd.classic "$USER" || exit 1 echo "(you may want to add more users by hand)" # create global auth files echo "* creating global auth files..." touch users passwd cvs add users* passwd* for i in users* passwd*; do echo -e "$i\tNo $i file" >> checkoutlist done cvs commit -m 'init' users* passwd* checkoutlist cd .. # init release config echo "* initializing release configuration..." mkdir release && cd release for i in release installer macros modules; do cp /usr/share/doc/sandman-server-*/$i.sample $i done subst 's,^.* = modules/.*$,#&,' modules subst 's,^.*master.*2.*2.*$,#&,' modules subst 's,isosetup-generic,\$requires,' installer touch {release,installer,macros}.generic # release -> cvs echo "* importing release module into cvs..." cvs -d :ext:localhost:/var/cvs import -m 'init' release me start cd .. #mv release release.orig #cvs -d :ext:localhost:/var/cvs co release #ls -l release # packages -> cvs mkdir packages echo "* importing package module into cvs..." cd packages echo *.spec >> .cvsignore cvs -d :ext:localhost:/var/cvs import -m 'init' packages me start cd .. #mv packages packages.orig #cvs -d :ext:localhost:/var/cvs co packages #ls -l packages # sandman hooks echo "* creating sandman hooks..." cd CVSROOT cat >> commitinfo << EOF release/* /usr/bin/sandctl -hook cvs:commit packages/* /usr/bin/sandctl -hook cvs:commit EOF cvs commit -m 'init' commitinfo # finally echo "** done." echo echo "You should start sandman by running (as root):" echo " /sbin/service sandd start" echo echo "Then you should be able to test it with e.g.:" echo " sandcl -d $USER:@localhost:/classic querynames \*" echo "(it should spend some time populating /var/cache/sandman/classic" echo "and then return an empty list (that is, print nothing :)" # see also http://www.linux-os.ru/Members/gvy/sandman-tips-2/