Files
haiku-beta6/data/system/boot/Bootscript
T

213 lines
4.3 KiB
Plaintext
Raw Normal View History

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