Commit 271a989a authored by Leigh B. Stoller's avatar Leigh B. Stoller

Changes for building the meta ports on FreeBSD 5.4, with a port tree

tagged from the 6.0 release. Also lots of changes to the install
scripts to handle inatlling boss/ops/fs on 5.4. All changes are
conditionalized so that things will continue to work on 4.10, but
hopefully we will move away from that before the year is out.
parent 78db03dc
...@@ -58,13 +58,14 @@ my $CP = "/bin/cp"; ...@@ -58,13 +58,14 @@ my $CP = "/bin/cp";
my $ENV = "/usr/bin/env"; my $ENV = "/usr/bin/env";
my $MOUNT = "/sbin/mount"; my $MOUNT = "/sbin/mount";
my $SUDO = "/usr/local/bin/sudo"; my $SUDO = "/usr/local/bin/sudo";
my $SUIDPERL = "/usr/bin/suidperl"; my $SUIDPERL = "/usr/bin/suidperl";
my $MYSQL = "/usr/local/bin/mysql"; my $MYSQL = "/usr/local/bin/mysql";
my $MYSQLADMIN = "/usr/local/bin/mysqladmin"; my $MYSQLADMIN = "/usr/local/bin/mysqladmin";
my $MYSQLSHOW = "/usr/local/bin/mysqlshow"; my $MYSQLSHOW = "/usr/local/bin/mysqlshow";
my $MYSQLDUMP = "/usr/local/bin/mysqldump"; my $MYSQLDUMP = "/usr/local/bin/mysqldump";
my $MYSQLINSTALL = "/usr/local/bin/mysql_install_db";
my $MYSQLDBDIR = "/var/db/mysql";
my $GMAKE = "/usr/local/bin/gmake"; my $GMAKE = "/usr/local/bin/gmake";
my $RNDC_CONFGEN = "/usr/local/sbin/rndc-confgen"; my $RNDC_CONFGEN = "/usr/local/sbin/rndc-confgen";
...@@ -84,15 +85,14 @@ my $ROOT_PRIVKEY = "/root/.ssh/identity"; ...@@ -84,15 +85,14 @@ my $ROOT_PRIVKEY = "/root/.ssh/identity";
my $ROOT_PUBKEY = "$ROOT_PRIVKEY.pub"; my $ROOT_PUBKEY = "$ROOT_PRIVKEY.pub";
my $ROOT_AUTHKEY = "/root/.ssh/authorized_keys"; my $ROOT_AUTHKEY = "/root/.ssh/authorized_keys";
my $APACHE_ETCDIR = "/usr/local/etc/apache";
my $SUDOERS = "/usr/local/etc/sudoers"; my $SUDOERS = "/usr/local/etc/sudoers";
my $HTTPD_CONF = "/usr/local/etc/apache/httpd.conf"; my $HTTPD_CONF = "$APACHE_ETCDIR/httpd.conf";
my $PHP_INI = "/usr/local/etc/php.ini"; my $PHP_INI = "/usr/local/etc/php.ini";
my $DHCPD_CONF = "/usr/local/etc/dhcpd.conf"; my $DHCPD_CONF = "/usr/local/etc/dhcpd.conf";
my $DHCPD_TEMPLATE = "/usr/local/etc/dhcpd.conf.template"; my $DHCPD_TEMPLATE = "/usr/local/etc/dhcpd.conf.template";
my $DHCPD_LEASES = "/var/db/dhcpd.leases"; my $DHCPD_LEASES = "/var/db/dhcpd.leases";
my $DHCPD_MAKECONF = "$PREFIX/sbin/dhcpd_makeconf"; my $DHCPD_MAKECONF = "$PREFIX/sbin/dhcpd_makeconf";
my $APACHE_CERTFILE = "/usr/local/etc/apache/ssl.crt/www.${OURDOMAIN}.crt";
my $APACHE_KEYFILE = "/usr/local/etc/apache/ssl.key/www.${OURDOMAIN}.key";
my $BATCHEXP = "$PREFIX/bin/batchexp"; my $BATCHEXP = "$PREFIX/bin/batchexp";
my $WAP = "$PREFIX/sbin/withadminprivs"; my $WAP = "$PREFIX/sbin/withadminprivs";
my $NAMED_SETUP = "$PREFIX/sbin/named_setup"; my $NAMED_SETUP = "$PREFIX/sbin/named_setup";
...@@ -116,8 +116,16 @@ my $EMULAB_PEM = "emulab.pem"; ...@@ -116,8 +116,16 @@ my $EMULAB_PEM = "emulab.pem";
my $CLIENT_PEM = "client.pem"; my $CLIENT_PEM = "client.pem";
my $CTRLNODE_PEM = "ctrlnode.pem"; my $CTRLNODE_PEM = "ctrlnode.pem";
my $ETC_EMULAB_DIR = "/etc/emulab"; my $ETC_EMULAB_DIR = "/etc/emulab";
my $APACHE_CERTPEM = "apache_cert.pem";
my $APACHE_KEYPEM = "apache_key.pem"; # Apache certs on both boss and ops
my $APACHE_CERTPEM = "apache_cert.pem";
my $APACHE_KEYPEM = "apache_key.pem";
my $APACHE_CERTFILE = "$APACHE_ETCDIR/ssl.crt/www.${OURDOMAIN}.crt";
my $APACHE_KEYFILE = "$APACHE_ETCDIR/ssl.key/www.${OURDOMAIN}.key";
my $APACHE_CERTPEM_OPS = "apache-ops_cert.pem";
my $APACHE_KEYPEM_OPS = "apache-ops_key.pem";
my $APACHE_CERTFILE_OPS = "$APACHE_ETCDIR/ssl.crt/${USERNODE}.crt";
my $APACHE_KEYFILE_OPS = "$APACHE_ETCDIR/ssl.key/${USERNODE}.key";
# #
# Some directories we care about # Some directories we care about
...@@ -184,11 +192,21 @@ if ($USERNODE eq $FSNODE) { ...@@ -184,11 +192,21 @@ if ($USERNODE eq $FSNODE) {
push(@OPS_NAMES, "fs"); push(@OPS_NAMES, "fs");
} }
# Version of FreeBSD.
my $FBSD_VERSION = 4;
if (`uname -r` =~ /^(\d)/) {
$FBSD_VERSION = $1;
}
else {
die("Could not determine what version of FreeBSD you are running!\n");
}
# #
# The meta-port (name and version) that drags in all the dependancies for # The meta-ports (name and version) that drag in all the dependancies for
# a boss node # a boss node. These are OS dependent as we upgrade.
# #
my $BOSS_PORT = "emulab-boss-1.8"; my $BOSS_PORT = (($FBSD_VERSION == 4) ? "emulab-boss-1.8" : "emulab-boss-2.0");
my $PHP4_PORT = "php4-extensions-1.0";
# #
# Figure out which directory we live in, so that some stages can do thing # Figure out which directory we live in, so that some stages can do thing
...@@ -286,9 +304,10 @@ Phase "usersgroups", "Creating users and groups", sub { ...@@ -286,9 +304,10 @@ Phase "usersgroups", "Creating users and groups", sub {
PhaseSkip("mysql user already exists"); PhaseSkip("mysql user already exists");
} }
ExecQuietFatal("$PW useradd mysql -g 88 -g 88 -h - ". ExecQuietFatal("$PW useradd mysql -g 88 -g 88 -h - ".
"-d /var/db/mysql -s /sbin/nologin -c 'MySQL Daemon'"); "-d $MYSQLDBDIR -s /sbin/nologin -c 'MySQL Daemon'");
ExecQuietFatal("$CHOWN mysql:mysql /var/db/mysql");
}; };
ExecQuietFatal("$CHOWN mysql:mysql $MYSQLDBDIR")
if (-e $MYSQLDBDIR);
}; };
Phase "dirs", "Setting directory permissions", sub { Phase "dirs", "Setting directory permissions", sub {
...@@ -335,14 +354,18 @@ Phase "tftp", "Setting up directories for tftp", sub { ...@@ -335,14 +354,18 @@ Phase "tftp", "Setting up directories for tftp", sub {
}; };
Phase "ports", "Installing ports", sub { Phase "ports", "Installing ports", sub {
if (!ExecQuiet("$PKG_INFO -e $BOSS_PORT")) { if (!ExecQuiet("$PKG_INFO -e $BOSS_PORT") &&
(($FBSD_VERSION == 4) || !ExecQuiet("$PKG_INFO -e $PHP4_PORT"))) {
PhaseSkip("Ports already installed"); PhaseSkip("Ports already installed");
} }
Phase "packages", "Installing packages", sub { Phase "packages", "Installing packages", sub {
if (!$packagedir) { if (!$packagedir) {
PhaseSkip("No package directory provided"); PhaseSkip("No package directory provided");
} }
ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $BOSS_PORT"); ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $BOSS_PORT")
if (!ExecQuiet("$PKG_INFO -e $BOSS_PORT"));
ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $PHP4_PORT")
if ($FBSD_VERSION > 4 && !ExecQuiet("$PKG_INFO -e $PHP4_PORT"));
}; };
if ($packagedir) { if ($packagedir) {
PhaseSkip("Packages installed okay"); PhaseSkip("Packages installed okay");
...@@ -351,21 +374,23 @@ Phase "ports", "Installing ports", sub { ...@@ -351,21 +374,23 @@ Phase "ports", "Installing ports", sub {
DoneIfExists("$PORTSMISCDIR/emulab-boss"); DoneIfExists("$PORTSMISCDIR/emulab-boss");
ExecQuietFatal("$SH $SRCDIR/ports/ports-install"); ExecQuietFatal("$SH $SRCDIR/ports/ports-install");
}; };
# Ick. The php4 port is broken with SSL, so we have to patch it - hopefully if ($FBSD_VERSION == 4) {
# it'll get fixed someday, and we remove this # Ick. The php4 port is broken with SSL, so we have to patch
Phase "php4patch", "Patching php4 port", sub { # it - hopefully it'll get fixed someday, and we remove this
if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $PHP4_PATCH")) { Phase "php4patch", "Patching php4 port", sub {
PhaseSkip("$PHP4_PATCH already applied"); if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $PHP4_PATCH")) {
} PhaseSkip("$PHP4_PATCH already applied");
ExecQuietFatal("$PATCH -f -l -p0 -i $PHP4_PATCH"); }
}; ExecQuietFatal("$PATCH -f -l -p0 -i $PHP4_PATCH");
};
}
PhaseFail("Please install ports manually, since some\n of them are " . PhaseFail("Please install ports manually, since some\n of them are " .
"interactive. Run: \n" . "interactive. Run: \n" .
"cd $PORTSMISCDIR/emulab-boss && make install\n" . " cd $PORTSMISCDIR/emulab-boss && make install\n" .
" cd $PORTSMISCDIR/emulab-php4 && make install\n" .
"then re-run this script."); "then re-run this script.");
}; };
# XXX Temporary.
Phase "portfixup", "Fixing up packages", sub { Phase "portfixup", "Fixing up packages", sub {
Phase "rsync", "Looking for rsync", sub { Phase "rsync", "Looking for rsync", sub {
if (!ExecQuiet("$PKG_INFO -x rsync")) { if (!ExecQuiet("$PKG_INFO -x rsync")) {
...@@ -379,7 +404,8 @@ Phase "portfixup", "Fixing up packages", sub { ...@@ -379,7 +404,8 @@ Phase "portfixup", "Fixing up packages", sub {
}; };
if ($WINSUPPORT) { if ($WINSUPPORT) {
Phase "gcc30", "Looking for GCC 3.0 and installing", sub { Phase "gcc30", "Looking for GCC 3.0 and installing", sub {
if (!ExecQuiet("$PKG_INFO -x gcc30")) { if ($FBSD_VERSION > 4 ||
!ExecQuiet("$PKG_INFO -x gcc30")) {
PhaseSkip("GCC 3.0 already installed"); PhaseSkip("GCC 3.0 already installed");
} }
...@@ -392,17 +418,24 @@ Phase "portfixup", "Fixing up packages", sub { ...@@ -392,17 +418,24 @@ Phase "portfixup", "Fixing up packages", sub {
}; };
Phase "patches", "Applying patches", sub { Phase "patches", "Applying patches", sub {
Phase "g++patch", "Patching g++'s STL", sub { if ($FBSD_VERSION == 4) {
if (!ExecQuiet("$PATCH -C -f -R -p0 -i $STL_PATCH")) { Phase "g++patch", "Patching g++'s STL", sub {
PhaseSkip("$STL_PATCH already applied"); if (!ExecQuiet("$PATCH -C -f -R -p0 -i $STL_PATCH")) {
} PhaseSkip("$STL_PATCH already applied");
ExecQuietFatal("$PATCH -f -p0 -i $STL_PATCH"); }
}; ExecQuietFatal("$PATCH -f -p0 -i $STL_PATCH");
};
}
Phase "m2cryptopatch", "Patching m2crypto", sub { Phase "m2cryptopatch", "Patching m2crypto", sub {
if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $M2CRYPTO_PATCH")) { my $patchfile = $M2CRYPTO_PATCH;
PhaseSkip("$M2CRYPTO_PATCH already applied");
if (ExecQuiet("$PKG_INFO -I -x m2crypto | fgrep -q -s '0.13'") == 0) {
$patchfile = "${patchfile}-0.13";
}
if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $patchfile")) {
PhaseSkip("$patchfile already applied");
} }
ExecQuietFatal("$PATCH -f -l -p0 -i $M2CRYPTO_PATCH"); ExecQuietFatal("$PATCH -f -l -p0 -i $patchfile");
}; };
}; };
...@@ -567,7 +600,14 @@ Phase "syslog", "Setting up syslog", sub { ...@@ -567,7 +600,14 @@ Phase "syslog", "Setting up syslog", sub {
}; };
Phase "database", "Setting up database", sub { Phase "database", "Setting up database", sub {
Phase "mysql", "Starting mysql", sub { Phase "initialize", "Initializing mysql", sub {
PhaseSkip("mysqld already initialzed")
if (-d "$MYSQLDBDIR/mysql");
ExecQuietFatal("$MYSQLINSTALL --ldata=${MYSQLDBDIR}");
ExecQuietFatal("$CHOWN -R mysql:mysql $MYSQLDBDIR");
};
Phase "mysql", "Starting mysqls", sub {
if (!ExecQuiet("$MYSQLADMIN ping")) { if (!ExecQuiet("$MYSQLADMIN ping")) {
PhaseSkip("mysqld already running"); PhaseSkip("mysqld already running");
} }
...@@ -639,6 +679,8 @@ Phase "database", "Setting up database", sub { ...@@ -639,6 +679,8 @@ Phase "database", "Setting up database", sub {
Phase "rc.conf", "Adding testbed content to $RCCONF", sub { Phase "rc.conf", "Adding testbed content to $RCCONF", sub {
DoneIfEdited($RCCONF); DoneIfEdited($RCCONF);
AppendToFileFatal($RCCONF, AppendToFileFatal($RCCONF,
qq|rpcbind_enable="YES"|,
qq|mountd_enable="YES"|,
qq|nfs_server_enable="YES"|, qq|nfs_server_enable="YES"|,
qq|nfs_server_flags="-u -t -n 16"|, qq|nfs_server_flags="-u -t -n 16"|,
qq|nfs_client_enable="YES"|, qq|nfs_client_enable="YES"|,
...@@ -651,10 +693,15 @@ Phase "rc.conf", "Adding testbed content to $RCCONF", sub { ...@@ -651,10 +693,15 @@ Phase "rc.conf", "Adding testbed content to $RCCONF", sub {
qq|apache_enable="YES"|); qq|apache_enable="YES"|);
}; };
Phase "suidperl", "Setting the suid bit on $SUIDPERL", sub { #
PhaseSkip("Already done") if (-u $SUIDPERL); # New version perl does not appear to require this anymore.
ExecQuietFatal("$CHMOD u+s $SUIDPERL"); #
}; if ($FBSD_VERSION == 4) {
Phase "suidperl", "Setting the suid bit on $SUIDPERL", sub {
PhaseSkip("Already done") if (-u $SUIDPERL);
ExecQuietFatal("$CHMOD u+s $SUIDPERL");
};
}
Phase "hosts", "Adding boss/ops/fs IP addresses to $HOSTS", sub { Phase "hosts", "Adding boss/ops/fs IP addresses to $HOSTS", sub {
DoneIfEdited($HOSTS); DoneIfEdited($HOSTS);
...@@ -868,7 +915,7 @@ Phase "sslcerts", "Setting up SSL certificates", sub { ...@@ -868,7 +915,7 @@ Phase "sslcerts", "Setting up SSL certificates", sub {
" 'chmod 640 ${ETC_EMULAB_DIR}/${CLIENT_PEM}; ". " 'chmod 640 ${ETC_EMULAB_DIR}/${CLIENT_PEM}; ".
" chmod 640 ${ETC_EMULAB_DIR}/${EMULAB_PEM}' "); " chmod 640 ${ETC_EMULAB_DIR}/${EMULAB_PEM}' ");
}; };
Phase "apache", "Setting up Apache", sub { Phase "apache", "Setting up Apache on boss", sub {
Phase "cert", "Installing Apache SSL certificate", sub { Phase "cert", "Installing Apache SSL certificate", sub {
DoneIfExists("$APACHE_CERTFILE"); DoneIfExists("$APACHE_CERTFILE");
ExecQuietFatal("$CP $TOP_OBJDIR/ssl/$APACHE_CERTPEM ". ExecQuietFatal("$CP $TOP_OBJDIR/ssl/$APACHE_CERTPEM ".
...@@ -888,6 +935,23 @@ Phase "sslcerts", "Setting up SSL certificates", sub { ...@@ -888,6 +935,23 @@ Phase "sslcerts", "Setting up SSL certificates", sub {
ExecQuietFatal("$RCDIR/apache.sh start"); ExecQuietFatal("$RCDIR/apache.sh start");
}; };
}; };
if ($FBSD_VERSION > 4) {
Phase "apache", "Setting up Apache on ops", sub {
Phase "cert", "Installing Apache SSL certificate", sub {
ExecQuietFatal("$SCP $TOP_OBJDIR/ssl/$APACHE_CERTPEM_OPS ".
" ${USERNODE}:$APACHE_CERTFILE_OPS");
};
Phase "key", "Installing Apache SSL key", sub {
ExecQuietFatal("$SCP $TOP_OBJDIR/ssl/$APACHE_KEYPEM_OPS ".
" ${USERNODE}:$APACHE_KEYFILE_OPS");
};
Phase "rc.d", "Installing Apache startup file", sub {
ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ".
" cp -f $RCDIR/apache.sh.sample ".
" $RCDIR/apache.sh");
};
};
}
}; };
Phase "event", "Setting up event system", sub { Phase "event", "Setting up event system", sub {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2003, 2004, 2005 University of Utah and the Flux Group. # Copyright (c) 2003, 2004, 2005, 2006 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
...@@ -56,11 +56,20 @@ sub usage { ...@@ -56,11 +56,20 @@ sub usage {
exit(1); exit(1);
} }
# Version of FreeBSD.
my $FBSD_VERSION = 4;
if (`uname -r` =~ /^(\d)/) {
$FBSD_VERSION = $1;
}
else {
die("Could not determine what version of FreeBSD you are running!\n");
}
# #
# The default meta-port (name and version) that drags in all the dependancies # The meta-ports (name and version) that drag in all the dependancies for
# for an fs node # an fs node. These are OS dependent as we upgrade.
# #
my $FS_PORT = "emulab-fs-1.4"; my $FS_PORT = (($FBSD_VERSION == 4) ? "emulab-fs-1.4" : "emulab-fs-2.0");
my $packagedir = ""; my $packagedir = "";
my $batchmode = 0; my $batchmode = 0;
...@@ -278,6 +287,7 @@ Phase "portfixup", "Fixing up packages", sub { ...@@ -278,6 +287,7 @@ Phase "portfixup", "Fixing up packages", sub {
Phase "rc.conf", "Adding testbed content to rc.conf", sub { Phase "rc.conf", "Adding testbed content to rc.conf", sub {
DoneIfEdited($RCCONF); DoneIfEdited($RCCONF);
AppendToFileFatal($RCCONF, AppendToFileFatal($RCCONF,
qq|rpcbind_enable="YES"|,
qq|nfs_server_enable="YES"|, qq|nfs_server_enable="YES"|,
qq|nfs_server_flags="-u -t -n 16"|, qq|nfs_server_flags="-u -t -n 16"|,
qq|mountd_flags="-r -p 900"|, qq|mountd_flags="-r -p 900"|,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2003, 2004, 2005 University of Utah and the Flux Group. # Copyright (c) 2003, 2004, 2005, 2006 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
...@@ -37,6 +37,9 @@ my $LOGFACIL = '@TBLOGFACIL@'; ...@@ -37,6 +37,9 @@ my $LOGFACIL = '@TBLOGFACIL@';
my $ELABINELAB = @ELABINELAB@; my $ELABINELAB = @ELABINELAB@;
my $WINSUPPORT = @WINSUPPORT@; my $WINSUPPORT = @WINSUPPORT@;
my $QUOTA_FSLIST= '@FS_WITH_QUOTAS@'; my $QUOTA_FSLIST= '@FS_WITH_QUOTAS@';
my $LOGDIR = "$PREFIX/log";
my $ETCDIR = "$PREFIX/etc";
# True if we are also the FS node # True if we are also the FS node
my $ISFS = ($USERNODE eq $FSNODE) ? 1 : 0; my $ISFS = ($USERNODE eq $FSNODE) ? 1 : 0;
...@@ -65,17 +68,28 @@ sub usage { ...@@ -65,17 +68,28 @@ sub usage {
exit(1); exit(1);
} }
# Version of FreeBSD.
my $FBSD_VERSION = 4;
if (`uname -r` =~ /^(\d)/) {
$FBSD_VERSION = $1;
}
else {
die("Could not determine what version of FreeBSD you are running!\n");
}
# #
# The default meta-port (name and version) that drags in all the dependancies # The meta-ports (name and version) that drag in all the dependancies for
# for an ops node # an ops/fs node. These are OS dependent as we upgrade.
# #
my $OPS_PORT = "emulab-ops-1.4"; my $OPS_PORT = (($FBSD_VERSION == 4) ? "emulab-ops-1.4" : "emulab-ops-2.0");
my $FS_PORT = "emulab-fs-1.4"; my $FS_PORT = (($FBSD_VERSION == 4) ? "emulab-fs-1.4" : "emulab-fs-2.0");
my $PHP4_PORT = "php4-extensions-1.0";
my $packagedir = ""; my $packagedir = "";
my $batchmode = 0; my $batchmode = 0;
my $password;
my %opts; my %opts;
if (! getopts("P:p:b", \%opts)) { if (! getopts("P:p:bw:F:", \%opts)) {
usage(); usage();
} }
if (defined($opts{p})) { if (defined($opts{p})) {
...@@ -87,7 +101,12 @@ if (defined($opts{b})) { ...@@ -87,7 +101,12 @@ if (defined($opts{b})) {
if (defined($opts{P})) { if (defined($opts{P})) {
$OPS_PORT = $opts{P}; $OPS_PORT = $opts{P};
} }
if (defined($opts{F})) {
$FS_PORT = $opts{F};
}
if (defined($opts{w})) {
$password = $opts{w};
}
if (@ARGV) { if (@ARGV) {
usage(); usage();
} }
...@@ -105,6 +124,7 @@ my $TOP_OBJDIR = "$OBJDIR/.."; ...@@ -105,6 +124,7 @@ my $TOP_OBJDIR = "$OBJDIR/..";
# #
my $CHGRP = "/usr/bin/chgrp"; my $CHGRP = "/usr/bin/chgrp";
my $CHMOD = "/bin/chmod"; my $CHMOD = "/bin/chmod";
my $CHOWN = "/usr/sbin/chown";
my $PW = "/usr/sbin/pw"; my $PW = "/usr/sbin/pw";
my $PATCH = "/usr/bin/patch"; my $PATCH = "/usr/bin/patch";
my $NEWALIASES = "/usr/bin/newaliases"; my $NEWALIASES = "/usr/bin/newaliases";
...@@ -138,6 +158,17 @@ my $CRONTAB = "/etc/crontab"; ...@@ -138,6 +158,17 @@ my $CRONTAB = "/etc/crontab";
my $AUTHKEYS = "/root/.ssh/authorized_keys"; my $AUTHKEYS = "/root/.ssh/authorized_keys";
my $SMBCONF_FILE = "/usr/local/etc/smb.conf"; my $SMBCONF_FILE = "/usr/local/etc/smb.conf";
my $SMBCONF_HEAD = "$SMBCONF_FILE.head"; my $SMBCONF_HEAD = "$SMBCONF_FILE.head";
my $APACHE_ETCDIR = "/usr/local/etc/apache";
my $HTTPD_CONF = "$APACHE_ETCDIR/httpd.conf";
# For installing mysqld
my $MYSQL = "/usr/local/bin/mysql";
my $MYSQLADMIN = "/usr/local/bin/mysqladmin";
my $MYSQLSHOW = "/usr/local/bin/mysqlshow";
my $MYSQLDUMP = "/usr/local/bin/mysqldump";
my $MYSQLINSTALL = "/usr/local/bin/mysql_install_db";
my $MYSQLDBDIR = "/var/db/mysql";
my $MYSQL_LOGDIR = "$LOGDIR/mysql";
# #
# Some directories we care about # Some directories we care about
...@@ -200,12 +231,29 @@ if ($UID != 0) { ...@@ -200,12 +231,29 @@ if ($UID != 0) {
# #
# The phases are fairly self-explanatory # The phases are fairly self-explanatory
# #
Phase "usersgroups", "Creating users and groups", sub {
Phase "groups", "Creating admin group", sub { Phase "tbadmin", "Creating tbadmin group", sub {
if (getgrnam("tbadmin")) { if (getgrnam("tbadmin")) {
PhaseSkip("tbadmin group already exists"); PhaseSkip("tbadmin group already exists");
} }
ExecQuietFatal("$PW groupadd tbadmin -g $TBADMINGID"); ExecQuietFatal("$PW groupadd tbadmin -g $TBADMINGID");
};
# Added next two cause the mysql package does not do this (port does).
Phase "mysqlgroup", "Creating mysql group", sub {
if (getgrnam("mysql")) {
PhaseSkip("mysql group already exists");
}
ExecQuietFatal("$PW groupadd mysql -g 88");
};
Phase "mysqluser", "Creating mysql user", sub {
if (getpwnam("mysql")) {
PhaseSkip("mysql user already exists");
}
ExecQuietFatal("$PW useradd mysql -g 88 -g 88 -h - ".
"-d $MYSQLDBDIR -s /sbin/nologin -c 'MySQL Daemon'");
};
ExecQuietFatal("$CHOWN mysql:mysql $MYSQLDBDIR")
if (-e $MYSQLDBDIR);
}; };
Phase "dirs", "Setting directory permissions", sub { Phase "dirs", "Setting directory permissions", sub {
...@@ -232,13 +280,17 @@ Phase "dirs", "Setting directory permissions", sub { ...@@ -232,13 +280,17 @@ Phase "dirs", "Setting directory permissions", sub {
Phase "ports", "Installing ports", sub { Phase "ports", "Installing ports", sub {
Phase "packages", "Installing packages", sub { Phase "packages", "Installing packages", sub {
if (!ExecQuiet("$PKG_INFO -e $OPS_PORT")) { if (!ExecQuiet("$PKG_INFO -e $OPS_PORT") &&
(($FBSD_VERSION == 4) || !ExecQuiet("$PKG_INFO -e $PHP4_PORT"))) {
PhaseSkip("Ports already installed"); PhaseSkip("Ports already installed");
} }
if (!$packagedir) { if (!$packagedir) {
PhaseSkip("No package directory provided"); PhaseSkip("No package directory provided");
} }
ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $OPS_PORT"); ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $OPS_PORT")
if (!ExecQuiet("$PKG_INFO -e $OPS_PORT"));
ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $PHP4_PORT")
if ($FBSD_VERSION > 4 && !ExecQuiet("$PKG_INFO -e $PHP4_PORT"));
}; };
Phase "fs-packages", "Installing FS packages", sub { Phase "fs-packages", "Installing FS packages", sub {
if (!$ISFS) { if (!$ISFS) {
...@@ -321,7 +373,8 @@ Phase "portfixup", "Fixing up packages", sub { ...@@ -321,7 +373,8 @@ Phase "portfixup", "Fixing up packages", sub {
ExecQuietFatal("$PKG_ADD samba-3.0.7,1"); ExecQuietFatal("$PKG_ADD samba-3.0.7,1");
}; };
Phase "gcc30", "Looking for GCC 3.0 and installing", sub { Phase "gcc30", "Looking for GCC 3.0 and installing", sub {
if (!ExecQuiet("$PKG_INFO -x gcc30")) { if ($FBSD_VERSION > 4 ||
!ExecQuiet("$PKG_INFO -x gcc30")) {
PhaseSkip("GCC 3.0 already installed"); PhaseSkip("GCC 3.0 already installed");
} }
...@@ -335,10 +388,15 @@ Phase "portfixup", "Fixing up packages", sub { ...@@ -335,10 +388,15 @@ Phase "portfixup", "Fixing up packages", sub {
Phase "patches", "Applying patches", sub { Phase "patches", "Applying patches", sub {
Phase "m2cryptopatch", "Patching m2crypto", sub { Phase "m2cryptopatch", "Patching m2crypto", sub {
if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $M2CRYPTO_PATCH")) { my $patchfile = $M2CRYPTO_PATCH;
PhaseSkip("$M2CRYPTO_PATCH already applied");
} if (ExecQuiet("$PKG_INFO -I -x m2crypto | fgrep -q -s '0.13'") == 0) {
ExecQuietFatal("$PATCH -f -p0 -l -i $M2CRYPTO_PATCH"); $patchfile = "${patchfile}-0.13";
}
if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $patchfile")) {
PhaseSkip("$patchfile already applied");
}
ExecQuietFatal("$PATCH -f -l -p0 -i $patchfile");
}; };
}; };
...@@ -346,10 +404,13 @@ Phase "rc.conf", "Adding testbed content to rc.conf", sub { ...@@ -346,10 +404,13 @@ Phase "rc.conf", "Adding testbed content to rc.conf", sub {
DoneIfEdited($RCCONF); DoneIfEdited($RCCONF);
AppendToFileFatal($RCCONF, AppendToFileFatal($RCCONF,
qq|sendmail_enable="YES"|, qq|sendmail_enable="YES"|,
qq|rpcbind_enable="YES"|,
qq|mountd_enable="YES"|,
qq|nfs_server_enable="YES"|, qq|nfs_server_enable="YES"|,
qq|nfs_server_flags="-u -t -n 16"|, qq|nfs_server_flags="-u -t -n 16"|,
qq|mountd_flags="-r -p 900"|, qq|mountd_flags="-r -p 900"|,
(($ISFS && $WINSUPPORT) ? qq|smbd_enable="YES"| : ()),