Changeset 997 for locker/bin


Ignore:
Timestamp:
Mar 2, 2009, 2:01:58 PM (15 years ago)
Author:
andersk
Message:
Automatic numbering in scripts-start.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • locker/bin/scripts-start

    r703 r997  
    11#!/bin/sh
     2
     3choices () {
     4    echo 'mediawiki MediaWiki'
     5    echo 'wordpress WordPress'
     6    echo 'joomla Joomla'
     7    echo 'e107 e107'
     8    echo 'gallery2 Gallery2'
     9    echo 'phpbb phpBB'
     10    echo 'advancedbook Advanced Guest Book'
     11    echo 'phpical PHP iCalendar'
     12    echo 'trac Trac'
     13    echo 'turbogears TurboGears'
     14}
     15
     16nchoices=`choices | wc -l`
    217
    318echo
    419echo "What piece of software would you like to install?"
    520echo
    6 echo "1. MediaWiki"
    7 echo "2. WordPress"
    8 echo "3. Joomla"
    9 echo "4. e107"
    10 echo "5. Gallery2"
    11 echo "6. phpBB"
    12 echo "7. Advanced Guest Book"
    13 echo "8. PHP iCalendar"
    14 echo "9. Trac"
     21choices | sed 's/^[^ ]* //' | cat -n
    1522echo
    16 printf "Please enter a number 1-9: "
     23printf "Please enter a number 1-%d: " "$nchoices"
    1724read num
    1825echo
    1926
    2027attach scripts 2>/dev/null
    21 if [ "$num" = 1 ]; then
    22   . "/mit/scripts/bin$scriptsdev/scripts-mediawiki"
    23 elif [ "$num" = 2 ]; then
    24   . "/mit/scripts/bin$scriptsdev/scripts-wordpress"
    25 elif [ "$num" = 3 ]; then
    26   . "/mit/scripts/bin$scriptsdev/scripts-joomla"
    27 elif [ "$num" = 4 ]; then
    28   . "/mit/scripts/bin$scriptsdev/scripts-e107"
    29 elif [ "$num" = 5 ]; then
    30   . "/mit/scripts/bin$scriptsdev/scripts-gallery2"
    31 elif [ "$num" = 6 ]; then
    32   . "/mit/scripts/bin$scriptsdev/scripts-phpbb"
    33 elif [ "$num" = 7 ]; then
    34   . "/mit/scripts/bin$scriptsdev/scripts-advancedbook"
    35 elif [ "$num" = 8 ]; then
    36   . "/mit/scripts/bin$scriptsdev/scripts-phpical"
    37 elif [ "$num" = 9 ]; then
    38   . "/mit/scripts/bin$scriptsdev/scripts-trac"
     28choice=`choices | sed -n "$num { s/ .*$//; p; }"`
     29if [ -n "$choice" ]; then
     30  . "/mit/scripts/bin$scriptsdev/scripts-$choice"
    3931else
    4032  echo "ERROR:"
    41   echo "You must enter a number 1 through 9."
     33  echo "You must enter a number 1 through $nchoices."
    4234  exit 1
    4335fi
Note: See TracChangeset for help on using the changeset viewer.