2004-11-03 19:36:40 +03:00
|
|
|
## The system's main boot script.
|
|
|
|
|
|
|
|
##
|
|
|
|
## Some functions used by the main script
|
|
|
|
##
|
|
|
|
|
2008-04-26 00:52:33 +04:00
|
|
|
# launch <executable path> [ <thread to wait for> [ <program args> ] ]
|
2004-11-03 19:36:40 +03:00
|
|
|
|
2005-01-19 05:46:12 +03:00
|
|
|
launch() {
|
2008-04-26 00:52:33 +04:00
|
|
|
toLaunch="$1"
|
|
|
|
shift
|
|
|
|
toWaitFor="$1"
|
2010-08-13 16:42:46 +04:00
|
|
|
(( $# )) && shift
|
2008-04-26 00:52:33 +04:00
|
|
|
if [ -f "/boot/$toLaunch" ]
|
2004-11-03 19:36:40 +03:00
|
|
|
then
|
2008-04-26 00:52:33 +04:00
|
|
|
"/boot/$toLaunch" $* &
|
|
|
|
[ "$toWaitFor" != "" ] && waitfor "$toWaitFor"
|
2004-11-03 19:36:40 +03:00
|
|
|
return 1
|
|
|
|
else
|
2008-04-26 00:52:33 +04:00
|
|
|
echo There is no "$toLaunch"
|
2008-04-25 20:35:35 +04:00
|
|
|
fi
|
|
|
|
return 0
|
2009-04-03 13:02:44 +04:00
|
|
|
}
|
2004-11-03 19:36:40 +03:00
|
|
|
|
|
|
|
# launchscript <script path>
|
|
|
|
|
|
|
|
launchscript() {
|
|
|
|
if [ -f "/boot/$1" ]
|
|
|
|
then
|
|
|
|
. "/boot/$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-11-23 02:33:02 +03:00
|
|
|
# runprog <executable path>
|
|
|
|
|
|
|
|
runprog() {
|
|
|
|
if [ -f "/boot/$1" ]
|
|
|
|
then
|
|
|
|
"/boot/$1"
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
echo There is no "$1"
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2004-11-03 19:36:40 +03:00
|
|
|
##
|
|
|
|
## Main script starts here
|
|
|
|
##
|
|
|
|
|
|
|
|
# Set up stdin/out/err to nirvana
|
|
|
|
|
|
|
|
exec </dev/null
|
2006-05-16 18:50:46 +04:00
|
|
|
exec >/dev/null 2>&1
|
2004-11-03 19:36:40 +03:00
|
|
|
|
2005-01-19 05:46:12 +03:00
|
|
|
# Standard locations of boot files
|
2009-04-03 13:02:44 +04:00
|
|
|
SCRIPTS=system/boot
|
|
|
|
SERVERS=system/servers
|
2005-01-19 05:46:12 +03:00
|
|
|
|
2008-05-08 17:42:33 +04:00
|
|
|
# clean the shared memory dir
|
2010-01-16 20:17:07 +03:00
|
|
|
shmDir=/var/shared_memory
|
2008-05-08 17:42:33 +04:00
|
|
|
rm -rf $shmDir
|
2009-04-03 13:02:44 +04:00
|
|
|
mkdir -p $shmDir
|
2008-05-08 17:42:33 +04:00
|
|
|
chmod 777 $shmDir
|
|
|
|
|
2004-11-03 19:36:40 +03:00
|
|
|
# Set up the environment
|
|
|
|
|
2004-11-25 21:39:09 +03:00
|
|
|
export SAFEMODE=`/bin/safemode`
|
|
|
|
|
2004-11-03 19:36:40 +03:00
|
|
|
launchscript $SCRIPTS/SetupEnvironment
|
|
|
|
|
2008-03-06 04:20:09 +03:00
|
|
|
# If the boot volume is a CD we use another script
|
2009-06-05 19:59:21 +04:00
|
|
|
isReadOnly=`/bin/isvolume -readonly-partition /boot`
|
|
|
|
if [ "$isReadOnly" = "yes" ]; then
|
2009-04-22 23:40:41 +04:00
|
|
|
# block the CD tray (avoid accidental ejection)
|
|
|
|
# This option stays 'on' even if we continue booting to the desktop.
|
|
|
|
/bin/eject -b /boot
|
|
|
|
else
|
|
|
|
# Sets timezone etc.
|
|
|
|
runprog system/bin/clockconfig
|
2008-03-06 04:20:09 +03:00
|
|
|
fi
|
|
|
|
|
2010-02-25 13:40:58 +03:00
|
|
|
# Create /tmp dir, and make sure it's empty
|
|
|
|
|
|
|
|
TMPDIR=/boot/common/cache/tmp
|
|
|
|
if [ ! -d $TMPDIR ]; then
|
|
|
|
mkdir -f $TMPDIR
|
|
|
|
chmod a+rwx $TMPDIR
|
|
|
|
else
|
|
|
|
rm -rf $TMPDIR/*
|
|
|
|
fi
|
|
|
|
|
2004-11-23 02:33:02 +03:00
|
|
|
|
2005-01-16 00:34:20 +03:00
|
|
|
# Launch servers
|
|
|
|
|
2012-08-02 13:45:42 +04:00
|
|
|
# We must wait for the app_server and registrar to be ready
|
|
|
|
launch $SERVERS/registrar _roster_thread_ # launch registrar
|
|
|
|
|
2012-07-31 00:42:49 +04:00
|
|
|
# If app_server doesn't exist, just run consoled.
|
|
|
|
if [ ! -f "/boot/$SERVERS/app_server" ]; then
|
|
|
|
/bin/consoled
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2005-07-15 16:31:59 +04:00
|
|
|
launch $SERVERS/debug_server # launch debug_server
|
|
|
|
|
2007-01-15 19:16:10 +03:00
|
|
|
# Init Network
|
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
2009-05-08 18:29:29 +04:00
|
|
|
launch $SERVERS/net_server # launch net_server
|
2007-01-15 19:16:10 +03:00
|
|
|
fi
|
|
|
|
|
2009-08-14 21:55:28 +04:00
|
|
|
launch $SERVERS/app_server picasso # launch app_server
|
2005-06-07 04:54:23 +04:00
|
|
|
|
2005-01-19 05:46:12 +03:00
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
|
|
|
launch $SERVERS/syslog_daemon
|
2006-12-24 02:00:37 +03:00
|
|
|
waitfor _input_server_event_loop_ # wait for input devices
|
2005-01-19 05:46:12 +03:00
|
|
|
fi
|
|
|
|
|
2009-04-22 23:40:41 +04:00
|
|
|
# Now ask the user if he wants to run the Installer or continue to the Desktop.
|
2009-06-05 19:59:21 +04:00
|
|
|
if [ "$isReadOnly" = "yes" ]; then
|
2009-09-08 13:58:51 +04:00
|
|
|
# Create Installer link (using the write overlay)
|
2009-08-26 12:58:26 +04:00
|
|
|
ln -sf /boot/system/apps/Installer /boot/home/Desktop/Installer
|
|
|
|
|
2010-01-21 18:14:20 +03:00
|
|
|
/bin/ReadOnlyBootPrompt
|
2009-04-22 23:40:41 +04:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
launchscript $SCRIPTS/Bootscript.cd
|
|
|
|
exit 0 # and return
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2009-08-14 21:55:28 +04:00
|
|
|
if [ -e /etc/users ]; then
|
2009-10-12 18:52:17 +04:00
|
|
|
# TODO: system/Login needs to be fixed to launch the mount_server!
|
2009-08-14 21:55:28 +04:00
|
|
|
launch system/Login
|
|
|
|
# nothing more
|
2005-06-07 04:54:23 +04:00
|
|
|
else
|
2009-08-14 21:55:28 +04:00
|
|
|
cd /boot/home
|
2009-10-12 18:52:17 +04:00
|
|
|
|
|
|
|
launch $SERVERS/mount_server
|
|
|
|
waitfor -m application/x-vnd.Haiku-mount_server
|
|
|
|
# delay the boot script until all previous volumes have been mounted
|
|
|
|
hey -s mount_server DO InitialScan
|
|
|
|
|
2009-08-14 21:55:28 +04:00
|
|
|
launch system/Tracker
|
|
|
|
launch system/Deskbar
|
2005-06-07 04:54:23 +04:00
|
|
|
fi
|
2005-01-16 00:34:20 +03:00
|
|
|
|
2006-03-12 17:21:39 +03:00
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
|
|
|
launch $SERVERS/media_server
|
2006-06-30 01:57:15 +04:00
|
|
|
launch $SERVERS/midi_server
|
2006-03-12 17:21:39 +03:00
|
|
|
fi
|
|
|
|
|
2009-04-03 13:02:44 +04:00
|
|
|
# Launch Print Server
|
2007-05-20 23:04:58 +04:00
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
|
|
|
launch $SERVERS/print_server
|
|
|
|
fi
|
|
|
|
|
2008-04-25 20:35:35 +04:00
|
|
|
# Launch Mail Daemon (if enabled on startup)
|
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
2008-04-26 00:52:33 +04:00
|
|
|
launch $SERVERS/mail_daemon "" -E
|
2008-04-25 20:35:35 +04:00
|
|
|
fi
|
|
|
|
|
2009-05-17 18:15:00 +04:00
|
|
|
# Launch CDDB Daemon
|
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
|
|
|
launch $SERVERS/cddb_daemon ""
|
|
|
|
fi
|
|
|
|
|
2010-07-23 00:18:35 +04:00
|
|
|
# Launch Notification Server
|
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
|
|
|
launch $SERVERS/notification_server ""
|
|
|
|
fi
|
|
|
|
|
2011-10-29 02:21:07 +04:00
|
|
|
# Launch Power Daemon
|
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
|
|
|
launch $SERVERS/power_daemon ""
|
|
|
|
fi
|
|
|
|
|
2011-06-06 07:25:50 +04:00
|
|
|
# Check for daylight saving time
|
2009-04-03 13:02:44 +04:00
|
|
|
launch system/bin/dstcheck
|
2004-12-14 19:38:47 +03:00
|
|
|
|
2011-06-06 07:25:50 +04:00
|
|
|
# Synchronize network time
|
|
|
|
launch system/preferences/Time "" --update
|
|
|
|
|
2006-03-02 11:29:18 +03:00
|
|
|
if [ "$SAFEMODE" != "yes" ]; then
|
|
|
|
# Start user boot script
|
|
|
|
if [ -f $HOME/config/boot/UserBootscript ]; then
|
|
|
|
. $HOME/config/boot/UserBootscript
|
|
|
|
fi
|
|
|
|
fi
|
2008-03-06 01:25:33 +03:00
|
|
|
|
2008-05-04 17:10:42 +04:00
|
|
|
# Check for fresh install and run post install scripts.
|
2008-05-07 02:47:38 +04:00
|
|
|
postInstallDir=/boot/common/boot/post_install
|
|
|
|
freshInstallIndicator=/boot/common/settings/fresh_install
|
2008-05-04 17:10:42 +04:00
|
|
|
if [ -e $freshInstallIndicator ]; then
|
|
|
|
# wait a moment for things to calm down a bit
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
# execute scripts
|
|
|
|
for f in $postInstallDir/*.sh; do
|
|
|
|
if [ -f $f ]; then
|
|
|
|
echo "Running post install script $f ..." > /dev/dprintf
|
|
|
|
$f
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
sync
|
|
|
|
rm $freshInstallIndicator
|
2008-03-06 01:25:33 +03:00
|
|
|
fi
|