Index: locker/deploy/bin/mediawiki-star
===================================================================
--- locker/deploy/bin/mediawiki-star	(revision 1103)
+++ locker/deploy/bin/mediawiki-star	(revision 1103)
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+use strict;
+use lib '/mit/scripts/deploy/bin';
+use onserver_star;
+
+setup();
+
+`cp skins/common/images/mediawiki.png skins/common/images/wiki.png`;
+`patch -s -p1 < /mit/scripts/deploy/mediawiki.patch`;
+
+print "\nPlease decide upon a title for your wiki and enter it below.\n";
+print "Desired title: ";
+my $title=<STDIN>;
+chomp($title);
+
+my $html = fetch_uri(
+    'config/index.php',
+    {},
+    {Sitename => $title,
+     EmergencyContact => $email,
+     LanguageCode => 'en',
+     DBserver => $sqlhost,
+     DBname => $sqldb,
+     DBuser => $sqluser,
+     DBpassword => $sqlpass,
+     DBpassword2 => $sqlpass,
+     defaultEmail => $email,
+     SysopName => $admin_username,
+     SysopPass => $admin_password,
+     SysopPass2 => $admin_password});
+unless ($html =~ /Installation successful/) {
+    print STDERR "ERROR: Automatic MediaWiki configuration failed.  You will need to configure\nyour MediaWiki manually, or email scripts\@mit.edu for help.\n";
+    exit;
+}
+`cp config/LocalSettings.php .`;
Index: locker/deploy/bin/onathena-star
===================================================================
--- locker/deploy/bin/onathena-star	(revision 1103)
+++ locker/deploy/bin/onathena-star	(revision 1103)
@@ -0,0 +1,239 @@
+#!/bin/sh
+
+checkfailed() {
+  if [ -f "$lroot/web_scripts/$addrend/.failed" ]; then
+    rm -f "$lroot/web_scripts/$addrend/.failed"
+    exit 1
+  fi
+}
+
+die() {
+  echo "== INSTALLATION FAILED =="
+  echo "Sorry, the installation failed:"
+  echo "$@"
+  echo "Please contact scripts@mit.edu and provide a copy of the output of this installer."
+  exit 1
+}
+  
+
+sshrun() {
+  athrun scripts scripts-ssh "$lname" "/mit/scripts/$@" 2>/dev/null
+}
+
+vsshrun() {
+  athrun scripts scripts-ssh "$lname" "/mit/scripts/$@"
+}
+
+checksqlpass() {
+    errors=`sshrun "sql/bin$scriptsdev/test-password"`
+    if [ "$errors" != "" ]; then
+        if [ "$1" -eq 1 ]; then
+          rm -f "$lroot/.sql/my.cnf"
+        fi
+        echo
+        echo "ERROR:"
+        printf "$2"
+        exit
+    fi
+}
+
+override=1
+if [ "$override" = "" ]; then
+echo "The scripts.mit.edu automatic installers are currently unavailable."
+echo "We hope to make them available again soon."
+echo "If you would like us to notify you as soon as they are available again,"
+echo "let us know by sending us an e-mail at scripts@mit.edu"
+exit 
+fi
+
+echo 
+echo "== Welcome to the scripts.mit.edu installer for $sname =="
+echo
+
+echo "For documentation, including a link to the Athena rules of use,"
+echo "see <http://scripts.mit.edu/start>."
+echo
+echo "Please report problems with this installer to scripts@mit.edu."
+echo
+echo "Are you performing this install for:"
+echo "1. Your personal Athena account"
+echo "2. A locker that you control (a club, a course, etc)"
+echo "If you do not understand this question, you should answer '1'."
+printf "Please enter either '1' or '2' (without quotes): "
+read whofor
+if [ "$whofor" = 1 ]; then
+    lname=$USER
+    lroot=$HOME 
+elif [ "$whofor" = 2 ]; then
+    echo
+    echo "OK.  $sname will be installed into a locker of your choice that"
+    echo "you control.  Please enter the name of the selected locker below."
+    echo "(For the locker /mit/lsc -- which has a full path of"
+    echo "/afs/athena.mit.edu/activity/l/lsc -- you would simply enter lsc)."
+    printf "Locker name: "
+    read lname
+    lroot="/mit/$lname" 
+else
+    echo
+    echo "ERROR:"
+    echo "You must select either '1' or '2'."
+    exit 1
+fi
+
+echo
+echo Checking the status of your scripts.mit.edu account...
+
+attach scripts 2>/dev/null
+. "/mit/scripts/bin$scriptsdev/signup-web"
+
+echo
+echo "Your new copy of $sname will appear on the web at a URL"
+echo "that starts with http://$lname.scripts.mit.edu/"
+echo "Please decide upon a complete URL and enter it below."
+echo "You must enter one or more characters after /"
+echo "The completed address must only contain a-z, 0-9, and /."
+printf "Desired address: http://$lname.scripts.mit.edu/"
+read addrend
+
+addrend=`perl -0e 'print $ARGV[0] =~ /^([\w\/-]*[\w-])\/*$/' -- "$addrend"`
+if [ "$addrend" = "" ]; then
+	echo
+	echo "ERROR:"
+	echo "You must enter one or more characters after /"
+	echo "The completed address must only contain a-z, 0-9, and /."
+	exit 1
+fi
+
+if [ -d "$lroot/web_scripts/$addrend" ]; then
+    echo
+    echo "ERROR:"
+    echo "You already have a directory corresponding to that web address."
+    echo "Please remove that directory, choose a different address, or"
+    echo "contact scripts@mit.edu for assistance."
+    exit 1
+fi
+
+if [ "$requires_sql" = "" ]; then
+  requires_sql=1
+fi
+
+if [ ! -f "$lroot/.my.cnf" ]; then
+  mkdir "$lroot/.sql" 2>/dev/null
+  fs sa "$lroot/.sql" daemon.scripts write
+  fs sa "$lroot/.sql" daemon.sql write
+  ln -nfs "$lroot/.sql/my.cnf" "$lroot/.my.cnf" 2>/dev/null
+fi
+
+fs sa "$lroot/.sql" system:anyuser none
+fs sa "$lroot/.sql" system:authuser none
+
+if [ "$requires_sql" -eq 1 ]; then
+  sqlinfo=`sshrun "sql/bin$scriptsdev/get-password"`
+  if [ "$sqlinfo" = "" ]; then
+      echo 
+      echo "You already have a MySQL account but you do not have a .my.cnf file."
+      echo "If you do not remember your MySQL account password, you can change it"
+      echo "at http://sql.mit.edu using MIT certificates."
+      printf "Please type your MySQL password and press [enter]: "
+      stty -echo
+      read sqlpass
+      stty echo
+      echo
+      sqlhost="sql.mit.edu"
+      sqluser=$lname
+      . "/mit/scripts/sql/bin$scriptsdev/save-password"
+      checksqlpass 1 'The MySQL password that you typed appears to be incorrect.\n'
+      echo
+      echo "OK.  Continuing with the install..."
+  else
+      checksqlpass 0 'The MySQL login information in your .my.cnf file\nappears to be incorrect.\n'
+  fi
+fi
+
+if [ "$prompt_username" = "" ]; then
+  admin_username="admin"
+  prompt_username=0
+fi
+if [ "$prompt_password" = "" ]; then
+  prompt_password=1
+fi
+
+if [ "$prompt_username" -eq 1 ]; then
+    echo
+    echo "You will be able to log in to $sname using a username of your choice."
+    echo "Please decide upon a username and enter it below."
+    echo "Your username must contain only alphanumeric characters (a-z, 0-9)."
+    printf "Desired username: "
+    read admin_username
+    admin_username=`perl -0e 'print $ARGV[0] =~ /^([[:alnum:]]+)$/' -- "$admin_username"`
+    if [ "$admin_username" = "" ]; then
+        echo
+        echo ERROR:
+        echo "Your username must contain only alphanumeric characters (a-z, 0-9)."
+        echo "You will need to run the installer again and choose a different username."
+        exit 1
+    fi
+fi
+
+origdir=`pwd`
+mkdir -p "$lroot/web_scripts_tmp"
+cd "$lroot/web_scripts_tmp"
+fs sa . system:anyuser none
+fs sa . system:authuser none
+fs sa . daemon.scripts write
+fs sa . system:scripts-security-upd write
+echo "This directory is necessary to store login sessions and other transient files for auto-installed packages from scripts.mit.edu." > DO_NOT_DELETE.txt
+mkdir -p "$lroot/web_scripts/$addrend"
+cd "$lroot/web_scripts/$addrend"
+fs sa . system:anyuser none
+fs sa . system:authuser none
+fs sa . daemon.scripts write
+fs sa . system:scripts-security-upd write
+
+if [ "$prompt_password" -eq 1 ]; then
+    stty -echo
+    sshrun "deploy$scriptsdev/bin/prompt-password" "$sname" "$deploy" "$addrend" "$admin_username"
+    stty echo
+fi
+
+echo
+echo "Unpacking $sname... (this step might take several minutes)"
+
+if [ "$create_dir" = "" ]; then
+  create_dir=0
+fi
+
+if [ "$create_dir" -eq 1 ]; then
+  mkdir -p "$lroot/scripts-$deploy"
+  fs sa "$lroot/scripts-$deploy" system:anyuser none
+  fs sa "$lroot/scripts-$deploy" system:authuser none
+  fs sa "$lroot/scripts-$deploy" daemon.scripts write
+  fs sa "$lroot/scripts-$deploy" system:scripts-security-upd write
+fi
+
+athrun scripts gtar zxf "/mit/scripts/deploy$scriptsdev/$deploy.tar.gz"
+files=`athrun scripts gfind . -mindepth 1 -maxdepth 1 | grep -v .admin`
+numfiles=`echo "$files" | wc -l`
+if [ "$numfiles" -eq 1 ]; then
+    athrun scripts gfind . -mindepth 2 -maxdepth 2 | xargs -i mv \{} .
+    rmdir "$files"
+fi
+if [ -f "/mit/scripts/deploy$scriptsdev/php.ini/$deploy" ]; then
+	nodot=`echo "$lname" | sed "/\./s///"`;
+	sed -e "/SCRIPTS_USER/ s//$lname/" -e "/SCRIPTS_NODOT/ s//$nodot/" "/mit/scripts/deploy$scriptsdev/php.ini/$deploy" > php.ini
+	athrun scripts gfind . -mindepth 1 -type d -exec sh -c 'ln -sf "`echo "$1" | sed '\''s,[^/],,g; s,/,../,g'\''`php.ini" "$1/"' -- {} \;
+fi
+cd "$origdir"
+
+vsshrun "deploy$scriptsdev/bin/$deploy" "$sname" "$deploy" "$addrend" "$admin_username" "$requires_sql" "$scriptsdev" "$USER" || die "Unknown failure during configuration"
+rm -f "$lroot/web_scripts/$addrend/.scripts-tmp"
+checkfailed
+
+echo
+echo "== Installation complete! =="
+echo "You should now be able to access your new copy of $sname at"
+echo "http://$lname.scripts.mit.edu/$addrend/"
+echo "(You can replace the http with https if you want to use encryption)"
+echo "If you have trouble accessing it, feel free to contact"
+echo "the scripts.mit.edu team by e-mailing scripts@mit.edu"
+exit 0
Index: locker/deploy/bin/onserver_star.pm
===================================================================
--- locker/deploy/bin/onserver_star.pm	(revision 1103)
+++ locker/deploy/bin/onserver_star.pm	(revision 1103)
@@ -0,0 +1,142 @@
+package onserver_star;
+use strict;
+use Exporter;
+use Sys::Hostname;
+use File::Spec::Functions;
+use File::Basename;
+use Socket;
+use Cwd qw(abs_path);
+use POSIX qw(strftime);
+use LWP::UserAgent;
+use URI;
+our @ISA = qw(Exporter);
+our @EXPORT = qw(setup totmp fetch_uri print_login_info press_enter $server $tmp $USER $HOME $sname $deploy $addrend $base_uri $ua $admin_username $requires_sql $addrlast $sqlhost $sqluser $sqlpass $sqldb $admin_password $scriptsdev $human $email);
+
+our $server = "scripts.mit.edu";
+
+our ($tmp, $USER, $HOME, $sname, $deploy, $addrend, $base_uri, $ua, $admin_username, $requires_sql, $addrlast, $sqlhost, $sqluser, $sqlpass, $sqldb, $admin_password, $scriptsdev, $human, $email);
+
+$tmp = ".scripts-tmp";
+sub totmp {
+  open(FILE, ">$tmp");
+  print FILE $_[0];
+  close(FILE);
+}
+
+$ua = LWP::UserAgent->new;
+push @{$ua->requests_redirectable}, 'POST';
+
+sub fetch_uri {
+    my ($uri, $get, $post) = @_;
+    my $u = URI->new($uri);
+    my $req;
+    if (defined $post) {
+	$u->query_form($post);
+	my $content = $u->query;
+	$u->query_form($get);
+	$req = HTTP::Request->new(POST => $u->abs($base_uri));
+	$req->content_type('application/x-www-form-urlencoded');
+	$req->content($content);
+    } else {
+	$u->query_form($get) if (defined $get);
+	$req = HTTP::Request->new(GET => $u->abs($base_uri));
+    }
+    my $res = $ua->request($req);
+    if ($res->is_success) {
+	return $res->content;
+    } else {
+	print STDERR "Error fetching configuration page: ", $res->status_line, "\n";
+	return undef;
+    }
+}
+
+sub print_login_info {
+  print "\nYou will be able to log in to $sname using the following:\n";
+  print "  username: $admin_username\n";
+  print "  password: $admin_password\n";
+}
+
+sub getclienthostname {
+    if (my $sshclient = $ENV{"SSH_CLIENT"}) {
+	my ($clientip) = split(' ', $sshclient);
+	my $hostname = gethostbyaddr(inet_aton($clientip), AF_INET);
+	return $hostname || $clientip;
+    } else {
+	return hostname();
+    }
+}
+
+sub press_enter {
+  local $/ = "\n";
+  print "Press [enter] to continue with the install.";
+  my $enter = <STDIN>; 
+}
+
+sub setup {
+  $ENV{PATH} = '/bin:/usr/bin';
+  $USER = $ENV{USER};
+  $HOME = $ENV{HOME};
+  
+  ($sname, $deploy, $addrend, $admin_username, $requires_sql, $scriptsdev, $human) = @ARGV;
+  chdir "$HOME/web_scripts/$addrend";
+  $email = "$human\@mit.edu";
+  
+  if($addrend =~ /^(.*)\/$/) {
+    $addrend = $1;
+  }
+  ($addrlast) = ($addrend =~ /([^\/]*)$/);
+  
+  $base_uri = "http://$USER.$server/$addrend/";
+  
+  if($requires_sql) {
+    print "\nCreating SQL database for $sname...\n";
+   
+    open GETPWD, '-|', "/mit/scripts/sql/bin$scriptsdev/get-password";
+    ($sqlhost, $sqluser, $sqlpass) = split(/\s/, <GETPWD>);
+    close GETPWD;
+    open SQLDB, '-|', "/mit/scripts/sql/bin$scriptsdev/get-next-database", $addrlast;
+    $sqldb = <SQLDB>;
+    close SQLDB;
+    open SQLDB, '-|', "/mit/scripts/sql/bin$scriptsdev/create-database", $sqldb;
+    $sqldb = <SQLDB>;
+    close SQLDB;
+    if($sqldb eq "") {
+      print "\nERROR:\n";
+      print "Your SQL account failed to create a SQL database.\n";
+      print "You should log in at http://sql.mit.edu to check whether\n";
+      print "your SQL account is at its database limit or its storage limit.\n";
+      print "If you cannot determine the cause of the problem, please\n";
+      print "feel free to contact sql\@mit.edu for assistance.\n";
+      open FAILED, ">.failed";
+      close FAILED;
+      exit 1;
+    }
+  }
+ 
+  if(-e "$HOME/web_scripts/$addrend/.admin") { 
+    open ADMIN, "<$HOME/web_scripts/$addrend/.admin";
+    $admin_password=<ADMIN>;
+    chomp($admin_password);
+    close ADMIN;
+    unlink "$HOME/web_scripts/$addrend/.admin";
+  } 
+
+  print "\nConfiguring $sname...\n";
+  if($requires_sql) {
+    print "A copy of ${USER}'s SQL login info will be placed in\n/mit/$USER/web_scripts/$addrend.\n";
+  }
+  
+  open(VERSION, ">.scripts-version") or die "Can't write scripts-version file: $!\n";
+  print VERSION strftime("%F %T %z\n", localtime);
+  print VERSION $ENV{'USER'}, '@', getclienthostname(), "\n";
+  my $tarball = abs_path("/mit/scripts/deploy$scriptsdev/$deploy.tar.gz");
+  print VERSION $tarball, "\n";
+  $tarball =~ s|/deploydev/|/deploy/|;
+  print VERSION dirname($tarball), "\n";
+  close(VERSION);
+
+  select STDOUT;
+  $| = 1; # STDOUT is *hot*!
+}
+
+1;
Index: locker/deploy/bin/wordpress-star
===================================================================
--- locker/deploy/bin/wordpress-star	(revision 1103)
+++ locker/deploy/bin/wordpress-star	(revision 1103)
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+use strict;
+use lib '/mit/scripts/deploy/bin';
+use onserver_star;
+use DBI;
+
+setup();
+
+fetch_uri(
+    'wp-admin/setup-config.php',
+    {step => 2},
+    {dbhost => $sqlhost,
+     uname => $sqluser,
+     dbname => $sqldb,
+     pwd => $sqlpass,
+     prefix => '',
+     submit => 'Submit',
+     step => 2});
+
+my $html = fetch_uri(
+    'wp-admin/install.php',
+    {step => 2},
+    {weblog_title => 'My Blog',
+     admin_email => $email,
+     submit => 'Continue',
+     step => 2});
+while ($html =~ /<code>(.*)<\/code>/g) {
+    $admin_username = $admin_password;
+    $admin_password = $1;
+}
+
+my $dbh = DBI->connect("dbi:mysql:database=$sqldb;host=$sqlhost", $sqluser, $sqlpass);
+$dbh->do("update wp_options set option_value = ? where option_name = 'siteurl'",
+         {}, "/~$USER/$addrend");
+$dbh->do("update wp_options set option_value = ? where option_name = 'home'",
+         {}, "http://$USER.$server/$addrend");
+$dbh->disconnect;
+
+print_login_info();
+print "You will also receive this login information at your MIT email address.\n";
+press_enter();
