diff options
author | Liam McLoughlin <hexxeh@hexxeh.net> | 2011-08-17 16:46:32 +0100 |
---|---|---|
committer | Liam McLoughlin <hexxeh@hexxeh.net> | 2011-08-17 16:46:32 +0100 |
commit | c7d7e6435bd7ee856854badd9e5e49864553bd6d (patch) | |
tree | 2dc4a5af77b59ff9393f3f25318a540a444a3c07 | |
parent | Make CSS image paths relative (diff) | |
download | gentoaster-c7d7e6435bd7ee856854badd9e5e49864553bd6d.tar.gz gentoaster-c7d7e6435bd7ee856854badd9e5e49864553bd6d.tar.bz2 gentoaster-c7d7e6435bd7ee856854badd9e5e49864553bd6d.zip |
Gentoo-style initscript, fix extlinux config and installer password arg
-rwxr-xr-x | gentoaster | 37 | ||||
-rw-r--r-- | install.php | 76 | ||||
-rw-r--r-- | res/extlinux.conf | 2 |
3 files changed, 49 insertions, 66 deletions
@@ -1,35 +1,18 @@ -#!/bin/bash +#!/sbin/runscript USER=root GENTOASTER=/usr/share/gentoaster/daemon.php -RETVAL=0 +GENTOASTER_PID=/usr/share/gentoaster/gentoaster.pid +GENTOASTER_LOG=/var/log/gentoaster.log start() { - echo "Starting Gentoaster" - start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/php -- -f $GENTOASTER - RETVAL=$? + ebegin "Starting Gentoaster" + start-stop-daemon --start --background --make-pidfile --pidfile ${GENTOASTER_PID} --user "${USER}" --stdout ${GENTOASTER_LOG} --exec /usr/bin/php --$ + eend $? } + stop() { - echo "Stopping Gentoaster" - killall -q -w -u $USER $GENTOASTER - RETVAL=$? + ebegin "Stopping Gentoaster" + start-stop-daemon --stop --exec /usr/bin/php --pidfile ${GENTOASTER_PID} + eend $? } - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - *) - echo "Usage: gentoaster {start|stop|restart}" - exit 1 - ;; -esac -exit $RETVAL - diff --git a/install.php b/install.php index 82fd732..796f9da 100644 --- a/install.php +++ b/install.php @@ -2,73 +2,73 @@ // 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"); + 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"); + die("GENTOASTER_PATH is set incorrectly\n"); } - - // Check database configuration is sane + + // Check database configuration is sane echo "Connecting to database\n"; $db = new mysqli( - MYSQL_HOSTNAME, + 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'); + // 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 = " --password=".escapeshellarg(MYSQL_PASSWORD)." "; + } else { + $mysqlPassword = " "; + } + + // Drop any existing database here + system('echo "DROP DATABASE IF EXISTS '.$mysqlDatabase.';" | mysql --user='.$mysqlUsername.$mysqlPassword); + + // Create a new database + system('echo "CREATE DATABASE '.$mysqlDatabase.';" | mysql --user='.$mysqlUsername.$mysqlPassword); + + // Import the database dump into that database + system('mysql --user='.$mysqlUsername.$mysqlPassword.$mysqlDatabase.' < gentoaster.sql'); } else { - die("SQL file not found, check GENTOASTER_PATH\n"); + 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"; + + 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"; diff --git a/res/extlinux.conf b/res/extlinux.conf index e69015e..a468dbc 100644 --- a/res/extlinux.conf +++ b/res/extlinux.conf @@ -3,4 +3,4 @@ timeout 10 label Gentoo kernel kernel - append root=/dev/hda3 ro ga=791 splash=silent,theme:default console=tty1 rootfstype=ext3 + append root=/dev/hda3 ro vga=791 splash=silent,theme:default console=tty1 rootfstype=ext3 |