diff options
author | Liam McLoughlin <hexxeh@hexxeh.net> | 2011-08-11 21:19:05 +0100 |
---|---|---|
committer | Liam McLoughlin <hexxeh@hexxeh.net> | 2011-08-11 21:19:05 +0100 |
commit | 20aaffd05379b748bb7455bdbbee2d92a13c370a (patch) | |
tree | 801be92b9ffaaa68c0b758c7e915034550145a6b | |
parent | Combine configs, fix image download path via a new config option, add initscript (diff) | |
download | gentoaster-20aaffd05379b748bb7455bdbbee2d92a13c370a.tar.gz gentoaster-20aaffd05379b748bb7455bdbbee2d92a13c370a.tar.bz2 gentoaster-20aaffd05379b748bb7455bdbbee2d92a13c370a.zip |
Added basic installer script and updated README appropriately
-rw-r--r-- | README | 14 | ||||
-rw-r--r-- | install.php | 74 |
2 files changed, 83 insertions, 5 deletions
@@ -4,7 +4,7 @@ Foreword ======= -Right now I'm developing this on Ubuntu/Debian, so the following instructions are for those platforms. This will eventually run on Gentoo, of course. +Right now I'm developing this on Ubuntu/Debian, so the following instructions are for those platforms. If you install the appropriate prerequisites, it will work on Gentoo too, of course. Prerequisites @@ -39,16 +39,18 @@ Installation cd /usr/share git clone http://git.overlays.gentoo.org/gitroot/proj/gentoaster.git - +Configure settings in config.php and web/config.php as appropriate +Run php5 install.php as root +Configure a webserver of your choice to server the web folder on the address you specified Running ======= -There's no init script for the daemon yet, so simply run as follows: +The installer will start the daemon for you automatically, but if you need to do this yourself later, run the following as root: -sudo php5 /usr/share/gentoaster/daemon.php & +/etc/init.d/gentoaster start -Note the use of sudo, the daemon MUST be ran as root for it to work, otherwise all builds will fail. +The daemon MUST be ran as root for it to work, otherwise all builds will fail. Now that the daemon is running, you can try a build, using the sample client: @@ -65,3 +67,5 @@ php5 /usr/share/gentoaster/status.php <handle hash> Where <handle hash> is the hash returned by client.php (for example 6085655f187a8442f82c43ebf98e5fdb) If the build is still running, you'll get a progress percentage. If it's finished, the return code and result message will be shown. + +If you've setup a webserver, you can also use the WebUI at the address you've configured diff --git a/install.php b/install.php new file mode 100644 index 0000000..8bb3515 --- /dev/null +++ b/install.php @@ -0,0 +1,74 @@ +<? + + // Gentoaster installer + // Licensed under GPL v3, see COPYING file + + // Check we're running as root + $processUser = posix_getpwuid(posix_geteuid()); + if($processUser['name'] != "root") { + die("This installer must be run as root\n"); + } + + // Load the configurations (the web config chainloads the daemon config) + echo "Loading configuration\n"; + require_once "web/config.php"; + + // Basic configuration path sanity checks + echo "Checking configuration sanity\n"; + if(!file_exists(GENTOASTER_PATH."/install.php")) { + die("GENTOASTER_PATH is set incorrectly\n"); + } + + // Check database configuration is sane + echo "Connecting to database\n"; + $db = new mysqli( + MYSQL_HOSTNAME, + MYSQL_USERNAME, + MYSQL_PASSWORD + ); + + if (mysqli_connect_errno()) { + die("Could not connect to MySQL server: ".mysqli_connect_error()."\n"); + } + + // If we reached here, MySQL details are fine + echo "Database connection is OK\n"; + + + // Make sure we have a dump file to use + if (file_exists(GENTOASTER_PATH."/gentoaster.sql")) { + // Prep MySQL details for shell args + $mysqlHostname = escapeshellarg(MYSQL_HOSTNAME); + $mysqlUsername = escapeshellarg(MYSQL_USERNAME); + $mysqlDatabase = mysql_escape_string(MYSQL_DATABASE); + + // Create shell component for password if required + if (strlen(MYSQL_PASSWORD) > 0) { + $mysqlPassword = " -p ".escapeshellarg(MYSQL_PASSWORD)." "; + } else { + $mysqlPassword = " "; + } + + // Drop any existing database here + system('echo "DROP DATABASE IF EXISTS '.$mysqlDatabase.';" | mysql -u '.$mysqlUsername.$mysqlPassword); + + // Create a new database + system('echo "CREATE DATABASE '.$mysqlDatabase.';" | mysql -u '.$mysqlUsername.$mysqlPassword); + + // Import the database dump into that database + system('mysql -u '.$mysqlUsername.$mysqlPassword.$mysqlDatabase.' < gentoaster.sql'); + } else { + die("SQL file not found, check GENTOASTER_PATH\n"); + } + + // Add the initscript for the daemon + echo "Adding initscript symlink\n"; + system("rm -f /etc/init.d/gentoaster"); + system("ln -s ".GENTOASTER_PATH."/gentoaster /etc/init.d/gentoaster"); + system("chmod +x ".GENTOASTER_PATH."/gentoaster"); + + echo "Starting Gentoaster daemon\n"; + exec("/etc/init.d/gentoaster start"); + + echo "If you didn't see any errors, the install was successful\n"; + echo "Try visiting the site at ".GENTOASTER_URL." to make sure everything works\n";
\ No newline at end of file |