installvars.pm.in 12.8 KB
Newer Older
1 2
#!/usr/bin/perl -w
#
3
# Copyright (c) 2003-2015 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#
#
# A big set of variables that are common to the installation scripts.
#
package installvars;
use strict;
# Avoid having to predefine everything.
no strict "vars";
use Exporter;
use vars qw(@ISA $SYMLIST);
@ISA    = qw(Exporter);
@EXPORT = qw();

# These are set in the driver script from command line args.
$domakes     = 0;
$packagedir  = "";
$password    = undef;

# Version of FreeBSD.
$FBSD_MAJOR = 4;
$FBSD_MINOR = 10;
if (`uname -r` =~ /^(\d+)\.(\d+)/) {
    $FBSD_MAJOR = $1;
    $FBSD_MINOR = $2;
}
else {
    die("Could not determine what version of FreeBSD you are running!\n");
}
51 52 53 54 55 56 57
$FBSD_ARCH = "i386";
if (`uname -m` =~ /^(\S+)$/) {
    $FBSD_ARCH = $1;
}
else {
    die("Could not determine what architecutre FreeBSD is running on!\n");
}
58 59 60 61 62 63 64 65 66

#
# The meta-ports (name and version) that drag in all the dependancies for
# a boss node. These are OS dependent as we upgrade.
#
$BOSS_PORT = "emulab-boss-1.8";
$OPS_PORT  = "emulab-ops-1.4"; 
$FS_PORT   = "emulab-fs-1.4";
if ($FBSD_MAJOR > 4) {
67 68 69 70 71
    if ($FBSD_MAJOR > 9) {
	$BOSS_PORT = "emulab-boss-6.0";
	$OPS_PORT = "emulab-ops-6.0";
	$FS_PORT = "emulab-fs-6.0";
    } elsif ($FBSD_MAJOR == 9 && $FBSD_MINOR > 1) {
72 73 74 75
	$BOSS_PORT = "emulab-boss-5.1";
	$OPS_PORT = "emulab-ops-5.1";
	$FS_PORT = "emulab-fs-5.1";
    } elsif ($FBSD_MAJOR > 8 || ($FBSD_MAJOR == 8 && $FBSD_MINOR > 2)) {
76 77 78 79
	$BOSS_PORT = "emulab-boss-5.0";
	$OPS_PORT = "emulab-ops-5.0";
	$FS_PORT = "emulab-fs-5.0";
    } elsif ($FBSD_MAJOR > 7) {
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
	$BOSS_PORT = "emulab-boss-4.0";
	$OPS_PORT = "emulab-ops-4.0";
	$FS_PORT = "emulab-fs-4.0";
    } elsif ($FBSD_MAJOR == 7 && $FBSD_MINOR > 2) {
	$BOSS_PORT = "emulab-boss-3.1";
	$OPS_PORT = "emulab-ops-3.1";
	$FS_PORT = "emulab-fs-3.1";
    } elsif ($FBSD_MAJOR == 7) {
	$BOSS_PORT = "emulab-boss-3.0";
	$OPS_PORT = "emulab-ops-3.0";
	$FS_PORT = "emulab-fs-3.0";
    } elsif ($FBSD_MAJOR == 6 && $FBSD_MINOR > 2) {
	$BOSS_PORT = "emulab-boss-2.1";
	$OPS_PORT = "emulab-ops-2.1";
	$FS_PORT = "emulab-fs-2.1";
    } else {
	$BOSS_PORT = "emulab-boss-2.0";
	$OPS_PORT = "emulab-ops-2.0";
	$FS_PORT = "emulab-fs-2.0";
    }
}

# PHP5 is the only alternative at the moment and only for newer OSes
$PHP_VERSION = 4;
$PHP_PORT = "php4-extensions-1.0";
if ($FBSD_MAJOR > 7 || ($FBSD_MAJOR == 7 && $FBSD_MINOR > 2)) {
    $PHP_VERSION = 5;
107 108 109
    if ($FBSD_MAJOR > 9 || ($FBSD_MAJOR == 9 && $FBSD_MINOR > 1)) {
	$PHP_PORT = "php5-extensions-1.7";
    } elsif ($FBSD_MAJOR > 8 || ($FBSD_MAJOR == 8 && $FBSD_MINOR > 2)) {
110 111
	$PHP_PORT = "php5-extensions-1.6";
    } elsif ($FBSD_MAJOR > 7) {
112
	$PHP_PORT = "php5-extensions-1.4";
113
    } else {
114 115 116 117 118 119 120
	$PHP_PORT = "php5-extensions-1.3";
    }
}

# XXX temporary for tftp
$TFTPD_PKG	  = "emulab-tftp-hpa-0.48";

121
# XXX temporary for perl DBD mysql access (only needed for FBSD7 and below)
122 123 124 125 126 127 128 129 130 131 132 133 134 135
$P5DBD_PKG	  = "p5-DBD-mysql50-3.0002";

# Lots of patches
$STL_PATCH		= "$main::TOP_SRCDIR/patches/g++.patch";
$M2CRYPTO_PATCH		= "$main::TOP_SRCDIR/patches/m2crypto.patch";
$MYSQL_PM_PATCH		= "$main::TOP_SRCDIR/patches/Mysql.pm.patch";
$PHP4_PATCH		= "$main::TOP_SRCDIR/patches/php4-Makefile.patch";
$SELFLOAD_PATCH		= "$main::TOP_SRCDIR/patches/SelfLoader.patch";

#
# Version dependent python-fu 
#
$PYM2_PKG = "py25-m2crypto-0.19.1";
$PY_VER   = "python2.5";
136 137 138 139
if ($FBSD_MAJOR > 9) {
    $PYM2_PKG = "py27-m2crypto-0.21.1_1";
    $PY_VER = "python2.7";
} elsif ($FBSD_MAJOR > 8 || ($FBSD_MAJOR == 8 && $FBSD_MINOR > 2)) {
140 141 142
    $PYM2_PKG = "py27-m2crypto-0.21.1";
    $PY_VER = "python2.7";
} elsif ($FBSD_MAJOR > 7 || ($FBSD_MAJOR == 7 && $FBSD_MINOR > 2)) {
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
    $PYM2_PKG = "py26-m2crypto-0.20";
    $PY_VER = "python2.6";
}
# XXX temporary until someone extracts their head from the dark regions
$EASYINSTALL		= "/usr/local/bin/easy_install";

# These names are for the scripts.
$BOSS_SERVERNAME	= "boss";
$OPS_SERVERNAME 	= "ops";
$FS_SERVERNAME		= "fs";

# Should be configure variable
$TBADMINGID		= 101;

$TBROOT			= "@prefix@";
$PREFIX			= $TBROOT;

$MAINSITE		= @TBMAINSITE@;
$PGENISUPPORT		= @PROTOGENI_SUPPORT@;
Leigh B Stoller's avatar
Leigh B Stoller committed
162
$PROTOGENI_GENIRACK     = @PROTOGENI_GENIRACK@;
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
$ELABINELAB		= @ELABINELAB@;
$DBNAME			= "@TBDBNAME@";
$ERRORLOG_DBNAME	= "@TBERRORLOGDBNAME@";
$FRISADDR		= '@FRISEBEEMCASTADDR@';

$HAVE_XERCES		= "@HAVE_XERCES@";
$MAILMANSUPPORT		= @MAILMANSUPPORT@;
$WINSUPPORT		= @WINSUPPORT@;

$OURDOMAIN		= '@OURDOMAIN@';
$USERNODE		= '@USERNODE@';
$FSNODE			= '@FSNODE@';
$BOSSNODE		= '@BOSSNODE@';
$BOSSNODE_IP		= '@BOSSNODE_IP@';
$USERNODE_IP		= '@USERNODE_IP@';
$FSNODE_IP		= '@FSNODE_IP@';
$CONTROL_NETWORK	= "@CONTROL_NETWORK@";
$CONTROL_NETMASK	= "@CONTROL_NETMASK@";
$PUBLIC_NETMASK		= "@PUBLIC_NETMASK@";
182
$NTPSERVER		= "@NTPSERVER@";
183 184
$LOGFACIL		= '@TBLOGFACIL@';
$QUOTA_FSLIST		= '@FS_WITH_QUOTAS@';
Leigh B Stoller's avatar
Leigh B Stoller committed
185
$OURTIMEZONE	        = "@OURTIMEZONE@";
186
$NODECONSOLE		= "@NODECONSOLE@";
Leigh B Stoller's avatar
Leigh B Stoller committed
187
$MFSVERSION		= "@MFSVERSION@";
188 189 190 191 192

$LOGDIR			= "$TBROOT/log";
$ETCDIR			= "$PREFIX/etc";
$LIBDIR			= "$PREFIX/lib";
$WAP			= "$TBROOT/sbin/withadminprivs";
Leigh B Stoller's avatar
Leigh B Stoller committed
193
$TESTBED_CONTROL	= "$TBROOT/sbin/testbed-control";
194 195 196 197 198 199 200 201 202

$ELVIN_COMPAT		= @ELVIN_COMPAT@;
$MAILMANSUPPORT		= @MAILMANSUPPORT@;
$CVSSUPPORT		= @CVSSUPPORT@;
$BUGDBSUPPORT		= @BUGDBSUPPORT@;
$WIKISUPPORT		= @WIKISUPPORT@;
$NOSHAREDFS		= @NOSHAREDFS@;
# Are we a VM on boss?
$OPSVM_ENABLE		= @OPSVM_ENABLE@;
203 204
# mrouted no longer needed; replaced by IGMP querier in mfrisbeed
$NEEDMROUTED		= 0;
205
$ARCHSUPPORT		= @ARCHIVESUPPORT@;
206
$BROWSER_CONSOLE_ENABLE = @BROWSER_CONSOLE_ENABLE@;
207 208 209 210 211 212

#
# Some programs we use
#
$CHGRP			= "/usr/bin/chgrp";
$CHMOD			= "/bin/chmod";
Leigh B Stoller's avatar
Leigh B Stoller committed
213
$MKDIR			= "/bin/mkdir";
214 215 216 217
$TOUCH			= "/usr/bin/touch";
$CHOWN			= "/usr/sbin/chown";
$PW			= "/usr/sbin/pw";
$PATCH			= "/usr/bin/patch";
Mike Hibler's avatar
Mike Hibler committed
218 219 220
if ($FBSD_MAJOR >= 10) {
    $PATCH		.= " --posix";
}
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
$CAT			= "/bin/cat";
$NEWALIASES		= "/usr/bin/newaliases";
$SH			= "/bin/sh";
$PWD			= "/bin/pwd";
$CP			= "/bin/cp";
$MV			= "/bin/mv";
$ENV			= "/usr/bin/env";
$MOUNT			= "/sbin/mount";
$TAR			= "/usr/bin/tar";
$MD5			= "/sbin/md5";
$SSH_KEYGEN		= "/usr/bin/ssh-keygen";
$SUDO			= "/usr/local/bin/sudo";
$GMAKE			= "/usr/local/bin/gmake";
$MYSQL			= "/usr/local/bin/mysql";
$QUOTAON		= "/usr/sbin/quotaon";
$SSH_INIT		= "/usr/bin/ssh -1";
$SCP_INIT		= "/usr/bin/scp -1";
$SSH			= "/usr/bin/ssh -2";
$SCP			= "/usr/bin/scp -2";
#
# XXX keep 4.x ElabInElab install limping along...
#
if ($FBSD_MAJOR == 4) {
    $SCP_INIT = "/usr/bin/scp -oProtocol=1";
    $SCP =      "/usr/bin/scp -oProtocol=2";
}

$PORTSDIR		= "/usr/ports";
$PORTSMISCDIR		= "$PORTSDIR/misc";
$LIST_DIR		= "/etc/mail/lists";
$ALIASES_FILE           = "/etc/mail/aliases";
$VARRUN			= "/var/run";
$RCDIR			= "/usr/local/etc/rc.d";
$NAMED_DIR		= "/etc/namedb";
255
$RESOLVECONF		= "/etc/resolv.conf";
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
$FSTAB			= "/etc/fstab";
$RCCONF			= "/etc/rc.conf";
$HOSTS			= "/etc/hosts";
$LOCAL_HOSTNAMES	= "/etc/mail/local-host-names";
$EXPORTS_FILE		= "/etc/exports";
$EXPORTS_HEAD		= "$EXPORTS_FILE.head";
$SYSLOG_CONF		= "/etc/syslog.conf";
$NEWSYSLOG_CONF		= "/etc/newsyslog.conf";
$SUDOERS		= "/usr/local/etc/sudoers";
$SSHD_CONFIG		= "/etc/ssh/sshd_config";
$CRONTAB		= "/etc/crontab";
$TIPLOG_DIR		= "/var/log/tiplogs";
$OPSWWWDIR		= "/usr/local/www/data";
$WWWDIR			= "$PREFIX/www";
$AUTHKEYS		= "/root/.ssh/authorized_keys";
$RCCAPTURE		= "$PREFIX/etc/rc.capture";
$RCLOCAL		= "/etc/rc.local";
$PHP_INI		= "/usr/local/etc/php.ini";
$SENDMAIL_CF		= "/etc/mail/sendmail.cf";
$INETD_CONF		= "/etc/inetd.conf";
$ETCSSH			= "/etc/ssh";
$SSH_CONFIG	        = "$ETCSSH/ssh_config";
$LOADER_CONF		= "/boot/loader.conf";
$SYSCTL_CONF		= "/etc/sysctl.conf";

$GROUPROOT		= "@GROUPSROOT_DIR@";
$USERROOT		= "@USERSROOT_DIR@";
$SCRATCHROOT		= "@SCRATCHROOT_DIR@";
$SHAREROOT		= "@SHAREROOT_DIR@";
$PROJROOT		= "@PROJROOT_DIR@";

$TBOPSEMAIL		= "@TBOPSEMAIL@";
$TBTESTSUITEEMAIL	= "@TBTESTSUITEEMAIL@";

# For installing mysqld
$MYSQLADMIN		= "/usr/local/bin/mysqladmin";
$MYSQLSHOW		= "/usr/local/bin/mysqlshow";
$MYSQLDUMP		= "/usr/local/bin/mysqldump";
$MYSQLINSTALL		= "/usr/local/bin/mysql_install_db";
$MYSQLDBDIR		= "/var/db/mysql";
$MYSQL_LOGDIR		= "$LOGDIR/mysql";

$PROTOUSER		= "elabman";
$CHECKUPUSER		= "elabckup";

$INSTALL_APACHE_CONFIG	= "@INSTALL_APACHE_CONFIG@";
$APACHE_VERSION		= "@APACHE_VERSION@";
$APACHE_START_COMMAND	= "@APACHE_START_COMMAND@";
$APACHE_ETCDIR		= "$INSTALL_APACHE_CONFIG";
$HTTPD_CONF		= "$APACHE_ETCDIR/httpd.conf";
$APACHE_CERTPEM		= "apache.pem";
$APACHE_KEYPEM		= "apache.key";
$APACHE_CERTFILE	= "$APACHE_ETCDIR/ssl.crt/www.${OURDOMAIN}.crt";
$APACHE_KEYFILE		= "$APACHE_ETCDIR/ssl.key/www.${OURDOMAIN}.key";
$APACHE_CERTPEM_OPS	= "apache-ops.pem";
$APACHE_KEYPEM_OPS	= "apache-ops.key";
$APACHE_CERTFILE_OPS	= "$APACHE_ETCDIR/ssl.crt/${USERNODE}.crt";
$APACHE_KEYFILE_OPS	= "$APACHE_ETCDIR/ssl.key/${USERNODE}.key";

$PROTOGENI_RPCNAME	= "@PROTOGENI_RPCNAME@";
$PROTOGENI_RPCPORT	= "@PROTOGENI_RPCPORT@";
$PROTOGENI_EMAIL        = "@PROTOGENI_EMAIL@";

$DHCPD_CONF		= "/usr/local/etc/dhcpd.conf";
$DHCPD_TEMPLATE		= "/usr/local/etc/dhcpd.conf.template";
$DHCPD_LEASES		= "/var/db/dhcpd.leases";
$DHCPD_MAKECONF		= "$TBROOT/sbin/dhcpd_makeconf";
$NAMED_SETUP		= "$TBROOT/sbin/named_setup";

$BATCHEXP		= "$PREFIX/bin/batchexp";
$ADDPUBKEY		= "$PREFIX/sbin/addpubkey";
$TBACCT			= "$PREFIX/sbin/tbacct";
$GENTOPOFILE		= "$PREFIX/libexec/gentopofile";
329
$UPDATESITEVARS		= "$PREFIX/sbin/update_sitevars";
330 331 332 333 334

$PROTOUSER_KEY		= "$main::TOP_SRCDIR/install/elabman_dsa.pub";
$ROOT_PRIVKEY		= "/root/.ssh/id_rsa";
$ROOT_PUBKEY		= "$ROOT_PRIVKEY.pub";
$ROOT_AUTHKEY		= "/root/.ssh/authorized_keys";
335 336
$ROOT_DSA_PRIVKEY	= "/root/.ssh/id_dsa";
$ROOT_DSA_PUBKEY	= "$ROOT_DSA_PRIVKEY.pub";
337

338 339
$INIT_PRIVKEY		= "$main::TOP_SRCDIR/install/id_rsa";
$INIT_PUBKEY		= "$main::TOP_SRCDIR/install/id_rsa.pub";
340 341 342 343 344 345 346 347 348 349 350
$CACERT			= "$TBROOT/etc/emulab.pem";
$EMULAB_PEM		= "emulab.pem";
$CLIENT_PEM		= "client.pem";
$CTRLNODE_PEM		= "ctrlnode.pem";
$ETC_EMULAB_DIR		= "/etc/emulab";

$SMBCONF_FILE		= "/usr/local/etc/smb.conf";
$SMBCONF_HEAD		= "$SMBCONF_FILE.head";

$TFTP_DIR	        = "$PREFIX/tftpboot";
$TFTP_PROJ_DIR		= "$TFTP_DIR/proj";
Leigh B Stoller's avatar
Leigh B Stoller committed
351
$IMAGEKEYS_DIR	        = "$ETCDIR/image_hostkeys";
352

Leigh B Stoller's avatar
Leigh B Stoller committed
353
$DEFAULTIMAGESITEVAR    = "general/default_imagename";
354
$IMAGEPASSWORDSITEVAR   = "images/root_password";
Leigh B Stoller's avatar
Leigh B Stoller committed
355

356 357 358
$MAILMANDIR		= "/usr/local/mailman";
$MAILMANCFG		= "$MAILMANDIR/Mailman/mm_cfg.py";

359
$SHAREDIR		= "@FSDIR_SHARE@";
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
$SCRATCHDIR		= "@FSDIR_SCRATCH@";

$OUTERBOSS_XMLRPCPORT   = "@OUTERBOSS_XMLRPCPORT@";

@OPS_NAMES		= ($USERNODE, "users", "ops");
@MAILING_LISTS		= ("@TBOPSEMAIL@","@TBLOGSEMAIL@","@TBWWWEMAIL@",
			   "@TBAPPROVALEMAIL@","@TBAUDITEMAIL@",
			   "@TBSTATEDEMAIL@", "@TBTESTSUITEEMAIL@",
			   "@TBERRORSEMAIL@", "@TBAUTOMAILEMAIL@");
@LOCAL_MAILING_LISTS    = grep(/$OURDOMAIN$/, @MAILING_LISTS);

$USERSVAR_MOUNTPOINT	= "$PREFIX/usersvar";
$OPSDIR_MOUNTPOINT	= "$PREFIX/opsdir";
$OPSVM_MOUNTPOINT	= "@OPSVM_MOUNTPOINT@";

@MOUNTPOINTS		= ($USERROOT, $PROJROOT, $GROUPROOT);
if ($SHAREDIR) {
    push(@MOUNTPOINTS, $SHAREROOT);
}
if ($SCRATCHDIR) {
    push(@MOUNTPOINTS, $SCRATCHROOT);
}

# ElabinElab.
$OUTER_BOSS		 = '@OUTERBOSS_NODENAME@';
if ($OUTER_BOSS eq '') {
    $OUTER_BOSS = "www.emulab.net";
}

389 390 391 392 393 394
# Firewall stuff
$FIREWALL_BOSS		= @FIREWALL_BOSS@;
$FIREWALL_OPS		= @FIREWALL_OPS@;
$FIREWALL_BOSS_RULES    = "/etc/boss.ipfw";
$FIREWALL_OPS_RULES     = "/etc/ops.ipfw";

395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
sub ISBOSSNODE($)	{ return ($_[0] eq $BOSS_SERVERNAME) ? 1 : 0; }
sub ISOPSNODE($)	{ return ($_[0] eq $OPS_SERVERNAME) ? 1 : 0; }
sub ISFSNODE($)		{ return ($_[0] eq $FS_SERVERNAME) ? 1 : 0; }

#
# Is the given server the FS
#
sub ISFS($)
{
    my ($server) = @_;

    if ($server eq $BOSS_SERVERNAME) {
	return ($BOSSNODE_IP eq $FSNODE_IP) ? 1 : 0;
    }
    elsif ($server eq $OPS_SERVERNAME) {
	return ($USERNODE_IP eq $FSNODE_IP) ? 1 : 0;
    }
    elsif ($server eq $FS_SERVERNAME) {
	return 1;
    }
    return 0;
}

#
# The point of this code is to export every single symbol in this
# file to the caller, without having to list them all.
#
sub importup($)
{
    my ($caller) = @_;

    no strict 'refs';

    while (my ($name, $symbol) = each %{__PACKAGE__ . '::'}) {
        next if      $name eq 'BEGIN';    # don't export BEGIN blocks
        next if      $name eq 'import';   # don't export this sub

        my $imported = $caller . '::' . $name;
        *{ $imported } = \*{ $symbol };
    }
}

sub import {
    return importup(caller());
}

1;