#!/bin/bash # $Id: linux_vegastrike-0.4.3.sh,v 1.3 2004/10/01 12:14:29 dgar Exp dgar $ VERSION=vegastrike_0_4_3 DATAPATH=/usr/local/share/vegastrike VSBUILD="$PWD/$VERSION" die() { echo "$*"; exit 1; } warn() { echo -e "\033[1;33;7m $* \033[0m"; } announce() { echo -e "\033[1;37;7m $* \033[0m"; } oneliner () { while read; do echo -e "\033[1A\033[K$REPLY" done } checkout_nover() { cvs -z9 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/vegastrike \ checkout $* 2>&1 | oneliner return $? } checkout_ver() { cvs -z9 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/vegastrike \ checkout -r$VERSION $* 2>&1 | oneliner return $? } checkout() { if [ "$CVSHEAD" ]; then checkout_nover $* return $? else checkout_ver $* return $? fi } download() { announce "Downloading data..." checkout "vegastrike" || die "Error checking out 'vegastrike'" # if test \( -e data \) -a \( \! -e data4.x \) ; then # mv data data4.x # fi checkout -d data "data4.x" || die "Error checking out 'data4.x'" checkout_nover "vssetup" || warn "Warning: Setup program not downloaded." # ln -s data4.x data cd $VSBUILD/data checkout "music" || warn "Warning: Music not downloaded." announce "Downloading data Done" announce "Creating installer... " cat << EOF > ./vsinstall || warn "Warning: Error creating vsinstall" #!/bin/sh # Data Directory: DATAPATH="$DATAPATH" CURPWD=\$PWD mkdir -p \$HOME/.vegastrike cd \$HOME/.vegastrike if [ -e save.4.x.txt ] ; then touch save.4.x.txt; else echo "default"> save.4.x.txt ; fi cp \$DATAPATH/data/setup.config . cp \$DATAPATH/data/.vegastrike/*.m3u . cp \$DATAPATH/data/vegastrike.config . /usr/local/bin/vssetup echo "If you wish to have your own music edit ~/.vegastrike/*.m3u" echo "Each playlist represents a place or situation in Vega Strike" cd \$CURPWD EOF chmod 755 ./vsinstall cd $VSBUILD announce "Creating installer Done" } configure () { cd $VSBUILD/vegastrike announce "Configuring vegastrike..." test -e Makefile && make distclean aclocal autoconf autoheader automake -a || automake -a --add-missing ./configure --enable-release|| die "Error running ./configure" cd $VSBUILD announce "Configuring vegastrike Done" } compile () { cd $VSBUILD/vegastrike announce "Compiling vegastrike..." make || die "Error running 'make'" cd $VSBUILD/vssetup/src rm -f c/*.o include/*.o bin/setup perl ./build cd $VSBUILD announce "Compiling vegastrike Done" } install () { cd $VSBUILD/data mkdir -p $HOME/.vegastrike echo "default" > ~/.vegastrike/save.4.x.txt cp $VSBUILD/vssetup/src/bin/setup ./vssetup cp $VSBUILD/vegastrike/src/vegastrike . cp $VSBUILD/vegastrike/src/networking/soundserver . cp $VSBUILD/vegastrike/launcher/vslauncher . cat << EOF > root_install.sh install -m 755 ./vsinstall /usr/local/bin/vsinstall install -m 755 ./vssetup /usr/local/bin/vssetup install -m 755 ./vegastrike /usr/local/bin/vegastrike install -m 755 ./vslauncher /usr/local/bin/vslauncher mkdir -p /usr/local/man/man1 install -m 644 documentation/vegastrike.1 /usr/local/man/man1/vegastrike.1 install -m 644 documentation/vslauncher.1 /usr/local/man/man1/vslauncher.1 install -m 644 documentation/vsinstall.1 /usr/local/man/man1/vsinstall.1 install -m 644 documentation/vssetup.1 /usr/local/man/man1/vssetup.1 cd $VSBUILD mkdir -p "$DATAPATH" cp -ar data "$DATAPATH" EOF announce "Installing vegastrike (requires root privileges)..." su -c "sh -x root_install.sh" || warn "Error running root_install.sh as root" announce "Installing vegastrike Done" cd $VSBUILD echo "" echo "run vsinstall to setup your account" echo "then run vslauncher to start Vega Strike" } disphelp () { cat << EOF Usage: $0 [-p datapath] [command [command...] ] For a complete install, use no arguments datapath is the directory to install the data to. note that vegastrike may not find data unless in a standard place. default is /usr/local/share/vegastrike command is one of: download - Redownloads vegastrike reconfigure - Configures vegastrike source compile - Compiles a configured vegastrike source install - Installs vegastrike from compiled source and data If a configure error occurs, run '$0 reconfigure compile install' If a compile error unrelated to configure occurs and has been fixed, run '$0 compile install' If a 'cvs update' error happens, run '$0' If an installation error happens only run EOF } mkdir -p $VSBUILD 2> /dev/null cd $VSBUILD echo -e '\033[32;7mWelcome to Vega Strike Setup for CVS Version '"$VERSION"'\033[0m' ispath=0 if [ $# -ge 1 ]; then for arg in $*; do if [ $ispath = 1 ]; then ispath=0 DATAPATH=$arg else case "$arg" in -p) ispath=$1 ;; *download*) download || exit 1 ;; *configure*) configure || exit 1 ;; *compile*) compile || exit 1 ;; *install*) install || die "Install failed. Type '$0 install' to install again." ;; *) warn "Unknown command \"$arg\"" disphelp exit 0 ;; esac fi done else download && configure && compile && install fi