[BACK]Return to dgl-create-chroot CVS log [TXT][DIR] Up to [contributed] / dgamelaunch-openbsd

Annotation of dgamelaunch-openbsd/dgl-create-chroot, Revision 1.1

1.1     ! rubenllo    1: #!/bin/sh
        !             2:
        !             3: # Ideas and some parts from the original dgl-create-chroot (by joshk@triplehelix.org, modifications by jilles@stack.nl)
        !             4: # This one by paxed@alt.org
        !             5:
        !             6:
        !             7: #
        !             8: # configure dgl with --with-config-file=/path_to_chroot/etc/dgamelaunch.conf, if you want the conf file inside the chroot.
        !             9: #
        !            10:
        !            11:
        !            12: # Same as chroot_path in dgl config file
        !            13: CHROOT="/opt/nethack/nethack.alt.org/"
        !            14: # the user & group from dgamelaunch config file.
        !            15: USRGRP="games:games"
        !            16: # COMPRESS from include/config.h; the compression binary to copy. leave blank to skip.
        !            17: COMPRESSBIN="/bin/gzip"
        !            18: # nethack binary to copy into chroot (leave blank to skip)
        !            19: #NETHACKBIN="/home/paxed/hacking/coding/nethacksource/nethack-3.4.3-nao/nh343/nethack.343-nao"
        !            20: # fixed data to copy (leave blank to skip)
        !            21: #NH_PLAYGROUND_FIXED="/home/paxed/hacking/coding/nethacksource/nethack-3.4.3-nao/nh343/"
        !            22: # HACKDIR from include/config.h; aka nethack subdir inside chroot
        !            23: NHSUBDIR="/nh343/"
        !            24: # VAR_PLAYGROUND from include/unixconf.h
        !            25: NH_VAR_PLAYGROUND="/nh343/var/"
        !            26:
        !            27: # only define this if dgl was configured with --enable-sqlite
        !            28: SQLITE_DBFILE="/dgldir/dgamelaunch.db"
        !            29:
        !            30: # END OF CONFIG
        !            31: ##############################################################################
        !            32:
        !            33: errorexit()
        !            34: {
        !            35:     echo "Error: $@" >&2
        !            36:     exit 1
        !            37: }
        !            38:
        !            39: findlibs()
        !            40: {
        !            41:   for i in "$@"; do
        !            42:       if [ -z "`ldd "$i" | grep 'not a dynamic executable'`" ]; then
        !            43:          echo $(ldd "$i" | awk '{ print $3 }' | egrep -v ^'\(')
        !            44:          echo $(ldd "$i" | grep 'ld-linux' | awk '{ print $1 }')
        !            45:       fi
        !            46:   done
        !            47: }
        !            48:
        !            49: ##############################################################################
        !            50:
        !            51: if [ -z "$TERMDATA" ]; then
        !            52:     SEARCHTERMDATA="/etc/terminfo /usr/share/lib/terminfo /usr/share/terminfo /lib/terminfo"
        !            53:     for dir in $SEARCHTERMDATA; do
        !            54:        if [ -e "$dir/x/xterm" ]; then
        !            55:            TERMDATA="$TERMDATA $dir"
        !            56:        fi
        !            57:     done
        !            58:     if [ -z "$TERMDATA" ]; then
        !            59:        errorexit "Couldn't find terminfo definitions. Please specify in 'TERMDATA' variable."
        !            60:     fi
        !            61: fi
        !            62:
        !            63:
        !            64:
        !            65: # remove trailing slash, if any
        !            66: CHROOT="`echo ${CHROOT%/}`"
        !            67:
        !            68: set -e
        !            69: umask 022
        !            70:
        !            71: if [ -e "$CHROOT" ]; then
        !            72:    errorexit "Chroot $CHROOT already exists."
        !            73: fi
        !            74:
        !            75: CURDIR="`pwd`"
        !            76:
        !            77: if [ ! -e "$CURDIR/dgamelaunch" ]; then
        !            78:    errorexit "Cannot find dgamelaunch in $CURDIR"
        !            79: fi
        !            80:
        !            81: DGLFILE="dgamelaunch.`date +%Y%m%d`"
        !            82:
        !            83: echo "Setting up chroot in $CHROOT"
        !            84:
        !            85: LIBS="`findlibs dgamelaunch`"
        !            86:
        !            87: mkdir -p "$CHROOT" || errorexit "Cannot create chroot"
        !            88: cd "$CHROOT"
        !            89: mkdir dgldir etc lib mail usr bin
        !            90: chown "$USRGRP" dgldir mail
        !            91: cp "$CURDIR/dgamelaunch" "$DGLFILE"
        !            92: ln -s "$DGLFILE" dgamelaunch
        !            93:
        !            94: mkdir -p "$CHROOT/dgldir/inprogress-nh343"
        !            95: mkdir -p "$CHROOT/dgldir/userdata"
        !            96: chown "$USRGRP" "$CHROOT/dgldir/inprogress-nh343"
        !            97: chown "$USRGRP" "$CHROOT/dgldir/userdata"
        !            98:
        !            99:
        !           100: if [ -n "$SQLITE_DBFILE" ]; then
        !           101:   if [ "x`which sqlite3`" = "x" ]; then
        !           102:       errorexit "No sqlite3 found."
        !           103:   else
        !           104:       echo "Creating SQLite database at $SQLITE_DBFILE"
        !           105:       SQLITE_DBFILE="`echo ${SQLITE_DBFILE%/}`"
        !           106:       SQLITE_DBFILE="`echo ${SQLITE_DBFILE#/}`"
        !           107:       sqlite3 "$CHROOT/$SQLITE_DBFILE" "create table dglusers (id integer primary key, username text, email text, env text, password text, flags integer);"
        !           108:       chown "$USRGRP" "$CHROOT/$SQLITE_DBFILE"
        !           109:   fi
        !           110: fi
        !           111:
        !           112:
        !           113: if [ -n "$COMPRESSBIN" -a -e "`which $COMPRESSBIN`" ]; then
        !           114:   COMPRESSDIR="`dirname $COMPRESSBIN`"
        !           115:   COMPRESSDIR="`echo ${COMPRESSDIR%/}`"
        !           116:   COMPRESSDIR="`echo ${COMPRESSDIR#/}`"
        !           117:   echo "Copying $COMPRESSBIN to $COMPRESSDIR"
        !           118:   mkdir -p "$COMPRESSDIR"
        !           119:   cp "`which $COMPRESSBIN`" "$COMPRESSDIR/"
        !           120:   LIBS="$LIBS `findlibs $COMPRESSBIN`"
        !           121: fi
        !           122:
        !           123:
        !           124: mkdir -p dev
        !           125: cd dev
        !           126: mknod urandom c 1 9
        !           127: cd ..
        !           128:
        !           129:
        !           130: cd etc
        !           131: cp "$CURDIR/examples/dgamelaunch.conf" .
        !           132: echo "Edit $CHROOT/etc/dgamelaunch.conf to suit your needs."
        !           133: [ -f /etc/localtime ] && cp /etc/localtime .
        !           134: cd ..
        !           135:
        !           136:
        !           137: cd bin
        !           138: cp "$CURDIR/ee" .
        !           139: cp "$CURDIR/virus" .
        !           140: echo "Copied text editors 'ee' and 'virus' to chroot."
        !           141: cd ..
        !           142:
        !           143:
        !           144: cp "$CURDIR/examples/dgl_menu_main_anon.txt" .
        !           145: cp "$CURDIR/examples/dgl_menu_main_user.txt" .
        !           146: cp "$CURDIR/examples/dgl_menu_watchmenu_help.txt" .
        !           147: cp "$CURDIR/examples/dgl-banner" .
        !           148: cp "$CURDIR/dgl-default-rcfile" "dgl-default-rcfile.nh343"
        !           149: chmod go+r dgl_menu_main_anon.txt dgl_menu_main_user.txt dgl-banner dgl-default-rcfile.nh343
        !           150:
        !           151: NHSUBDIR="`echo ${NHSUBDIR%/}`"
        !           152: NHSUBDIR="`echo ${NHSUBDIR#/}`"
        !           153:
        !           154: mkdir "$CHROOT/$NHSUBDIR"
        !           155:
        !           156: if [ -n "$NETHACKBIN" -a ! -e "$NETHACKBIN" ]; then
        !           157:   errorexit "Cannot find NetHack binary $NETHACKBIN"
        !           158: fi
        !           159:
        !           160: if [ -n "$NETHACKBIN" -a -e "$NETHACKBIN" ]; then
        !           161:   echo "Copying $NETHACKBIN"
        !           162:   cd "$NHSUBDIR"
        !           163:   NHBINFILE="`basename $NETHACKBIN`.`date +%Y%m%d`"
        !           164:   cp "$NETHACKBIN" "$NHBINFILE"
        !           165:   ln -s "$NHBINFILE" nethack
        !           166:   LIBS="$LIBS `findlibs $NETHACKBIN`"
        !           167:   cd "$CHROOT"
        !           168: fi
        !           169:
        !           170:
        !           171: NH_PLAYGROUND_FIXED="`echo ${NH_PLAYGROUND_FIXED%/}`"
        !           172:
        !           173: if [ -n "$NH_PLAYGROUND_FIXED" -a -d "$NH_PLAYGROUND_FIXED" ]; then
        !           174:   echo "Copying NetHack playground stuff."
        !           175:   NHFILES="*.lev *.dat cmdhelp data dungeon help hh history license opthelp options oracles recover rumors wizhelp"
        !           176:   for fil in $NHFILES; do
        !           177:     cp $NH_PLAYGROUND_FIXED/$fil "$CHROOT/$NHSUBDIR/"
        !           178:   done
        !           179: fi
        !           180:
        !           181:
        !           182: NH_VAR_PLAYGROUND="`echo ${NH_VAR_PLAYGROUND%/}`"
        !           183: NH_VAR_PLAYGROUND="`echo ${NH_VAR_PLAYGROUND#/}`"
        !           184:
        !           185: echo "Creating NetHack variable dir stuff."
        !           186: if [ -n "$NH_VAR_PLAYGROUND" ]; then
        !           187:   mkdir -p "$CHROOT/$NH_VAR_PLAYGROUND"
        !           188:   chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND"
        !           189: fi
        !           190: mkdir -p "$CHROOT/$NH_VAR_PLAYGROUND/save"
        !           191: chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND/save"
        !           192: touch "$CHROOT/$NH_VAR_PLAYGROUND/logfile"
        !           193: touch "$CHROOT/$NH_VAR_PLAYGROUND/perm"
        !           194: touch "$CHROOT/$NH_VAR_PLAYGROUND/record"
        !           195: touch "$CHROOT/$NH_VAR_PLAYGROUND/xlogfile"
        !           196:
        !           197: chown -R "$USRGRP" "$CHROOT/$NHSUBDIR"
        !           198: chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND"
        !           199:
        !           200:
        !           201:
        !           202: # Curses junk
        !           203: if [ -n "$TERMDATA" ]; then
        !           204:     echo "Copying termdata files from $TERMDATA"
        !           205:     for termdat in $TERMDATA; do
        !           206:        mkdir -p "$CHROOT`dirname $termdat`"
        !           207:        if [ -d $termdat/. ]; then
        !           208:                cp -LR $termdat/. $CHROOT$termdat
        !           209:        else
        !           210:                cp $termdat $CHROOT`dirname $termdat`
        !           211:        fi
        !           212:     done
        !           213: fi
        !           214:
        !           215:
        !           216: LIBS=`for lib in $LIBS; do echo $lib; done | sort | uniq`
        !           217: echo "Copying libraries:" $LIBS
        !           218: for lib in $LIBS; do
        !           219:         mkdir -p "$CHROOT`dirname $lib`"
        !           220:         cp $lib "$CHROOT$lib"
        !           221: done
        !           222:
        !           223:
        !           224: echo "Finished."
        !           225:
        !           226:

CVSweb