Permalink
Browse files

Added dedicated install mode

Activated by kernel option "install" (note: disable gdm with option "text")
  • Loading branch information...
1 parent 04b7ab2 commit eb2625c6ed7fcf7f24a187a64337fe42fbb6c0b6 @ikeydoherty ikeydoherty committed with Clement Lefebvre Jul 9, 2010
View
@@ -21,6 +21,7 @@ case "$1" in
configure)
update-mime-database /usr/share/mime
update-desktop-database
+ update-rc.d live-installer defaults 22
test -x /usr/bin/update-menus && update-menus
;;
@@ -0,0 +1,154 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: live-installer
+# Should-Start: console-screen acpid bootlogs dbus hal network-manager
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Live Installer
+# Description: Provides a dedicated operating mode for Live Installer
+# without a DE or DM
+### END INIT INFO
+
+# Author: Ikey Doherty <contactjfreak@gmail.com>
+#
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="Live Installer"
+NAME=live-installer-dm
+DAEMON=/usr/bin/$NAME
+DAEMON_ARGS="--options args"
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/live-installer
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ #reload|force-reload)
+ #
+ # If do_reload() is not implemented then leave this commented out
+ # and leave 'force-reload' as an alias for 'restart'.
+ #
+ #log_daemon_msg "Reloading $DESC" "$NAME"
+ #do_reload
+ #log_end_msg $?
+ #;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
@@ -1,3 +1,3 @@
#!/bin/bash
# Launch live-installer with all passed arguments (future reserved)
-/usr/lib/live-installer/main.py $*
+/usr/lib/live-installer/main.py
@@ -0,0 +1,11 @@
+#!/bin/bash
+# Set the display
+DISPLAY=":0"
+export DISPLAY
+# detect language (as per the livecd)
+LANG=`cat /etc/default/locale | grep -v '#' | head -n 1 | cut -d '=' -f 2 | sed 's/"//g'`
+export LANG
+# Launches a "display manager" for the live-installer
+/usr/lib/live-installer/standalone-dm.py
+
+
@@ -46,7 +46,7 @@ def show(self):
class InstallerWindow:
- def __init__(self):
+ def __init__(self, fullscreen=False):
self.resource_dir = '/usr/share/live-installer/'
#self.glade = 'interface.glade'
self.glade = os.path.join(self.resource_dir, 'interface.glade')
@@ -95,7 +95,6 @@ def __init__(self):
# language view
self.help_labels.append("Please select the language you wish to use\nfor this installation from the list below")
- #self.wTree.get_widget("label_select_language").set_markup(_("<span color=\"#FFFFFF\">Please select the language you wish to use\nfor this installation from the list below</span>"))
ren = gtk.CellRendererPixbuf()
column = gtk.TreeViewColumn("Flags", ren)
@@ -257,7 +256,17 @@ def __init__(self):
index+=1
widget = self.wTree.get_widget("label_step_%d" % index)
widget.modify_fg(gtk.STATE_NORMAL, color2)
-
+ if(fullscreen):
+ # dedicated installer mode thingum
+ img = gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/live-installer/logo.svg", 96, 96)
+ self.wTree.get_widget("logo").set_from_pixbuf(img)
+ self.window.maximize()
+ self.window.fullscreen()
+ else:
+ # running on livecd (windowed)
+ img = gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/live-installer/logo.svg", 64, 64)
+ self.wTree.get_widget("logo").set_from_pixbuf(img)
+
def quit_cb(self, widget, data=None):
''' ask whether we should quit. because touchpads do happen '''
gtk.main_quit()
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import sys
+import commands
sys.path.append('/usr/lib/live-installer')
from frontend.gtk_interface import InstallerWindow
@@ -12,5 +13,8 @@
# main entry
if __name__ == "__main__":
- win = InstallerWindow()
+ if("install" in commands.getoutput("cat /proc/cmdline")):
+ win = InstallerWindow(fullscreen=True)
+ else:
+ win = InstallerWindow(fullscreen=False)
gtk.main()
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+import os
+import sys
+import commands
+import subprocess
+
+# This allows the installer to run without the need for a desktop,
+# i.e. for those who do not wish to run the LiveCD or are restrained
+# by hardware limitations etc.
+# Or.. whatever. Some people need it.
+
+class StandaloneDM:
+
+ def __init__(self):
+ ''' Init the StandaloneDM '''
+ DISPLAY=":0" # represents which X..
+ wCMD = None
+ xCMD = "X -br :0"
+ sCMD = "gnome-settings-daemon"
+ if(os.path.exists("/usr/bin/metacity")):
+ # assume gnome desktop.
+ wCMD = "/usr/bin/metacity --sm-disable --display=%s &" % DISPLAY
+
+ xpid = self.pid_open(xCMD)
+ wpid = self.pid_open(wCMD)
+ spid = self.pid_open(sCMD, wait=True)
+
+ ppid = self.pid_open("/usr/lib/live-installer/main.py", wait=True)
+
+ #os.kill(wpid)
+ #os.kill(xpid)
+ #os.kill(spid)
+ os.system("pkill metacity")
+ os.system("pkill gnome-settings-daemon")
+ os.system("pkill X")
+ sys.exit(0)
+
+ def pid_open(self, proc, wait=False):
+ ''' open a process and return its pid '''
+ p = subprocess.Popen(proc, shell=True)
+ if(wait):
+ p.wait()
+ return p.pid
+
+# main entry point
+if __name__ == "__main__":
+ if "install" in commands.getoutput("cat /proc/cmdline"):
+ dm = StandaloneDM()
@@ -81,7 +81,7 @@
</packing>
</child>
<child>
- <widget class="GtkImage" id="image1">
+ <widget class="GtkImage" id="logo">
<property name="visible">True</property>
<property name="xpad">6</property>
<property name="ypad">2</property>
@@ -96,6 +96,8 @@
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="padding">2</property>
<property name="position">0</property>
</packing>
@@ -198,13 +200,17 @@
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -429,6 +435,8 @@
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="padding">4</property>
<property name="position">0</property>
</packing>
@@ -485,6 +493,9 @@
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">4</property>
<property name="position">1</property>
</packing>
</child>
@@ -588,6 +599,9 @@
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">4</property>
<property name="position">2</property>
</packing>
</child>
@@ -643,6 +657,8 @@
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
Oops, something went wrong. Retry.

0 comments on commit eb2625c

Please sign in to comment.